aurelio-labs/semantic-router

Errors: BedrockEncoder

Opened this issue · 0 comments

Thank you for releasing the BedrockEncoder integration! Just having a couple of issues with the release

ValueError: No access_key_id provided

The BedrockEncoder currently uses "access_key_id", "secret_access_key" and "AWS_REGION" as the default environment variables would it be possible to update to the AWS Environment variables format of AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION

ValueError: No AWS_SESSION_TOKEN provided

The session token is optional/not required for IAM users but is currently enforced through a ValueError raise in the get_env_variable method - current workaround is providing an empty string

An error occurred (ExpiredTokenException) when calling the InvokeModel operation: The security token included in the request is expired

As the encoder is initialised with the session token if using the router in an application after uptime of an hour or specified time the token will expire and the Encoder and RouteLayer has to be recreated with a new token - it would be good to dynamically get the session token or utilise boto3.Session.client without explicitly setting the session token in the client

        self.session = session or boto3.Session()
        if self.session.get_credentials() is None:
            raise ValueError("Could not get AWS session")
        self.region = region or self.session.region_name
        if self.region is None:
            raise ValueError("No AWS region provided")
        try:
            self.client = self.session.client(
                service_name="bedrock-runtime", region_name=str(self.region)
            )