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

[Bufix] Modify the default value of sessionId when fetching history chat messages. #1661

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

melon95
Copy link

@melon95 melon95 commented Feb 2, 2024

Background

I used OpenAI's Assistant in ChatFlow and differentiated users based on their chatId.

Then, when I wanted to retrieve the user's chat message history based on the unique chatId, I had to first call /chatmessage/${chatflowid} to get all the historical chat messages. Then, I filtered the chat message based on chatId and obtained the sessionId. After that, I called /chatmessage/${chatflowid}?chatId=${chatId}&sessionId=${sessionId} to retrieve the user's chat message.

💡 Flowise internal sessionId is the threadId returned by Assistant and cannot be overwritten.

⚠️ Calling /chatmessage/${chatflowid} will retrieve all chat messages, which is not ideal.

Reason

The reason for needing to retrieve the chat history of a single user is because when querying the database, if only the chatId is passed, the sessionId will be null.

Untitled1

Code address

Solution

The value of sessionId is no longer related to chatId. This means that when retrieving the history messages of the current chatId, you only need to call the /chatmessage/${chatflowid}?chatId=${chatId} API once.
Untitled

@melon95 melon95 changed the title Modify the default value of sessionId when fetching history chat messages. [Bufix] Modify the default value of sessionId when fetching history chat messages. Feb 2, 2024
@automaton82
Copy link
Contributor

Does this fix #1666?

@melon95
Copy link
Author

melon95 commented Feb 4, 2024

yes. This issue is the same as my needs. @automaton82

@HenryHengZJ HenryHengZJ merged commit 6c80a14 into FlowiseAI:main Feb 6, 2024
2 checks passed
@melon95 melon95 deleted the bugfix/sessionId branch February 7, 2024 00:47
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.

3 participants