testing thinking
This commit is contained in:
parent
ba5fbffbe2
commit
8692d2f2e4
@ -177,12 +177,16 @@ class Pipeline:
|
|||||||
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse_stream.html
|
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse_stream.html
|
||||||
streaming_response = self.bedrock_runtime.converse_stream(**payload)
|
streaming_response = self.bedrock_runtime.converse_stream(**payload)
|
||||||
print(f"{streaming_response} for {payload}")
|
print(f"{streaming_response} for {payload}")
|
||||||
|
thinking_start = False
|
||||||
for chunk in streaming_response["stream"]:
|
for chunk in streaming_response["stream"]:
|
||||||
if "contentBlockDelta" in chunk:
|
if "contentBlockDelta" in chunk:
|
||||||
delta = chunk["contentBlockDelta"]["delta"]
|
delta = chunk["contentBlockDelta"]["delta"]
|
||||||
|
|
||||||
# Handle reasoning content (Chain of Thought)
|
# Handle reasoning content (Chain of Thought)
|
||||||
if "reasoningContent" in delta and "text" in delta["reasoningContent"]:
|
if "reasoningContent" in delta and "text" in delta["reasoningContent"]:
|
||||||
|
if not thinking_start:
|
||||||
|
thinking_start = True
|
||||||
|
yield "\n<Thinking>\n\n"
|
||||||
print(f"Reasoning content: {delta['reasoningContent']}")
|
print(f"Reasoning content: {delta['reasoningContent']}")
|
||||||
yield delta["reasoningContent"]["text"]
|
yield delta["reasoningContent"]["text"]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user