Version: 0.8.6.dev.260401

后端:
新建了chat和execute节点,完善了相关逻辑,代码尚未review
前端:
无
仓库:
无
This commit is contained in:
LoveLosita
2026-04-01 21:35:41 +08:00
parent e1a06be768
commit 2c64b37d00
8 changed files with 817 additions and 50 deletions

View File

@@ -0,0 +1,56 @@
package newagentprompt
import (
"strings"
newagentmodel "github.com/LoveLosita/smartflow/backend/newAgent/model"
"github.com/cloudwego/eino/schema"
)
const chatIntentSystemPrompt = `
你是 SmartFlow 的意图分类器。
你的唯一任务是判断用户本轮输入是"纯闲聊"还是"包含任务意图"。
判断规则:
1. chat打招呼、感谢、简单问答、情感表达、闲聊不涉及任何具体任务或操作请求。
2. task包含任何需要规划/执行/操作的意图,包括但不限于查询信息、创建内容、修改数据、安排日程、继续已有任务等。
保守原则:当不确定时,倾向于判断为 task宁可多走一次规划也不要丢失用户意图。
严格输出以下 JSON不要输出 markdown不要在 JSON 外补文字):
{"intent":"chat或task","reply":"仅当intent=chat时填写你的闲聊回复task时留空","reason":"简短判断依据"}
`
// BuildChatIntentSystemPrompt 返回意图分类系统提示词。
func BuildChatIntentSystemPrompt() string {
return strings.TrimSpace(chatIntentSystemPrompt)
}
// BuildChatIntentMessages 组装意图分类的 messages。
//
// 职责边界:
// 1. 只取最近 6 条历史,保证分类高效;
// 2. 不注入 pinned blocks / tool schemas分类不需要这些信息
// 3. 不负责解析模型输出。
func BuildChatIntentMessages(conversationContext *newagentmodel.ConversationContext, userInput string) []*schema.Message {
messages := make([]*schema.Message, 0, 8)
messages = append(messages, schema.SystemMessage(BuildChatIntentSystemPrompt()))
if conversationContext != nil {
history := conversationContext.HistorySnapshot()
if len(history) > 6 {
history = history[len(history)-6:]
}
if len(history) > 0 {
messages = append(messages, history...)
}
}
trimmedInput := strings.TrimSpace(userInput)
if trimmedInput != "" {
messages = append(messages, schema.UserMessage(trimmedInput))
}
return messages
}