Skip to content

Commit

Permalink
aws[patch]: fix initialization of BedrockLLM without client (#204)
Browse files Browse the repository at this point in the history
`BedrockLLM.validate_environment` shadows its parent
`BedrockBase.validate_environment`, so the latter appears not to run.

Resolves #196
  • Loading branch information
ccurme authored Sep 19, 2024
1 parent 151125b commit bef0e87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/aws/langchain_aws/llms/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ class BedrockLLM(LLM, BedrockBase):
"""

@model_validator(mode="after")
def validate_environment(self) -> Self:
def validate_environment_llm(self) -> Self:
model_id = self.model_id
if model_id.startswith("anthropic.claude-3"):
raise ValueError(
Expand Down
8 changes: 8 additions & 0 deletions libs/aws/tests/integration_tests/llms/test_bedrock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from langchain_aws import BedrockLLM


def test_bedrock_llm() -> None:
llm = BedrockLLM(model_id="anthropic.claude-v2:1")
response = llm.invoke("Hello")
assert isinstance(response, str)
assert len(response) > 0

0 comments on commit bef0e87

Please sign in to comment.