Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix storing and passing previous messages to API #449

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

niquepolice
Copy link

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 messages

new_dialog_message = {"user": [{"type": "text", "text": message}], "bot": answer, "date": datetime.now()}

and _generate_prompt_messages has been changed accordingly.
But in message_handle_fn it is still

new_dialog_message = {"user": _message, "bot": answer, "date": datetime.now()}

Call of extend(dialog_message["user"]) for the dialog message saved in message_handle_fn results in splitting dialog_message["user"]= _message of type str into symbols, thus the structure in response is messed and API returns
something 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.

@niquepolice niquepolice mentioned this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant