Skip to content

Commit fbe3d1b

Browse files
authored
Merge pull request #106 from 0xacx/escape-system-prompt-from-file
Escape system prompt from file
2 parents e6c213f + a5c3ddf commit fbe3d1b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

chatgpt.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,16 @@ request_to_image() {
125125
# $1 should be the message(s) formatted with role and content
126126
request_to_chat() {
127127
local message="$1"
128+
escaped_system_prompt=$(escape "$SYSTEM_PROMPT")
129+
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',
@@ -319,7 +321,7 @@ while $running; do
319321
if [ -z "$pipe_mode_prompt" ]; then
320322
if [ $MULTI_LINE_PROMPT = true ]; then
321323
echo -e "\nEnter a prompt: (Press Enter then Ctrl-D to send)"
322-
cat > "${USER_INPUT_TEMP_FILE}"
324+
cat >"${USER_INPUT_TEMP_FILE}"
323325
input_from_temp_file=$(cat "${USER_INPUT_TEMP_FILE}")
324326
prompt=$(escape "$input_from_temp_file")
325327
else

0 commit comments

Comments
 (0)