Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anthropic): Fix multipart tool message #7096

Conversation

gingerhendrix
Copy link
Contributor

@gingerhendrix gingerhendrix commented Oct 28, 2024

Fixes handling multi-part (e.g. image and text) ToolMessages.

For Anthropic these need to be handled as HumanMessages with a type: "tool_result" MessageContentComplex, which itself can have a multipart content part (formatted according to anthropic's requirements).

https://x.com/gingerhendrixai

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 28, 2024
Copy link

vercel bot commented Oct 28, 2024

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

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Oct 29, 2024 9:39pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Oct 29, 2024 9:39pm

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Oct 28, 2024
Copy link
Member

@bracesproul bracesproul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good granted @jacoblee93 confirms it passes integration tests!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Oct 29, 2024
@jacoblee93
Copy link
Collaborator

Thank you!

@jacoblee93 jacoblee93 merged commit e0c05df into langchain-ai:main Oct 29, 2024
32 checks passed
@gingerhendrix gingerhendrix deleted the fix_anthropic_multipart_tool_message branch October 30, 2024 08:42
FilipZmijewski pushed a commit to FilipZmijewski/langchainjs that referenced this pull request Oct 31, 2024
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
aditishree1 pushed a commit to aditishree1/langchainjs that referenced this pull request Nov 1, 2024
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature lgtm PRs that are ready to be merged as-is size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants