diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a12496d5..4ee856d90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 time, you will need to wrap it with `watchdog_coroutine()` so the watchdog timers are reset regularly. +- Added `session_token` parameter to `AWSNovaSonicLLMService`. + ### Fixed - Fixed a race condition that occurs in Python 3.10+ where the task could miss diff --git a/examples/foundational/40-aws-nova-sonic.py b/examples/foundational/40-aws-nova-sonic.py index ef01f7a47..ecfc4c1fb 100644 --- a/examples/foundational/40-aws-nova-sonic.py +++ b/examples/foundational/40-aws-nova-sonic.py @@ -102,6 +102,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), region=os.getenv("AWS_REGION"), # as of 2025-05-06, us-east-1 is the only supported region + session_token=os.getenv("AWS_SESSION_TOKEN"), voice_id="tiffany", # matthew, tiffany, amy # you could choose to pass instruction here rather than via context # system_instruction=system_instruction diff --git a/src/pipecat/services/aws_nova_sonic/aws.py b/src/pipecat/services/aws_nova_sonic/aws.py index 77e9575b5..a7832669e 100644 --- a/src/pipecat/services/aws_nova_sonic/aws.py +++ b/src/pipecat/services/aws_nova_sonic/aws.py @@ -194,6 +194,7 @@ class AWSNovaSonicLLMService(LLMService): *, secret_access_key: str, access_key_id: str, + session_token: Optional[str] = None, region: str, model: str = "amazon.nova-sonic-v1:0", voice_id: str = "matthew", # matthew, tiffany, amy @@ -208,6 +209,7 @@ class AWSNovaSonicLLMService(LLMService): Args: secret_access_key: AWS secret access key for authentication. access_key_id: AWS access key ID for authentication. + session_token: AWS session token for authentication. region: AWS region where the service is hosted. model: Model identifier. Defaults to "amazon.nova-sonic-v1:0". voice_id: Voice ID for speech synthesis. Options: matthew, tiffany, amy. @@ -220,6 +222,7 @@ class AWSNovaSonicLLMService(LLMService): super().__init__(**kwargs) self._secret_access_key = secret_access_key self._access_key_id = access_key_id + self._session_token = session_token self._region = region self._model = model self._client: Optional[BedrockRuntimeClient] = None @@ -523,7 +526,9 @@ class AWSNovaSonicLLMService(LLMService): region=self._region, aws_credentials_identity_resolver=StaticCredentialsResolver( credentials=AWSCredentialsIdentity( - access_key_id=self._access_key_id, secret_access_key=self._secret_access_key + access_key_id=self._access_key_id, + secret_access_key=self._secret_access_key, + session_token=self._session_token, ) ), http_auth_scheme_resolver=HTTPAuthSchemeResolver(),