Skip to content

Commit 15a073e

Browse files
author
Jeel Mehta
committed
Checking result is empty or not
1 parent d0bdb5a commit 15a073e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ 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-
367-
result = response_body["results"][0]
366+
if "results" in response_body:
367+
result = response_body["results"][0]
368368
if "tokenCount" in result:
369369
span.set_attribute(GEN_AI_USAGE_OUTPUT_TOKENS, result["tokenCount"])
370370
if "completionReason" in result:

0 commit comments

Comments
 (0)