Skip to content

Commit df1045f

Browse files
author
Jeel Mehta
committed
Gen-AI python implementation
1 parent 08fb76f commit df1045f

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_bedrock_patches.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,11 @@ def extract_attributes(self, attributes: _AttributeMapT):
251251
attributes[GEN_AI_SYSTEM] = _AWS_BEDROCK_SYSTEM
252252

253253
model_id = self._call_context.params.get(_MODEL_ID)
254-
# attributes["Testing"]= "Test"
255254
if model_id:
256255
attributes[GEN_AI_REQUEST_MODEL] = model_id
257256

258257
# Get the request body if it exists
259258
body = self._call_context.params.get("body")
260-
# print("This is the body :",body)
261259
if body:
262260
try:
263261
request_body = json.loads(body)
@@ -308,7 +306,6 @@ def _extract_llama_attributes(self, attributes, request_body):
308306
self._set_if_not_none(attributes, GEN_AI_REQUEST_TOP_P, request_body.get("top_p"))
309307

310308
def _extract_mistral_attributes(self, attributes, request_body):
311-
print("This is the request body:", request_body)
312309
prompt = request_body.get("prompt")
313310
if prompt:
314311
attributes[GEN_AI_USAGE_INPUT_TOKENS] = math.ceil(len(prompt) / 6)
@@ -322,8 +319,6 @@ def _set_if_not_none(attributes, key, value):
322319
attributes[key] = value
323320

324321
def on_success(self, span: Span, result: Dict[str, Any]):
325-
super().on_success(span, result)
326-
327322
model_id = self._call_context.params.get(_MODEL_ID)
328323
if not model_id:
329324
return
@@ -404,7 +399,6 @@ def _handle_meta_llama_response(self, span: Span, response_body: Dict[str, Any])
404399
span.set_attribute(GEN_AI_RESPONSE_FINISH_REASONS, [response_body["stop_reason"]])
405400

406401
def _handle_mistral_mistral_response(self, span: Span, response_body: Dict[str, Any]):
407-
print("This is the response body :", response_body)
408402
if "outputs" in response_body:
409403
outputs = response_body["outputs"][0]
410404
if "text" in outputs:

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def _test_patched_botocore_instrumentation(self):
309309
bedrock_runtime_attributes["gen_ai.usage.input_tokens"], math.ceil(len(request_body["message"]) / 6)
310310
)
311311
response_body = {
312-
"text": 'Goodbye, world',
312+
"text": "Goodbye, world",
313313
"finish_reason": "COMPLETE",
314314
}
315315
json_bytes = json.dumps(response_body).encode("utf-8")
@@ -412,7 +412,7 @@ def _test_patched_botocore_instrumentation(self):
412412
bedrock_runtime_success_attributes: Dict[str, str] = _do_on_success_bedrock(
413413
"bedrock-runtime", model_id="mistral", streaming_body=streaming_body
414414
)
415-
415+
416416
self.assertEqual(
417417
bedrock_runtime_success_attributes["gen_ai.usage.output_tokens"],
418418
math.ceil(len(response_body["outputs"][0]["text"]) / 6),

0 commit comments

Comments
 (0)