assistant-ui icon indicating copy to clipboard operation
assistant-ui copied to clipboard

feat: Custom encode and decode for thread messages in cloud

Open lawnzapper opened this issue 9 months ago • 5 comments

Hello, I have integrated a custom encoder and decoder for thread messages into the AssistantCloud constructor. This enhancement allows an external cloud provider to manage not just text content, but also attachments or various types of data that need to be stored.


[!IMPORTANT] Adds custom encode/decode functions for thread messages in AssistantCloud, enhancing data handling flexibility.

  • Behavior:
    • Adds encodeMessage and decodeMessage to AssistantCloud constructor for custom message handling.
    • Defaults to auiV0Encode and auiV0Decode if no custom functions provided.
  • Integration:
    • AssistantCloudThreads in AssistantCloud.tsx now uses custom encode/decode functions.
    • append() and load() in AssistantCloudThreadHistoryAdapter.tsx use cloud.encodeMessage and cloud.decodeMessage for message processing.

This description was created by Ellipsis for 4bfc56883ef5fa65758849ed8bbdeb0936814c52. It will automatically update as commits are pushed.

lawnzapper avatar Mar 21 '25 16:03 lawnzapper

@lawnzapper is attempting to deploy a commit to the assistant-ui Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 21 '25 16:03 vercel[bot]

📝 Documentation updates detected! You can review documentation updates here

promptless[bot] avatar Mar 21 '25 16:03 promptless[bot]

Walkthrough

The changes add two new public properties, encodeMessage and decodeMessage, to the AssistantCloud class, initializing them in the constructor with values from a configuration parameter. If no custom functions are provided, they default to auiV0Encode and auiV0Decode. The instantiation of the threads property now passes these encoding and decoding functions as parameters to the AssistantCloudThreads instance. Additionally, modifications in the AssistantCloudThreadHistoryAdapter class update the append and load methods to use the cloud instance's encodeMessage and decodeMessage instead of the direct calls to the default functions. A local variable is introduced to reference the cloud instance, streamlining access to its methods for message handling.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 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 Mar 21 '25 16:03 coderabbitai[bot]

👋 Hey! As a free user, you're receiving reviews for every 5th PR. Upgrade to get reviews on every pull request and boost your code quality! Learn more here 🚀

trag-bot[bot] avatar Mar 21 '25 17:03 trag-bot[bot]

Pull request summary

  • Added auiV0Encode and auiV0Decode imports to AssistantCloud for message encoding and decoding.
  • Introduced encodeMessage and decodeMessage properties in the AssistantCloud class to allow custom encoding/decoding functions.
  • Updated the constructor of AssistantCloud to initialize encodeMessage and decodeMessage from the configuration or use default functions.
  • Refactored AssistantCloudThreadHistoryAdapter to utilize the encodeMessage method from the AssistantCloud instance when creating messages.
  • Modified the message loading logic in AssistantCloudThreadHistoryAdapter to use the decodeMessage method from the AssistantCloud instance for decoding messages.

trag-bot[bot] avatar Mar 21 '25 17:03 trag-bot[bot]

We implemented a .withFormat API which was inspired by this PR, thank you!

Yonom avatar Nov 17 '25 19:11 Yonom