Skip to content

Commit fc7c2f1

Browse files
author
Jeel Mehta
committed
Gen-AI Python Implementation
1 parent 15a073e commit fc7c2f1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ def on_success(self, span: Span, result: Dict[str, Any]):
363363
def _handle_amazon_titan_response(self, span: Span, response_body: Dict[str, Any]):
364364
if "inputTextTokenCount" in response_body:
365365
span.set_attribute(GEN_AI_USAGE_INPUT_TOKENS, response_body["inputTextTokenCount"])
366-
if "results" in response_body:
366+
if "results" in response_body and response_body["results"]:
367367
result = response_body["results"][0]
368-
if "tokenCount" in result:
369-
span.set_attribute(GEN_AI_USAGE_OUTPUT_TOKENS, result["tokenCount"])
370-
if "completionReason" in result:
371-
span.set_attribute(GEN_AI_RESPONSE_FINISH_REASONS, [result["completionReason"]])
368+
if "tokenCount" in result:
369+
span.set_attribute(GEN_AI_USAGE_OUTPUT_TOKENS, result["tokenCount"])
370+
if "completionReason" in result:
371+
span.set_attribute(GEN_AI_RESPONSE_FINISH_REASONS, [result["completionReason"]])
372372

373373
# pylint: disable=no-self-use
374374
def _handle_anthropic_claude_response(self, span: Span, response_body: Dict[str, Any]):

0 commit comments

Comments
 (0)