-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Langchain::Assistant works with AWS Bedrock-hosted Anthropic models (#…
…849) * Langchain::Assistant works with AWS Bedrock-hosted Anthropic models * specs * Update adapter.rb * Fixes * changelog entry
- Loading branch information
1 parent
7baf643
commit 683a85b
Showing
9 changed files
with
164 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
lib/langchain/assistant/llm/adapters/aws_bedrock_anthropic.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Langchain | ||
class Assistant | ||
module LLM | ||
module Adapters | ||
class AwsBedrockAnthropic < Anthropic | ||
private | ||
|
||
# @param [String] choice | ||
# @param [Boolean] _parallel_tool_calls | ||
# @return [Hash] | ||
def build_tool_choice(choice, _parallel_tool_calls) | ||
# Aws Bedrock hosted Anthropic does not support parallel tool calls | ||
Langchain.logger.warn "WARNING: parallel_tool_calls is not supported by AWS Bedrock Anthropic currently" | ||
|
||
tool_choice_object = {} | ||
|
||
case choice | ||
when "auto" | ||
tool_choice_object[:type] = "auto" | ||
when "any" | ||
tool_choice_object[:type] = "any" | ||
else | ||
tool_choice_object[:type] = "tool" | ||
tool_choice_object[:name] = choice | ||
end | ||
|
||
tool_choice_object | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.