修改消息逻辑
This commit is contained in:
@@ -120,6 +120,7 @@ async def call_agent_stream(
|
||||
stream_id = generate_req_id("stream")
|
||||
full_text = ""
|
||||
has_sent_final = False
|
||||
has_sent_thinking = False
|
||||
|
||||
async for line in response.aiter_lines():
|
||||
if not line.startswith("data: "):
|
||||
@@ -148,12 +149,13 @@ async def call_agent_stream(
|
||||
continue
|
||||
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:
|
||||
await ws_client.reply_stream(
|
||||
frame, stream_id, "💭 正在思考...", False
|
||||
)
|
||||
has_sent_thinking = True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user