feat: Custom encode and decode for thread messages in cloud
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
encodeMessageanddecodeMessagetoAssistantCloudconstructor for custom message handling.- Defaults to
auiV0EncodeandauiV0Decodeif no custom functions provided.- Integration:
AssistantCloudThreadsinAssistantCloud.tsxnow uses custom encode/decode functions.append()andload()inAssistantCloudThreadHistoryAdapter.tsxusecloud.encodeMessageandcloud.decodeMessagefor message processing.This description was created by
for 4bfc56883ef5fa65758849ed8bbdeb0936814c52. It will automatically update as commits are pushed.
@lawnzapper is attempting to deploy a commit to the assistant-ui Team on Vercel.
A member of the Team first needs to authorize it.
📝 Documentation updates detected! You can review documentation updates here
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
@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 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.
👋 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 🚀
Pull request summary
- Added
auiV0EncodeandauiV0Decodeimports toAssistantCloudfor message encoding and decoding. - Introduced
encodeMessageanddecodeMessageproperties in theAssistantCloudclass to allow custom encoding/decoding functions. - Updated the constructor of
AssistantCloudto initializeencodeMessageanddecodeMessagefrom the configuration or use default functions. - Refactored
AssistantCloudThreadHistoryAdapterto utilize theencodeMessagemethod from theAssistantCloudinstance when creating messages. - Modified the message loading logic in
AssistantCloudThreadHistoryAdapterto use thedecodeMessagemethod from theAssistantCloudinstance for decoding messages.
We implemented a .withFormat API which was inspired by this PR, thank you!