修改消息逻辑

This commit is contained in:
2026-04-11 17:31:18 +08:00
parent 7019cf180d
commit 45bf49998c

View File

@@ -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