@@ 57,22 57,31 @@ spinner() {
done
}
-mkprompt() {
- # make a preprompt to send to the openai chat api
- prompt="Provide only commands or scripts for the shell $(shell) without any description."
- prompt="$prompt The user is using the operating system $(os)."
- prompt="$prompt The user is currently in the directory \`$(cwd)\` on a host named \`$(hostname)\`."
+mkprompt_shell() {
+ prompt="Provide only commands or scripts for the shell \`$(shell)\`."
+ prompt="$prompt Do not give any explanations or descriptions."
+ prompt="$prompt Provide the command exactly as it should be ran, so the user can copy and paste it."
prompt="$prompt Ensure the output is a valid for the user's shell."
prompt="$prompt Provide the most logical solution if the prompt is unclear."
prompt="$prompt Try to make a one-line solution, but it is not required."
- prompt="$prompt The request is: $1"
- printf '%s\n' "$prompt"
+ prompt="$prompt The user is using the operating system $(os)."
+ prompt="$prompt The user is currently in the directory \`$(cwd)\` on a host named \`$(hostname)\`."
+ prompt="$prompt The user request is: $1"
+ printf '%s' "$prompt"
+}
+
+mkprompt_default() {
+ prompt='You are a shell script called shatgpt, assisting the user with programming and system administration.'
+ prompt="$prompt The user is using the operating system $(os)."
+ prompt="$prompt The user is currently in the directory \`$(cwd)\` on a host named \`$(hostname)\`."
+ prompt="$prompt The user request is: $1"
+ printf '%s' "$prompt"
}
mkbody() {
# make a body to send to the openai chat api
# $1 - prompt
- printf '%s\n' "{\"model\": \"gpt-3.5-turbo\", \"stream\": true, \"messages\": [{\"role\": \"user\", \"content\": \"$*\"}]}"
+ printf '%s\n' "{\"model\": \"gpt-3.5-turbo\", \"stream\": true, \"messages\": [{\"role\": \"user\", \"content\": \"$1\"}]}"
}
get_field() {