From a5c9244f1e20b9da6b60fe6c30a02292211d88a0 Mon Sep 17 00:00:00 2001 From: jknapp Date: Sun, 16 Mar 2025 20:58:40 -0700 Subject: [PATCH] testing thinking --- claude_sonnet-3-7-bedrock.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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: