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

Pop user message from multiturn if error is encountered #198

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

sfc-gh-cnivera
Copy link
Collaborator

@sfc-gh-cnivera sfc-gh-cnivera commented Oct 24, 2024

If a user has multiturn enabled but encounters an error, they are permanently stuck in a state where there are 2+ consecutive user messages in the conversation which prevents them from using the app at all unless they reload the page.

One option to fix this is to only save messages if the content can be successfully parsed. As such, if an error is encountered and we couldn't parse the assistant message, we remove the user message from the Streamlit session state.

Here is an example of the behavior, locally I've forced the API call to intermittently return an error. Note that we run into an error but are able to send later messages successfully, preserving multiturn context:

CleanShot.2024-10-24.at.15.25.05.mp4

Single-turn example:

CleanShot.2024-10-24.at.15.26.40.mp4

@sfc-gh-cnivera sfc-gh-cnivera linked an issue Oct 24, 2024 that may be closed by this pull request
@sfc-gh-cnivera sfc-gh-cnivera marked this pull request as ready for review October 24, 2024 22:27
@sfc-gh-jsummer
Copy link
Collaborator

Very simple and clever.

@sfc-gh-cnivera sfc-gh-cnivera merged commit 6a00f3a into main Oct 25, 2024
1 check passed
@sfc-gh-cnivera sfc-gh-cnivera deleted the cnivera/fix-multiturn branch October 25, 2024 16:30
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.

FIx multiturn behvaior when user question results in an error
2 participants