This commit is contained in:
@@ -189,6 +189,20 @@ class AIAgentService:
|
|||||||
}
|
}
|
||||||
# 处理普通 token
|
# 处理普通 token
|
||||||
elif token_content:
|
elif token_content:
|
||||||
|
# 如果内容较长,拆成单个字符模拟流式效果
|
||||||
|
if len(token_content) > 1:
|
||||||
|
import asyncio
|
||||||
|
for char in token_content:
|
||||||
|
yield {
|
||||||
|
"type": "llm_token",
|
||||||
|
"node": node_name,
|
||||||
|
"token": char,
|
||||||
|
"reasoning_token": reasoning_token
|
||||||
|
}
|
||||||
|
# 短暂暂停,模拟打字效果
|
||||||
|
await asyncio.sleep(0.01)
|
||||||
|
else:
|
||||||
|
# 内容较短,直接发送
|
||||||
yield {
|
yield {
|
||||||
"type": "llm_token",
|
"type": "llm_token",
|
||||||
"node": node_name,
|
"node": node_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user