File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -125,14 +125,16 @@ request_to_image() {
125125# $1 should be the message(s) formatted with role and content
126126request_to_chat () {
127127 local message=" $1 "
128+ # escape quotation marks and newlines in the prompt
129+ escaped_system_prompt=$( echo " $SYSTEM_PROMPT " | sed ' s/"/\\"/g' | sed ' :a;N;$!ba;s/\n/\\n/g' )
128130 curl https://api.openai.com/v1/chat/completions \
129131 -sS \
130132 -H ' Content-Type: application/json' \
131133 -H " Authorization: Bearer $OPENAI_KEY " \
132134 -d ' {
133135 "model": "' " $MODEL " ' ",
134136 "messages": [
135- {"role": "system", "content": "' " $SYSTEM_PROMPT " ' "},
137+ {"role": "system", "content": "' " $escaped_system_prompt " ' "},
136138 ' " $message " '
137139 ],
138140 "max_tokens": ' $MAX_TOKENS ' ,
You can’t perform that action at this time.
0 commit comments