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[patch]: add vertex and bedrock support, streamResponseChunk… #6206

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

tofuliang
Copy link
Contributor

Add support for vertex and bedrock, optimize stream response chunks

This pull request adds support for vertex and bedrock, and optimizes the *_streamResponseChunks method for better efficiency.

Changes:

  • Added support for vertex and bedrock:
    • Added necessary configurations and logic to handle vertex and bedrock requests.
  • Optimized *_streamResponseChunks method:
    • Simplified the logic for handling response chunks, making it more concise and efficient.

Question:

  • Should the extractToken method return tool_use related tokens?
    • Currently, the extractToken method returns tool_use related tokens as new tokens to handleLLMNewToken. This might be problematic because these tokens are not actual language model outputs for human.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 25, 2024
Copy link

vercel bot commented Jul 25, 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 26, 2024 10:47pm
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jul 26, 2024 10:47pm

@dosubot dosubot bot added auto:improvement Medium size change to existing code to handle new use-cases auto:question A specific question about the codebase, product, project, or how to use a feature labels Jul 25, 2024
"@anthropic-ai/sdk": "^0.22.0",
"@anthropic-ai/vertex-sdk": "^0.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Making this a required, rather than an optional, dependency adds a library for an edge case. (It also suggests that we can't include this in the google-vertex package, since we're not using this library there.)

Copy link
Collaborator

@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.

I just spoke async with the rest of the LangChain team, and we decided not to include Bedrock/Vertex support via the Anthropic package. For Anthropic via Bedrock, the new recommended approach is via ChatBedrockConverse in the @langchain/aws package. As for Vertex, any changes should be pushed to the @langchain/google-common package, which will then be used in @langchain/google-vertexai.

I pushed up a commit removing these additions, but still keeping the other refactors you made. Thanks for cleaning that up!

@danny-avila
Copy link

After this update (0.2.10), anthropic will stream with bound tools but it will not stream tool chunks.

Related issues:

langchain-ai/langgraphjs#253 (closed but still ongoing issue)
#6238

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 auto:question A specific question about the codebase, product, project, or how to use a feature size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants