Skip to content

Commit

Permalink
aws[patch]: make ChatBedrockConverse serializable (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan authored Sep 20, 2024
1 parent 019041e commit 7c20d8b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
24 changes: 16 additions & 8 deletions libs/aws/langchain_aws/chat_models/bedrock_converse.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,6 @@ class Joke(BaseModel):
populate_by_name=True,
)

@property
def lc_secrets(self) -> Dict[str, str]:
return {
"aws_access_key_id": "AWS_ACCESS_KEY_ID",
"aws_secret_access_key": "AWS_SECRET_ACCESS_KEY",
"aws_session_token": "AWS_SESSION_TOKEN",
}

@model_validator(mode="before")
@classmethod
def set_disable_streaming(cls, values: Dict) -> Any:
Expand Down Expand Up @@ -662,6 +654,22 @@ def _llm_type(self) -> str:
"""Return type of chat model."""
return "amazon_bedrock_converse_chat"

@classmethod
def is_lc_serializable(cls) -> bool:
return True

@classmethod
def get_lc_namespace(cls) -> list[str]:
return ["langchain_aws", "chat_models"]

@property
def lc_secrets(self) -> Dict[str, str]:
return {
"aws_access_key_id": "AWS_ACCESS_KEY_ID",
"aws_secret_access_key": "AWS_SECRET_ACCESS_KEY",
"aws_session_token": "AWS_SESSION_TOKEN",
}


def _messages_to_bedrock(
messages: List[BaseMessage],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# serializer version: 1
# name: TestBedrockStandard.test_serdes[serialized]
dict({
'id': list([
'langchain_aws',
'chat_models',
'ChatBedrockConverse',
]),
'kwargs': dict({
'max_tokens': 100,
'model_id': 'anthropic.claude-3-sonnet-20240229-v1:0',
'provider': 'anthropic',
'region_name': 'us-west-1',
'stop_sequences': list([
]),
'supports_tool_choice_values': list([
'auto',
'any',
'tool',
]),
'temperature': 0.0,
}),
'lc': 1,
'name': 'ChatBedrockConverse',
'type': 'constructor',
})
# ---

0 comments on commit 7c20d8b

Please sign in to comment.