microsoft / sample-app-aoai-chatGPT

Sample code for a simple web chat experience through Azure OpenAI, including Azure OpenAI On Your Data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

history/update is not executed when there are no errors in currentChat

tateren opened this issue · comments

Describe the bug
We have enabled chat history.
However, only user messages are being saved, and the assistant's responses are not being saved.

To Reproduce
Steps to reproduce the behavior:

  1. Enable chat history.
  2. Start the chat.

Expected behavior
Chat history is saved.

Configuration: Please provide the following

  • Azure OpenAI model name and version. gpt-35-turbo-16k
  • Is chat history enabled? Yes
  • Are you using data? No

Additional context
In this process, I believe that if there are no errors in currentChat, saveToDB is not being called.

const noContentError = appStateContext.state.currentChat.messages.find(m => m.role === ERROR)
if (noContentError && !noContentError.content.includes(NO_CONTENT_ERROR)) {
saveToDB(appStateContext.state.currentChat.messages, appStateContext.state.currentChat.id)

I have this same issue. The tools and assistant role history are not being saved to Cosmos DB. If I deploy a new Web App and Cosmos DB from the AI Playground, History is saved correctly. If I use the current code against my existing web app and Cosmos DBs, the history isn't saved correctly.

This doesn't seem to be called at any point of the conversation.

@bp.route("/history/generate", methods=["POST"])
async def add_conversation():

I have confirmed that this will be fixed by this pull request.
#768

The changes from #768 fixed the issue for me. Great work finding the issue so quickly!