Skip to content

Commit

Permalink
fix: keep consistent names
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfcabral committed Feb 1, 2025
1 parent f45340b commit 0489125
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libs/aws/langchain_aws/rerank/rerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class BedrockRerank(BaseDocumentCompressor):
"""Bedrock client to use for compressing documents."""
top_n: Optional[int] = 3
"""Number of documents to return."""
aws_region: str = Field(
region_name: str = Field(
default_factory=from_env("AWS_DEFAULT_REGION", default=None)
)
"""AWS region to initialize the Bedrock client."""
aws_profile: Optional[str] = Field(
credentials_profile_name: Optional[str] = Field(
default_factory=from_env("AWS_PROFILE", default=None)
)
"""AWS profile for authentication, optional."""
Expand All @@ -37,13 +37,16 @@ def initialize_client(self) -> Self:
"""Initialize the AWS Bedrock client."""
if not self.client:
session = self._get_session()
self.client = session.client("bedrock-agent-runtime")
self.client = session.client(
"bedrock-agent-runtime",
region_name=self.region_name
)
return self

def _get_session(self):
return (
boto3.Session(profile_name=self.aws_profile)
if self.aws_profile
boto3.Session(profile_name=self.credentials_profile_name)
if self.credentials_profile_name
else boto3.Session()
)

Expand Down

0 comments on commit 0489125

Please sign in to comment.