From a33a73003eadbf0797e394b1f287a64bb78808e5 Mon Sep 17 00:00:00 2001 From: jknapp Date: Sun, 16 Mar 2025 19:26:06 -0700 Subject: [PATCH] testing thinking --- claude_sonnet-3-7-bedrock.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/claude_sonnet-3-7-bedrock.py b/claude_sonnet-3-7-bedrock.py index a5e1103..b00b317 100644 --- a/claude_sonnet-3-7-bedrock.py +++ b/claude_sonnet-3-7-bedrock.py @@ -176,23 +176,18 @@ class Pipeline: def stream_response(self, model_id: str, payload: dict) -> Generator: # 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}") for chunk in streaming_response["stream"]: - think_start = False 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 think_start: - think_start = True - yield "\n" + # if '"
' in delta["reasoningContent"]["text"]: yield delta["reasoningContent"]["text"] # Handle regular response text if "text" in delta: - if think_start: - yield "\n\n" - think_start = False yield delta["text"] def get_completion(self, model_id: str, payload: dict) -> str: