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 duplicate ToolResult display in ChatMessage component #71

Closed
wants to merge 13 commits into from

Conversation

AtlantisPleb
Copy link
Contributor

@AtlantisPleb AtlantisPleb commented Aug 28, 2024

This PR addresses issue #65: ToolResult shows malformed data, the related rehydration issue mentioned in #69, and prevents duplicate content from being displayed.

Changes made:

  1. Modified the ChatMessage.tsx file to prevent duplicate rendering of ToolResult components.
  2. Implemented a useMemo hook to create a filtered list of unique tool invocations.
  3. Combined both toolInvocations and tool_invocations into a single array for processing.
  4. Used a Set to keep track of rendered invocations based on a unique key (toolName + stringified args).
  5. Replaced the two separate mappings of tool invocations with a single mapping of the filtered list.

These changes should resolve the following issues:

  • Prevent duplicate ToolResult components from being displayed.
  • Ensure consistent handling of tool invocations from both toolInvocations and tool_invocations arrays.
  • Improve performance by reducing unnecessary renders of duplicate ToolResult components.

The modifications should provide a more consistent and clean display of tool invocations in the chat interface, eliminating the issue of seeing the same content twice.

To test these changes:

  1. Deploy this version to a test environment.
  2. Test the chat interface with various tools, ensuring that each unique tool invocation is displayed only once.
  3. Verify that the displayed results are consistent and not duplicated across different message types (user messages, AI responses, etc.).
  4. Check that both toolInvocations and tool_invocations are properly handled and displayed.

Please review the changes and test the component thoroughly. If any issues persist or new ones arise, please let me know, and I'll make further modifications as needed.

Note: The previous commit was mistakenly made on the main branch. This PR now contains the correct changes on the issue-65-fix-toolresult-display branch. I apologize for any confusion this may have caused.

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 1:14am

Copy link

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

Copy link

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

Copy link

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

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.

@AtlantisPleb AtlantisPleb changed the title Fix ToolResult display issue Fix ToolResult display issue and prevent duplicate results after rehydration Aug 28, 2024
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 ToolResult display issue and prevent duplicate results after rehydration Fix ToolResult display issue and improve result rendering Aug 28, 2024
@AtlantisPleb AtlantisPleb changed the title Fix ToolResult display issue and improve result rendering Add extensive logging to ToolResult component for debugging Aug 28, 2024
Copy link

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

@AtlantisPleb AtlantisPleb changed the title Add extensive logging to ToolResult component for debugging Fix ToolResult display for both rehydrated and non-rehydrated data Aug 28, 2024
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 ToolResult display for both rehydrated and non-rehydrated data Fix ToolResult display and prevent duplicate content Aug 28, 2024
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 ToolResult display and prevent duplicate content Fix ToolResult display and prevent duplicate content using useRef Aug 28, 2024
@AtlantisPleb AtlantisPleb changed the title Fix ToolResult display and prevent duplicate content using useRef Fix duplicate ToolResult display in ChatMessage component Aug 28, 2024
Copy link

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

Copy link

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

@AtlantisPleb AtlantisPleb deleted the issue-65-fix-toolresult-display branch August 28, 2024 01:15
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