Merge pull request #2098 from StrongMind/aws-session-token
Add support for session token in AWS Nova Sonic service
This commit is contained in:
@@ -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
|
time, you will need to wrap it with `watchdog_coroutine()` so the watchdog
|
||||||
timers are reset regularly.
|
timers are reset regularly.
|
||||||
|
|
||||||
|
- Added `session_token` parameter to `AWSNovaSonicLLMService`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed a race condition that occurs in Python 3.10+ where the task could miss
|
- Fixed a race condition that occurs in Python 3.10+ where the task could miss
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si
|
|||||||
secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
|
secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
|
||||||
access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
|
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
|
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
|
voice_id="tiffany", # matthew, tiffany, amy
|
||||||
# you could choose to pass instruction here rather than via context
|
# you could choose to pass instruction here rather than via context
|
||||||
# system_instruction=system_instruction
|
# system_instruction=system_instruction
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ class AWSNovaSonicLLMService(LLMService):
|
|||||||
*,
|
*,
|
||||||
secret_access_key: str,
|
secret_access_key: str,
|
||||||
access_key_id: str,
|
access_key_id: str,
|
||||||
|
session_token: Optional[str] = None,
|
||||||
region: str,
|
region: str,
|
||||||
model: str = "amazon.nova-sonic-v1:0",
|
model: str = "amazon.nova-sonic-v1:0",
|
||||||
voice_id: str = "matthew", # matthew, tiffany, amy
|
voice_id: str = "matthew", # matthew, tiffany, amy
|
||||||
@@ -208,6 +209,7 @@ class AWSNovaSonicLLMService(LLMService):
|
|||||||
Args:
|
Args:
|
||||||
secret_access_key: AWS secret access key for authentication.
|
secret_access_key: AWS secret access key for authentication.
|
||||||
access_key_id: AWS access key ID 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.
|
region: AWS region where the service is hosted.
|
||||||
model: Model identifier. Defaults to "amazon.nova-sonic-v1:0".
|
model: Model identifier. Defaults to "amazon.nova-sonic-v1:0".
|
||||||
voice_id: Voice ID for speech synthesis. Options: matthew, tiffany, amy.
|
voice_id: Voice ID for speech synthesis. Options: matthew, tiffany, amy.
|
||||||
@@ -220,6 +222,7 @@ class AWSNovaSonicLLMService(LLMService):
|
|||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self._secret_access_key = secret_access_key
|
self._secret_access_key = secret_access_key
|
||||||
self._access_key_id = access_key_id
|
self._access_key_id = access_key_id
|
||||||
|
self._session_token = session_token
|
||||||
self._region = region
|
self._region = region
|
||||||
self._model = model
|
self._model = model
|
||||||
self._client: Optional[BedrockRuntimeClient] = None
|
self._client: Optional[BedrockRuntimeClient] = None
|
||||||
@@ -523,7 +526,9 @@ class AWSNovaSonicLLMService(LLMService):
|
|||||||
region=self._region,
|
region=self._region,
|
||||||
aws_credentials_identity_resolver=StaticCredentialsResolver(
|
aws_credentials_identity_resolver=StaticCredentialsResolver(
|
||||||
credentials=AWSCredentialsIdentity(
|
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(),
|
http_auth_scheme_resolver=HTTPAuthSchemeResolver(),
|
||||||
|
|||||||
Reference in New Issue
Block a user