fix(aws): fix BedrockRuntimeClient/Config import errors in realtime p… - #7003
fix(aws): fix BedrockRuntimeClient/Config import errors in realtime p…#7003Vinayakdwivedi wants to merge 1 commit into
Conversation
|
|
| @utils.log_exceptions(logger=logger) | ||
| def _initialize_client(self) -> None: | ||
| """Instantiate the Bedrock runtime client""" | ||
| """Instantiate the Bedrock runtime client" "" |
There was a problem hiding this comment.
🔴 Malformed docstring breaks module import
The edited docstring """Instantiate the Bedrock runtime client" "" opens a triple-quoted string that is never closed, so Python swallows the following code and raises a SyntaxError. The whole module fails to import.
| """Instantiate the Bedrock runtime client" "" | |
| """Instantiate the Bedrock runtime client""" |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Pull request overview
This PR updates the AWS Bedrock realtime integration to use the async-native aws_sdk_bedrock_runtime client/config types, addressing import compatibility issues across SDK versions when importing RealtimeModel.
Changes:
- Replace
BedrockRuntimeClientwithAsyncBedrockRuntimeClient. - Replace
Configimport withAsyncBedrockRuntimeConfig(aliased asConfig) and keep auth scheme wiring.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @utils.log_exceptions(logger=logger) | ||
| def _initialize_client(self) -> None: | ||
| """Instantiate the Bedrock runtime client""" | ||
| """Instantiate the Bedrock runtime client" "" |
| InvokeModelWithBidirectionalStreamOperationInput, | ||
| ) | ||
| from aws_sdk_bedrock_runtime.config import Config, HTTPAuthSchemeResolver, SigV4AuthScheme | ||
| from aws_sdk_bedrock_runtime.config import AsyncBedrockRuntimeConfig as Config, HTTPAuthSchemeResolver, SigV4AuthScheme |
|
duplicates #7002 |
What is changed
Fixes
ImportErrorwhen importingRealtimeModelfromlivekit-plugins-aws[realtime], which occurs with every version ofaws-sdk-bedrock-runtimeallowed by the plugin's own dependency spec(
>=0.2.0).Root cause
realtime_model.pyimportsBedrockRuntimeClientandConfigdirectly:Neither of these import cleanly depending on the installed SDK version:
aws-sdk-bedrock-runtime==0.11.0ImportError: cannot import name 'BedrockRuntimeClient' from 'aws_sdk_bedrock_runtime.client'— onlyAsyncBedrockRuntimeClientexistsaws-sdk-bedrock-runtime==0.10.0ImportError: cannot import name 'Config' from 'aws_sdk_bedrock_runtime.config'— onlyAsyncBedrockRuntimeConfigexistsSo there is no version in the supported range that lets the plugin import successfully.
Fix
Switched all usages to the async-native SDK classes:
Also audited and updated all downstream usage of
self._bedrock_client(stream open/read/write) to properly
awaitcalls and useasync with/
async forwhere the SDK returns async streaming objects, sinceAsyncBedrockRuntimeClienthas no synchronous API surface.Pinned
aws-sdk-bedrock-runtimeto>=<tested-version>,<next-major>inpyproject.tomlso the plugin doesn't silently drift out ofcompatibility again if the SDK changes its export surface in the future.
Testing
Import check (reproduces the original issue):
ImportError(as described above, on both 0.10.0 and 0.11.0)Functional check:
invoke_model_with_bidirectional_streamopens correctly andinput/output streaming works end-to-end against
<the version you tested>.Environment tested:
aws-sdk-bedrock-runtime==<version>livekit-agents==1.7.0Related
Fixes #6994
Related to #3244 (different root cause — Python version issue, already resolved, not affected by this change)