fix: 工具名过滤、消息拆分提示词优化
- filterActions: 过滤DeepSeek直接输出工具名(如vision_analyze)的怪话 - 系统提示词: 明确告知用双换行(空行)拆分多条消息 - 群聊规则: 加入独立想法用双换行分隔的说明
This commit is contained in:
@@ -960,7 +960,27 @@ func filterActions(text string) string {
|
||||
}
|
||||
}
|
||||
|
||||
return strings.TrimSpace(text)
|
||||
// 过滤 LLM 直接输出工具名的情况(DeepSeek 有时不调用函数而是直接输出函数名)
|
||||
text = strings.TrimSpace(text)
|
||||
toolNames := []string{"vision_analyze", "video_analyze", "web_search", "web_fetch",
|
||||
"iot_control", "iot_query", "host_exec", "os_exec", "knowledge_search"}
|
||||
for _, name := range toolNames {
|
||||
if text == name || strings.HasPrefix(text, name+"\n") || strings.HasPrefix(text, name+":") || strings.HasPrefix(text, name+":") {
|
||||
text = strings.TrimPrefix(text, name)
|
||||
text = strings.TrimSpace(text)
|
||||
if text == "" {
|
||||
return "" // 纯工具名,完全去掉
|
||||
}
|
||||
}
|
||||
}
|
||||
// 也处理 "vision_analyze\n..." 这种内嵌在第一行的情况
|
||||
for _, name := range toolNames {
|
||||
if strings.HasPrefix(text, name+" ") {
|
||||
text = strings.TrimSpace(text[len(name):])
|
||||
}
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
// buildMemoryNamespace creates a memory-isolated user_id for a platform channel.
|
||||
|
||||
Reference in New Issue
Block a user