fix:The handling of the streaming tool calls has been fixed, but there are still bugs in the model's reply messages with thoughtfulness.

This commit is contained in:
Dong_master
2025-08-10 23:14:57 +08:00
parent 03b11481ed
commit 46452de7b5
10 changed files with 112 additions and 98 deletions

View File

@@ -13,6 +13,7 @@ class WebChatDebugRouterGroup(group.RouterGroup):
"""Send a message to the pipeline for debugging"""
async def stream_generator(generator):
yield 'data: {"type": "start"}\n\n'
async for message in generator:
yield f'data: {json.dumps({"message": message})}\n\n'
yield 'data: {"type": "end"}\n\n'
@@ -38,8 +39,14 @@ class WebChatDebugRouterGroup(group.RouterGroup):
generator = webchat_adapter.send_webchat_message(
pipeline_uuid, session_type, message_chain_obj, is_stream
)
return quart.Response(stream_generator(generator), mimetype='text/event-stream')
# 设置正确的响应头
headers = {
'Content-Type': 'text/event-stream',
'Transfer-Encoding': 'chunked',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive'
}
return quart.Response(stream_generator(generator), mimetype='text/event-stream',headers=headers)
else:
# result = await webchat_adapter.send_webchat_message(pipeline_uuid, session_type, message_chain_obj)