修改消息逻辑
This commit is contained in:
@@ -120,6 +120,7 @@ async def call_agent_stream(
|
|||||||
stream_id = generate_req_id("stream")
|
stream_id = generate_req_id("stream")
|
||||||
full_text = ""
|
full_text = ""
|
||||||
has_sent_final = False
|
has_sent_final = False
|
||||||
|
has_sent_thinking = False
|
||||||
|
|
||||||
async for line in response.aiter_lines():
|
async for line in response.aiter_lines():
|
||||||
if not line.startswith("data: "):
|
if not line.startswith("data: "):
|
||||||
@@ -148,12 +149,13 @@ async def call_agent_stream(
|
|||||||
continue
|
continue
|
||||||
full_text += text
|
full_text += text
|
||||||
|
|
||||||
# 实时推送"正在思考"状态
|
# 只发送一次"正在思考"状态
|
||||||
if full_text and not has_sent_final:
|
if full_text and not has_sent_thinking and not has_sent_final:
|
||||||
try:
|
try:
|
||||||
await ws_client.reply_stream(
|
await ws_client.reply_stream(
|
||||||
frame, stream_id, "💭 正在思考...", False
|
frame, stream_id, "💭 正在思考...", False
|
||||||
)
|
)
|
||||||
|
has_sent_thinking = True
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user