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 stop button preventing future chats and improve message order (Issue #67) #87

Closed
wants to merge 4 commits into from

Conversation

AtlantisPleb
Copy link
Contributor

@AtlantisPleb AtlantisPleb commented Aug 28, 2024

This PR addresses the issue of the stop button preventing future chats and causing errors when interrupted during tool calls (Issue #67).

Changes made:

  1. Modified the ensureValidMessageOrder function in app/api/chat/route.ts to handle potential errors and edge cases:
    • Added checks for invalid messages
    • Improved handling of tool messages and tool invocations
    • Enhanced error handling for message content combination
  2. Updated the POST function to include additional logging for better debugging
  3. Added explicit handling for assistant messages with tool invocations
  4. Improved the overall robustness of the message processing pipeline

These changes should prevent the "ValidationException" error that occurs when a tool call is interrupted, ensuring that the message order is always valid before sending it to the AI model. The new implementation also handles potential errors more gracefully, which should improve the overall stability of the chat functionality.

The updated ensureValidMessageOrder function now:

  • Checks for invalid messages and skips them
  • Handles tool messages and tool invocations more robustly
  • Combines consecutive messages with the same role more safely
  • Ensures the conversation starts and ends with a user message, even if the input is empty

Testing:

  • Please test by interrupting tool calls and verifying that subsequent messages can be sent without errors
  • Check that the chat history maintains the correct order and content after interruptions
  • Verify that the conversation flow remains natural even when tool calls are interrupted
  • Test with various edge cases, such as empty message arrays or invalid message formats

This PR should fully resolve the issues described in #67 and improve the overall robustness of the chat functionality.

Copy link

vercel bot commented Aug 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 5:56am

Copy link

The Vercel build for this PR has failed. Please check the Vercel deployment logs for more information.

@AtlantisPleb AtlantisPleb changed the title Fix stop button preventing future chats (Issue #67) Fix stop button preventing future chats and improve message order (Issue #67) Aug 28, 2024
Copy link

The Vercel build for this PR has failed. Please check the Vercel deployment logs for more information.

@AtlantisPleb AtlantisPleb deleted the issue-67-fix-stop-button-chat-prevention branch August 28, 2024 05:57
Copy link

The Vercel build for this PR has failed. Please check the Vercel deployment logs for more information.

1 similar comment
Copy link

The Vercel build for this PR has failed. Please check the Vercel deployment logs for more information.

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