MCPcopy Create free account
hub / github.com/AsyncFuncAI/deepwiki-open / init_sync_client

Method init_sync_client

api/bedrock_client.py:113–152  ·  view source on GitHub ↗

Initialize the synchronous AWS Bedrock client.

(self)

Source from the content-addressed store, hash-verified

111 self.async_client = None # It will be lazily initialized when acall is used
112
113 def init_sync_client(self):
114 """Initialize the synchronous AWS Bedrock client."""
115 try:
116 # Create a session with the provided credentials
117 session = boto3.Session(
118 aws_access_key_id=self.aws_access_key_id,
119 aws_secret_access_key=self.aws_secret_access_key,
120 aws_session_token=self.aws_session_token,
121 region_name=self.aws_region
122 )
123
124 # If a role ARN is provided, assume that role
125 if self.aws_role_arn:
126 sts_client = session.client('sts')
127 assumed_role = sts_client.assume_role(
128 RoleArn=self.aws_role_arn,
129 RoleSessionName="DeepWikiBedrockSession"
130 )
131 credentials = assumed_role['Credentials']
132
133 # Create a new session with the assumed role credentials
134 session = boto3.Session(
135 aws_access_key_id=credentials['AccessKeyId'],
136 aws_secret_access_key=credentials['SecretAccessKey'],
137 aws_session_token=credentials['SessionToken'],
138 region_name=self.aws_region
139 )
140
141 # Create the Bedrock client
142 bedrock_runtime = session.client(
143 service_name='bedrock-runtime',
144 region_name=self.aws_region
145 )
146
147 return bedrock_runtime
148
149 except Exception as e:
150 log.error(f"Error initializing AWS Bedrock client: {str(e)}")
151 # Return None to indicate initialization failure
152 return None
153
154 def init_async_client(self):
155 """Initialize the asynchronous AWS Bedrock client.

Callers 2

__init__Method · 0.95
__setstate__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected