Skip to content

Commit 182fd38

Browse files
author
Jack Yuan
committed
change logger info to warning, optimize if condition
1 parent 2b81b1c commit 182fd38

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/strands/models/bedrock.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -453,17 +453,17 @@ def _stream(
453453
has_tool_use = True
454454

455455
# Fix stopReason for streaming responses that contain tool use
456-
if "messageStop" in chunk and has_tool_use:
457-
message_stop = chunk["messageStop"]
458-
if message_stop.get("stopReason") == "end_turn":
459-
# Create corrected chunk with tool_use stopReason
460-
modified_chunk = chunk.copy()
461-
modified_chunk["messageStop"] = message_stop.copy()
462-
modified_chunk["messageStop"]["stopReason"] = "tool_use"
463-
logger.info("Override stop reason from end_turn to tool_use")
464-
callback(modified_chunk)
465-
else:
466-
callback(chunk)
456+
if (
457+
has_tool_use
458+
and "messageStop" in chunk
459+
and (message_stop := chunk["messageStop"]).get("stopReason") == "end_turn"
460+
):
461+
# Create corrected chunk with tool_use stopReason
462+
modified_chunk = chunk.copy()
463+
modified_chunk["messageStop"] = message_stop.copy()
464+
modified_chunk["messageStop"]["stopReason"] = "tool_use"
465+
logger.warning("Override stop reason from end_turn to tool_use")
466+
callback(modified_chunk)
467467
else:
468468
callback(chunk)
469469

@@ -607,7 +607,7 @@ def _convert_non_streaming_to_streaming(self, response: dict[str, Any]) -> Itera
607607
message_content = response["output"]["message"]["content"]
608608
if any("toolUse" in content for content in message_content):
609609
current_stop_reason = "tool_use"
610-
logger.info("Override stop reason from end_turn to tool_use")
610+
logger.warning("Override stop reason from end_turn to tool_use")
611611

612612
yield {
613613
"messageStop": {

0 commit comments

Comments
 (0)