@@ -105,7 +105,7 @@ maintain_chat_context() {
105
105
done
106
106
}
107
107
108
- # build user chat message function for /chat/completions (gpt turbo model )
108
+ # build user chat message function for /chat/completions (gpt models )
109
109
# builds chat message before request,
110
110
# $1 should be the chat message
111
111
# $2 should be the escaped prompt
@@ -122,18 +122,18 @@ build_user_chat_message() {
122
122
}
123
123
124
124
# adds the assistant response to the message in (chatml) format
125
- # for /chat/completions (gpt turbo model )
125
+ # for /chat/completions (gpt models )
126
126
# keeps messages length under max token limit
127
127
# $1 should be the chat message
128
128
# $2 should be the response data (only the text)
129
129
add_assistant_response_to_chat_message () {
130
130
chat_message=" $1 "
131
- response_data =" $2 "
131
+ local local_response_data =" $2 "
132
132
133
133
# replace new line characters from response with space
134
- response_data =$( echo " $response_data " | tr ' \n' ' ' )
134
+ local_response_data =$( echo " $local_response_data " | tr ' \n' ' ' )
135
135
# add response to chat context as answer
136
- chat_message=" $chat_message , {\" role\" : \" assistant\" , \" content\" : \" $response_data \" }"
136
+ chat_message=" $chat_message , {\" role\" : \" assistant\" , \" content\" : \" $local_response_data \" }"
137
137
138
138
# transform to json array to parse with jq
139
139
chat_message_json=" [ $chat_message ]"
@@ -306,8 +306,8 @@ while $running; do
306
306
eval $response_data
307
307
fi
308
308
fi
309
- response_data =$( echo " $response_data " | sed ' s/"/\\"/g' )
310
- add_assistant_response_to_chat_message " $chat_message " " $response_data "
309
+ escaped_response_data =$( echo " $response_data " | sed ' s/"/\\"/g' )
310
+ add_assistant_response_to_chat_message " $chat_message " " $escaped_response_data "
311
311
312
312
timestamp=$( date +" %d/%m/%Y %H:%M" )
313
313
echo -e " $timestamp $prompt \n$response_data \n" >> ~/.chatgpt_history
@@ -325,8 +325,8 @@ while $running; do
325
325
326
326
echo -e " ${CHATGPT_CYAN_LABEL}${response_data} "
327
327
328
- response_data =$( echo " $response_data " | sed ' s/"/\\"/g' )
329
- add_assistant_response_to_chat_message " $chat_message " " $response_data "
328
+ escaped_response_data =$( echo " $response_data " | sed ' s/"/\\"/g' )
329
+ add_assistant_response_to_chat_message " $chat_message " " $escaped_response_data "
330
330
331
331
timestamp=$( date +" %d/%m/%Y %H:%M" )
332
332
echo -e " $timestamp $prompt \n$response_data \n" >> ~/.chatgpt_history
@@ -349,8 +349,9 @@ while $running; do
349
349
escaped_response_data=$( echo " $response_data " | sed ' s/"/\\"/g' )
350
350
maintain_chat_context " $chat_context " " $escaped_response_data "
351
351
fi
352
-
352
+ echo " this"
353
+ echo $response_data
353
354
timestamp=$( date +" %d/%m/%Y %H:%M" )
354
- echo -e " $timestamp $prompt \n$escaped_response_data \n" >> ~/.chatgpt_history
355
+ echo -e " $timestamp $prompt \n$response_data \n" >> ~/.chatgpt_history
355
356
fi
356
- done
357
+ done
0 commit comments