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

[fix]: langchain-community bedrock anthropic support

Open pavel1tel opened this issue 7 months ago • 7 comments

For some reason content parts type are different when using langgraph with bedrock claude models, causing "Unknown content part type" in convertLangChainMessages.ts. So I added missing types to fix this issue


[!IMPORTANT] Adds support for text_delta and input_json_delta types in convertLangChainMessages.ts to fix type errors with Bedrock Claude models.

  • Behavior:
    • Adds support for text_delta and input_json_delta types in contentToParts() in convertLangChainMessages.ts to prevent "Unknown content part type" errors.
  • Types:
    • Updates MessageContentText to include text_delta type in types.ts.
    • Updates MessageContentToolUse to include input_json_delta type in types.ts.

This description was created by Ellipsis for a38ff77b1302c7e400b7eba5d3cbc7007c57a0e2. You can customize this summary. It will automatically update as commits are pushed.

pavel1tel avatar May 20 '25 20:05 pavel1tel

🦋 Changeset detected

Latest commit: 8edefe437bc9baf74eac9cf2abd6f2e71b6db865

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@assistant-ui/react-langgraph Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar May 20 '25 20:05 changeset-bot[bot]

Someone 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 May 20 '25 20:05 vercel[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
assistant-ui-registry ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 20, 2025 11:01pm

vercel[bot] avatar May 20 '25 20:05 vercel[bot]

✅ No documentation updates required.

promptless[bot] avatar May 20 '25 20:05 promptless[bot]

Review Summary

Skipped posting 1 drafted comments based on your review threshold. Feel free to update them here.

Draft Comments
packages/react-langgraph/src/convertLangChainMessages.ts:29-31
The `default` case in the switch statement doesn't wrap the declaration in a block, which could lead to variable scoping issues. The linter suggests wrapping the declaration in a block to restrict its access.

Scores:

  • Production Impact: 3
  • Fix Specificity: 5
  • Urgency Impact: 3
  • Total Score: 11

Reason for filtering: The comment addresses a legitimate code issue with variable scoping in switch statements that could lead to unexpected behavior.

Analysis: The issue involves variable scoping in a switch statement which could potentially cause bugs if other cases access the variable incorrectly. The fix is extremely specific and directly applicable. While important for code correctness, it's unlikely to cause immediate production failures as it's in an error handling path. The total score falls below the threshold of 13, but the issue is still valid and worth addressing.

Walkthrough

The changes extend the message content handling by adding support for two new content part types. The conversion function now processes "text_delta" parts as "text" and excludes "input_json_delta" parts by returning null. Correspondingly, the type definitions were updated to allow "text_delta" as a valid type for MessageContentText and "input_json_delta" as a valid type for MessageContentToolUse. No other logic or types were altered.


📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a38ff77b1302c7e400b7eba5d3cbc7007c57a0e2 and 069b525600de7a0c55e5721d70d66f9f036b9125.

⛔ Files ignored due to path filters (1)
  • .changeset/sharp-bugs-itch.md is excluded by !.changeset/**
📒 Files selected for processing (2)
  • packages/react-langgraph/src/convertLangChainMessages.ts (2 hunks)
  • packages/react-langgraph/src/types.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/react-langgraph/src/convertLangChainMessages.ts
  • packages/react-langgraph/src/types.ts
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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 May 20 '25 20:05 coderabbitai[bot]

Bug Report

Name Severity Example test case Description
tool_use and input_json_delta information is dropped Medium Create a LangGraph message with tool_use or input_json_delta content, then convert it using convertLangChainMessages. The tool call information will be dropped. The contentToParts function in convertLangChainMessages.ts explicitly returns null for tool_use and input_json_delta content types. This means that any tool call information or input json deltas will be dropped during the conversion process, potentially breaking functionality if the UI relies on tool calls or state updates.

Comments? Email us.

jazzberry-ai[bot] avatar Jun 05 '25 19:06 jazzberry-ai[bot]

Bug Report

Name Severity Example test case Description
Cross-Site Scripting (XSS) vulnerability in text_delta content Critical Send a LangChain message with content containing a text_delta part with a malicious JavaScript payload, such as <script>alert("XSS")</script>. The convertLangChainMessages.ts file extracts the text content from text_delta and passes it to the UI. If this content is not properly sanitized, an attacker can inject malicious JavaScript code that will be executed in the user's browser. This can lead to session hijacking, data theft, and other malicious activities. The fix should involve HTML-encoding the text before rendering it in the UI.

Comments? Email us.

jazzberry-ai[bot] avatar Jun 05 '25 19:06 jazzberry-ai[bot]

Thanks!

AVGVSTVS96 avatar Jun 05 '25 19:06 AVGVSTVS96