diff --git a/claude_sonnet-3-7-bedrock.py b/claude_sonnet-3-7-bedrock.py index aa38517..df481ce 100644 --- a/claude_sonnet-3-7-bedrock.py +++ b/claude_sonnet-3-7-bedrock.py @@ -178,6 +178,9 @@ class Pipeline: streaming_response = self.bedrock_runtime.converse_stream(**payload) thinking_block = None for chunk in streaming_response["stream"]: + if "contentBlockStop" in chunk and chunk["contentBlockStop"]["contentBlockIndex"] == thinking_block: + print("Thinking End") + yield '\n\n' if "contentBlockDelta" in chunk: delta = chunk["contentBlockDelta"]["delta"] @@ -188,10 +191,6 @@ class Pipeline: yield '\n' yield delta["reasoningContent"]["text"] - if "contentBlockStop" in chunk: # and chunk["contentBlockStop"]["contentBlockIndex"] == thinking_block: - print("Thinking End") - yield '\n\n' - # Handle regular response text if "text" in delta: yield delta["text"]