diff --git a/claude_sonnet-3-7-bedrock.py b/claude_sonnet-3-7-bedrock.py index 0b86d29..d1761a8 100644 --- a/claude_sonnet-3-7-bedrock.py +++ b/claude_sonnet-3-7-bedrock.py @@ -177,20 +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_block = '' + thinking_block = None for chunk in streaming_response["stream"]: - print(chunk) 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_block: + if thinking_block is None: thinking_block = chunk["contentBlockDelta"]["contentBlockIndex"] - yield '\n' - print(f"Reasoning content: {thinking_block}") - if "contentBlockIndex" in delta: - print(delta["contentBlockIndex"]) + yield '\n' yield delta["reasoningContent"]["text"] if "contentBlockStop" in delta and delta["contentBlockStop"]["contentBlockIndex"] == thinking_block: