trustgraph-bedrock 0.20.6__tar.gz → 0.20.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-bedrock
3
- Version: 0.20.6
3
+ Version: 0.20.8
4
4
  Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
5
5
  Home-page: https://github.com/trustgraph-ai/trustgraph
6
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.20.6.tar.gz
6
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.20.8.tar.gz
7
7
  Author: trustgraph.ai
8
8
  Author-email: security@trustgraph.ai
9
9
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1 @@
1
+ __version__ = "0.20.8"
@@ -24,32 +24,48 @@ default_subscriber = module
24
24
  default_model = 'mistral.mistral-large-2407-v1:0'
25
25
  default_temperature = 0.0
26
26
  default_max_output = 2048
27
- default_aws_id_key = os.getenv("AWS_ID_KEY", None)
28
- default_aws_secret = os.getenv("AWS_SECRET", None)
29
- default_aws_region = os.getenv("AWS_REGION", 'us-west-2')
27
+
28
+ # Actually, these could all just be None, no need to get environment
29
+ # variables, as Boto3 would pick all these up if not passed in as args
30
+ default_access_key_id = os.getenv("AWS_ACCESS_KEY_ID", None)
31
+ default_secret_access_key = os.getenv("AWS_SECRET_ACCESS_KEY", None)
32
+ default_session_token = os.getenv("AWS_SESSION_TOKEN", None)
33
+ default_profile = os.getenv("AWS_PROFILE", None)
34
+ default_region = os.getenv("AWS_DEFAULT_REGION", None)
30
35
 
31
36
  class Processor(ConsumerProducer):
32
37
 
33
38
  def __init__(self, **params):
39
+
40
+ print(params)
34
41
 
35
42
  input_queue = params.get("input_queue", default_input_queue)
36
43
  output_queue = params.get("output_queue", default_output_queue)
37
44
  subscriber = params.get("subscriber", default_subscriber)
45
+
38
46
  model = params.get("model", default_model)
39
- aws_id_key = params.get("aws_id_key", default_aws_id_key)
40
- aws_secret = params.get("aws_secret", default_aws_secret)
41
- aws_region = params.get("aws_region", default_aws_region)
42
47
  temperature = params.get("temperature", default_temperature)
43
48
  max_output = params.get("max_output", default_max_output)
44
49
 
45
- if aws_id_key is None:
46
- raise RuntimeError("AWS ID not specified")
50
+ aws_access_key_id = params.get(
51
+ "aws_access_key_id", default_access_key_id
52
+ )
53
+
54
+ aws_secret_access_key = params.get(
55
+ "aws_secret_access_key", default_secret_access_key
56
+ )
47
57
 
48
- if aws_secret is None:
49
- raise RuntimeError("AWS secret not specified")
58
+ aws_session_token = params.get(
59
+ "aws_session_token", default_session_token
60
+ )
50
61
 
51
- if aws_region is None:
52
- raise RuntimeError("AWS region not specified")
62
+ aws_region = params.get(
63
+ "aws_region", default_region
64
+ )
65
+
66
+ aws_profile = params.get(
67
+ "aws_profile", default_profile
68
+ )
53
69
 
54
70
  super(Processor, self).__init__(
55
71
  **params | {
@@ -82,9 +98,11 @@ class Processor(ConsumerProducer):
82
98
  self.max_output = max_output
83
99
 
84
100
  self.session = boto3.Session(
85
- aws_access_key_id=aws_id_key,
86
- aws_secret_access_key=aws_secret,
87
- region_name=aws_region
101
+ aws_access_key_id=aws_access_key_id,
102
+ aws_secret_access_key=aws_secret_access_key,
103
+ aws_session_token=aws_session_token,
104
+ profile_name=aws_profile,
105
+ region_name=aws_region,
88
106
  )
89
107
 
90
108
  self.bedrock = self.session.client(service_name='bedrock-runtime')
@@ -179,9 +197,6 @@ class Processor(ConsumerProducer):
179
197
  accept = 'application/json'
180
198
  contentType = 'application/json'
181
199
 
182
- # FIXME: Consider catching request limits and raise TooManyRequests
183
- # See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/retries.html
184
-
185
200
  with __class__.text_completion_metric.time():
186
201
  response = self.bedrock.invoke_model(
187
202
  body=promptbody, modelId=self.model, accept=accept,
@@ -243,10 +258,7 @@ class Processor(ConsumerProducer):
243
258
 
244
259
  print("Done.", flush=True)
245
260
 
246
-
247
- # FIXME: Wrong exception, don't know what Bedrock throws
248
- # for a rate limit
249
- except TooManyRequests:
261
+ except self.bedrock.exceptions.ThrottlingException:
250
262
 
251
263
  print("Send rate limit response...", flush=True)
252
264
 
@@ -300,21 +312,27 @@ class Processor(ConsumerProducer):
300
312
  )
301
313
 
302
314
  parser.add_argument(
303
- '-z', '--aws-id-key',
304
- default=default_aws_id_key,
305
- help=f'AWS ID Key'
315
+ '-z', '--aws-access-key-id',
316
+ default=default_access_key_id,
317
+ help=f'AWS access key ID'
306
318
  )
307
319
 
308
320
  parser.add_argument(
309
- '-k', '--aws-secret',
310
- default=default_aws_secret,
311
- help=f'AWS Secret Key'
321
+ '-k', '--aws-secret-access-key',
322
+ default=default_secret_access_key,
323
+ help=f'AWS secret access key'
312
324
  )
313
325
 
314
326
  parser.add_argument(
315
327
  '-r', '--aws-region',
316
- default=default_aws_region,
317
- help=f'AWS Region'
328
+ default=default_region,
329
+ help=f'AWS region'
330
+ )
331
+
332
+ parser.add_argument(
333
+ '--aws-profile', '--profile',
334
+ default=default_profile,
335
+ help=f'AWS profile name'
318
336
  )
319
337
 
320
338
  parser.add_argument(
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-bedrock
3
- Version: 0.20.6
3
+ Version: 0.20.8
4
4
  Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
5
5
  Home-page: https://github.com/trustgraph-ai/trustgraph
6
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.20.6.tar.gz
6
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.20.8.tar.gz
7
7
  Author: trustgraph.ai
8
8
  Author-email: security@trustgraph.ai
9
9
  Classifier: Programming Language :: Python :: 3
@@ -1 +0,0 @@
1
- __version__ = "0.20.6"