testing thinking
This commit is contained in:
parent
36b1d49c62
commit
99a49cdec0
@ -177,15 +177,22 @@ 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)
|
||||
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<thinking>"
|
||||
yield delta["reasoningContent"]["text"]
|
||||
|
||||
# Handle regular response text
|
||||
if "text" in delta:
|
||||
if think_start:
|
||||
yield "\n</thinking>\n"
|
||||
think_start = False
|
||||
yield delta["text"]
|
||||
|
||||
def get_completion(self, model_id: str, payload: dict) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user