Fix storing and passing previous messages to API #449
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Critical bug: conversation history is lost, bot remembers only the current message
Current version does not pass chat history to the API correctly:
vision_message_handle_fn
introduced new format for saving user messagesand
_generate_prompt_messages
has been changed accordingly.But in
message_handle_fn
it is stillCall of
extend(dialog_message["user"])
for the dialog message saved inmessage_handle_fn
results in splittingdialog_message["user"]
=_message
of typestr
into symbols, thus the structure inresponse
is messed and API returnssomething like
error_code=None error_message="'$.messages[3].content' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference." error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False chatgpt_telegram_bot | 2024-04-09 18:47:58 DEBUG: message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
and finally ignores the conversation context.