eliza icon indicating copy to clipboard operation
eliza copied to clipboard

feat: view chat history with agent in client UI

Open jonathanykh opened this issue 11 months ago • 4 comments

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. image

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

  1. Run both the backend & frontend.
  2. Write some messages to the agent via the UI to create some chat memories for the agent
  3. 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.

jonathanykh avatar Jan 13 '25 09:01 jonathanykh

relates to #2293

wtfsayo avatar Jan 15 '25 08:01 wtfsayo

@coderabbitai review

wtfsayo avatar Jan 15 '25 08:01 wtfsayo

📝 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Jan 15 '25 08:01 coderabbitai[bot]

@odilitime can you have a look here; looks like you opened issue related to #2293

wtfsayo avatar Jan 15 '25 09:01 wtfsayo

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

lalalune avatar Mar 08 '25 20:03 lalalune