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

anthropic[minor]: Implement actual anthropic tool call streaming #6056

Merged
merged 18 commits into from
Jul 16, 2024

Conversation

bracesproul
Copy link
Collaborator

@bracesproul bracesproul commented Jul 12, 2024

Depends on #6057 merging & releasing

Adds proper streaming tool call support to ChatAnthropic. Now it will

  • yield tool call chunks as they come in from anthropic
  • populate tool_calls in the final message with the tool calls

For backcompat:

  • still yields tool calls in anthropic format inside the content field with type: "tool_use"
  • JSON.parse()s the tool call input args inside the content block and only yield the final chunk so the input field contains valid JSON

Copy link

vercel bot commented Jul 12, 2024

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

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2024 1:10am
langchainjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2024 1:10am

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ignore this file, this is merged from #6057

@jacoblee93 jacoblee93 marked this pull request as ready for review July 16, 2024 01:01
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. auto:improvement Medium size change to existing code to handle new use-cases labels Jul 16, 2024
@jacoblee93 jacoblee93 merged commit 131267e into main Jul 16, 2024
38 checks passed
@jacoblee93 jacoblee93 deleted the brace/anthropic-tool-streaming branch July 16, 2024 01:33
@DevDeepakBhattarai
Copy link

DevDeepakBhattarai commented Jul 16, 2024

This exact feature is also missing from ChatGroq and ChatVertexAI. When ever we call the models with tools they don't stream.

@jacoblee93
Copy link
Collaborator

Thanks for flagging - can you open an issue?

I think when we initially implemented these integration packages, streaming tool calls weren't supported, but if they are now we should support.

@wh1pp3rz
Copy link

This is now broken when using streamEvents with ChatAnthropic, it;s giving the warning: The "tool_calls" field on a message is only respected if content is a string. and throws the exception: Error: Unsupported message content format.

@DevDeepakBhattarai
Copy link

DevDeepakBhattarai commented Jul 17, 2024

Thanks for flagging - can you open an issue?

I think when we initially implemented these integration packages, streaming tool calls weren't supported, but if they are now we should support.

Sure, I have opened #6099 and #6100

@danny-avila
Copy link

Still having streaming issues with ChatAnthropic using streamEvents and v2 in particular.

I saw an open issue in the langgraph repo so I posted there. This may be involve @langchain/anthropic or how streamEvents is handling a bound ChatAnthropic.

More details:
langchain-ai/langgraphjs#253 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants