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] added missed client parameter in ChatBedrock #345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/aws/langchain_aws/chat_models/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ def _as_converse(self) -> ChatBedrockConverse:
if self.temperature is not None:
kwargs["temperature"] = self.temperature
return ChatBedrockConverse(
client=self.client,
model=self.model_id,
region_name=self.region_name,
credentials_profile_name=self.credentials_profile_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Standard LangChain interface tests"""

from typing import Literal, Type

from unittest.mock import Mock
import pytest
from langchain_core.language_models import BaseChatModel
from langchain_core.messages import HumanMessage
Expand Down Expand Up @@ -74,6 +74,33 @@ def test_tool_message_histories_list_content(self, model: BaseChatModel) -> None
super().test_tool_message_histories_list_content(model)


class TestBedrockNovaStandardWithClient(ChatModelIntegrationTests):
@property
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatBedrockConverse

@property
def chat_model_params(self) -> dict:
client = Mock()
return {"client": client, "model": "us.amazon.nova-pro-v1:0"}

@property
def standard_chat_model_params(self) -> dict:
return {"max_tokens": 300, "stop": []}

@property
def tool_choice_value(self) -> str:
return "auto"

@pytest.mark.xfail(reason="Tool choice 'Any' not supported.")
def test_structured_few_shot_examples(self, model: BaseChatModel) -> None:
super().test_structured_few_shot_examples(model)

@pytest.mark.xfail(reason="Human messages following AI messages not supported.")
def test_tool_message_histories_list_content(self, model: BaseChatModel) -> None:
super().test_tool_message_histories_list_content(model)


class TestBedrockCohereStandard(ChatModelIntegrationTests):
@property
def chat_model_class(self) -> Type[BaseChatModel]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def chat_model_class(self) -> Type[BaseChatModel]:
@property
def chat_model_params(self) -> dict:
return {
"client": None,
"model": "anthropic.claude-3-sonnet-20240229-v1:0",
"region_name": "us-west-1",
}
Expand Down