feat: view chat history with agent in client UI
Relates to
N/A - new feature not mentioned in issue/ticket
Risks
Low. Changes are mainly related to the chat UI, which does not affect the core system functionality.
One thing to note is the changes made to the API server's agent memory retrieval method implementation. The "unique" flag was disabled so that non-unique memories can also be retrieved from the agent's database.
Background
What does this PR do?
Chat UI can now load memories from database as chat history and visualize it to the user <> agent chatting interface.
What kind of change is this?
Features (non-breaking change which adds functionality)
Why are we doing this? Any context or related work?
As a part of Client improvements, this PR will enable chat history loading features that help users to easily pickup their previous chat with their agents.
Documentation changes needed?
My changes do not require a change to the project documentation.
Testing
Where should a reviewer start?
Reviewer should start by running the UI and check the changes made to the API server.
Detailed testing steps
- Run both the backend & frontend.
- Write some messages to the agent via the UI to create some chat memories for the agent
- Refresh the page to check if the messages is still there/ chat history is loaded.
Supplementary Info
In this PR, the API method /agents/:agentId/:roomId/memories is updated with the "unique" flag was disabled so that non-unique memories can also be retrieved from the agent's database.
Currently, based on my understanding, "unique" = false is decided if a new memory has high similarity with previous memories based on searching the embeddings of historical memories.
Any feedback on this change is welcomed. We could alternatively set up a new API method to retrieve non-"unique" memories and keep this method untouched.
relates to #2293
@coderabbitai review
📝 Walkthrough
Walkthrough
The pull request introduces enhancements to chat history management across multiple files. The changes focus on implementing a mechanism to retrieve and display agent memories in the chat interface. A new utility endpoint for UUID conversion is added, and the client-side API is extended to support fetching historical messages. The modifications enable dynamic loading of past conversations with improved state management and rendering logic.
Changes
| File | Change Summary |
|---|---|
client/src/components/chat.tsx |
- Added isHistory flag to ExtraContentFields interface- Introduced roomId and isLoadingHistory state variables- Implemented useEffect to load chat history on component mount |
client/src/lib/api.ts |
- Added getAgentMemories method to fetch agent memories- Introduced stringToUuid method for UUID conversion |
packages/client-direct/src/api.ts |
- Created /utils/string-to-uuid POST endpoint- Modified /agents/:agentId/:roomId/memories endpoint response structure- Added error handling for UUID conversion |
Finishing Touches
- [ ] 📝 Generate Docstrings (Beta)
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@odilitime can you have a look here; looks like you opened issue related to #2293
We're gonna integrate this work into the new API on v2-develop so I'm gonna close this, but I've passed it to the devs to work on