diff --git a/claude_sonnet-3-7-bedrock.py b/claude_sonnet-3-7-bedrock.py index 4d44bdb..ca37149 100644 --- a/claude_sonnet-3-7-bedrock.py +++ b/claude_sonnet-3-7-bedrock.py @@ -177,12 +177,16 @@ class Pipeline: # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse_stream.html streaming_response = self.bedrock_runtime.converse_stream(**payload) print(f"{streaming_response} for {payload}") + thinking_start = False for chunk in streaming_response["stream"]: if "contentBlockDelta" in chunk: delta = chunk["contentBlockDelta"]["delta"] # Handle reasoning content (Chain of Thought) if "reasoningContent" in delta and "text" in delta["reasoningContent"]: + if not thinking_start: + thinking_start = True + yield "\n\n\n" print(f"Reasoning content: {delta['reasoningContent']}") yield delta["reasoningContent"]["text"]