update pay function
This commit is contained in:
@@ -2361,6 +2361,36 @@ MEETING_MODEL_CONFIGS = {
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def clean_deepseek_tool_markers(content: str) -> str:
|
||||
"""
|
||||
清理 DeepSeek 模型输出中的工具调用标记
|
||||
DeepSeek 有时会以文本形式输出工具调用,格式如:
|
||||
<|tool▁calls▁begin|><|tool▁call▁begin|>tool_name<|tool▁sep|>{"args": "value"}<|tool▁call▁end|><|tool▁calls▁end|>
|
||||
"""
|
||||
import re
|
||||
if not content:
|
||||
return content
|
||||
|
||||
# 清理 DeepSeek 工具调用标记
|
||||
# 匹配 <|tool▁calls▁begin|> ... <|tool▁calls▁end|> 整个块
|
||||
pattern = r'<|tool▁calls▁begin|>.*?<|tool▁calls▁end|>'
|
||||
cleaned = re.sub(pattern, '', content, flags=re.DOTALL)
|
||||
|
||||
# 也清理可能残留的单个标记
|
||||
markers = [
|
||||
'<|tool▁calls▁begin|>',
|
||||
'<|tool▁calls▁end|>',
|
||||
'<|tool▁call▁begin|>',
|
||||
'<|tool▁call▁end|>',
|
||||
'<|tool▁sep|>',
|
||||
]
|
||||
for marker in markers:
|
||||
cleaned = cleaned.replace(marker, '')
|
||||
|
||||
return cleaned.strip()
|
||||
|
||||
|
||||
# 每个角色可用的工具列表
|
||||
ROLE_TOOLS = {
|
||||
"buffett": ["search_china_news", "search_research_reports", "get_stock_basic_info", "get_stock_financial_index"],
|
||||
@@ -2663,6 +2693,9 @@ async def stream_role_response(
|
||||
"content": content
|
||||
}
|
||||
|
||||
# 清理 DeepSeek 工具调用标记
|
||||
full_content = clean_deepseek_tool_markers(full_content)
|
||||
|
||||
# 发送完成事件
|
||||
yield {
|
||||
"type": "content_done",
|
||||
|
||||
Reference in New Issue
Block a user