Merge pull request #2098 from StrongMind/aws-session-token

Add support for session token in AWS Nova Sonic service
This commit is contained in:
Mark Backman
2025-07-01 16:25:38 -04:00
committed by GitHub
3 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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(),