Merge pull request #87 from tomas223/fix/multiline-file-prompt

fix: multiline file prompt input
escape-system-prompt-from-file
0xacx 1 year ago committed by GitHub
commit 4395626b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      chatgpt.sh

@ -125,6 +125,8 @@ request_to_image() {
# $1 should be the message(s) formatted with role and content
request_to_chat() {
local message="$1"
# escape quotation marks and newlines in the prompt
escaped_system_prompt=$(echo "$SYSTEM_PROMPT" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
curl https://api.openai.com/v1/chat/completions \
-sS \
-H 'Content-Type: application/json' \
@ -132,7 +134,7 @@ request_to_chat() {
-d '{
"model": "'"$MODEL"'",
"messages": [
{"role": "system", "content": "'"$SYSTEM_PROMPT"'"},
{"role": "system", "content": "'"$escaped_system_prompt"'"},
'"$message"'
],
"max_tokens": '$MAX_TOKENS',

Loading…
Cancel
Save