trustgraph-bedrock 1.2.3__tar.gz → 1.2.5__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-bedrock
3
- Version: 1.2.3
3
+ Version: 1.2.5
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
  Author-email: "trustgraph.ai" <security@trustgraph.ai>
6
6
  Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
@@ -0,0 +1 @@
1
+ __version__ = "1.2.5"
@@ -8,10 +8,14 @@ import boto3
8
8
  import json
9
9
  import os
10
10
  import enum
11
+ import logging
11
12
 
12
13
  from .... exceptions import TooManyRequests
13
14
  from .... base import LlmService, LlmResult
14
15
 
16
+ # Module logger
17
+ logger = logging.getLogger(__name__)
18
+
15
19
  default_ident = "text-completion"
16
20
 
17
21
  default_model = 'mistral.mistral-large-2407-v1:0'
@@ -145,7 +149,7 @@ class Processor(LlmService):
145
149
 
146
150
  def __init__(self, **params):
147
151
 
148
- print(params)
152
+ logger.debug(f"Bedrock LLM initialized with params: {params}")
149
153
 
150
154
  model = params.get("model", default_model)
151
155
  temperature = params.get("temperature", default_temperature)
@@ -197,7 +201,7 @@ class Processor(LlmService):
197
201
 
198
202
  self.bedrock = self.session.client(service_name='bedrock-runtime')
199
203
 
200
- print("Initialised", flush=True)
204
+ logger.info("Bedrock LLM service initialized")
201
205
 
202
206
  def determine_variant(self, model):
203
207
 
@@ -250,9 +254,9 @@ class Processor(LlmService):
250
254
  inputtokens = int(metadata['x-amzn-bedrock-input-token-count'])
251
255
  outputtokens = int(metadata['x-amzn-bedrock-output-token-count'])
252
256
 
253
- print(outputtext, flush=True)
254
- print(f"Input Tokens: {inputtokens}", flush=True)
255
- print(f"Output Tokens: {outputtokens}", flush=True)
257
+ logger.debug(f"LLM output: {outputtext}")
258
+ logger.info(f"Input Tokens: {inputtokens}")
259
+ logger.info(f"Output Tokens: {outputtokens}")
256
260
 
257
261
  resp = LlmResult(
258
262
  text = outputtext,
@@ -265,7 +269,7 @@ class Processor(LlmService):
265
269
 
266
270
  except self.bedrock.exceptions.ThrottlingException as e:
267
271
 
268
- print("Hit rate limit:", e, flush=True)
272
+ logger.warning(f"Hit rate limit: {e}")
269
273
 
270
274
  # Leave rate limit retries to the base handler
271
275
  raise TooManyRequests()
@@ -274,8 +278,7 @@ class Processor(LlmService):
274
278
 
275
279
  # Apart from rate limits, treat all exceptions as unrecoverable
276
280
 
277
- print(type(e))
278
- print(f"Exception: {e}")
281
+ logger.error(f"Bedrock LLM exception ({type(e).__name__}): {e}", exc_info=True)
279
282
  raise e
280
283
 
281
284
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-bedrock
3
- Version: 1.2.3
3
+ Version: 1.2.5
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
  Author-email: "trustgraph.ai" <security@trustgraph.ai>
6
6
  Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
@@ -1 +0,0 @@
1
- __version__ = "1.2.3"