Files
smartmate/backend/newAgent/prompt/quick_task.go
LoveLosita 8daae62812 Version: 0.9.41.dev.260424
后端:
1. 随口记从 Execute 工具链路迁移到独立 QuickTask 轻量节点——单轮流式提取意图直接调 service,绕过 ReAct 循环
- 新增 QuickTask graph 节点 + Chat→QuickTask→END 分支
- Chat 路由提示词新增 quick_task 路由判别规则,execute 路由收窄为日程类
- Execute 提示词(有 plan / ReAct 两套)移除 quick_note_create / query_tasks 指令
- ToolRegistry 注销 quick_note_create / query_tasks,移除相关依赖与注册
- 依赖注入从 ToolRegistry 改为 Service 层直接注入 QuickTaskDeps

2. urgency_threshold_at 代码兜底 + API 返回补全
- priorityGroup=2 且有 deadline 但 LLM 未填时,自动设为 deadline-24h
- 任务查询接口返回结构补充 UrgencyThresholdAt 字段与转换映射

3. 记忆召回条数 5→10
2026-04-24 14:02:27 +08:00

103 lines
4.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package newagentprompt
import (
"fmt"
"strings"
"time"
newagentmodel "github.com/LoveLosita/smartflow/backend/newAgent/model"
"github.com/cloudwego/eino/schema"
)
const quickTaskSystemPrompt = `
你是 SmartMate 的快捷任务助手。用户想记录或查看待办任务。你需要从用户消息中提取操作意图和参数。
你能做的操作:
- create记录一条新任务/提醒
- query查看/筛选任务列表
输出格式(两阶段):
先输出一行决策标签,标签内是 JSON标签之后换行输出给用户看的自然语言正文。
决策标签格式:<SMARTFLOW_DECISION>{JSON}</SMARTFLOW_DECISION>
JSON 字段说明:
- action只能是 create / query / ask
- create 时title 必填deadline_at 必填priority_group 必填,范围 1-4urgency_threshold_at 满足条件时填写,条件在下面
- query 时quadrant 可选 1-4keyword 可选limit 可选
- ask 时question 必填
规则:
1. 优先级1=重要且紧急2=重要不紧急3=简单不重要4=复杂不重要;紧急判定:截止时间距今不超过 48 小时为紧急(1),超过 48 小时为不紧急(2),无截止时间默认 3
2. 信息不足时(如缺少 title输出 {"action":"ask","question":"追问内容"}
3. deadline_at 支持「明天下午3点」「下周一」「2026-04-20 18:00」等格式
4. 未提供的可选字段直接省略,不要填 null 或空字符串
5. JSON 中不要包含 speak 字段,给用户看的话放在 </SMARTFLOW_DECISION> 标签之后
6. 紧急分界时间,即任务从"重要不紧急"自动轮换到"重要且紧急"的时间点;格式同 deadline_at ——当 priority_group=2 时必填,你必须根据 deadline 自动推算一个合理的紧急分界时间(通常为 deadline 前 24-48 小时不要等用户提供priority_group 为 1、3、4 或无截止时间时不要输出此字段
示例:
<SMARTFLOW_DECISION>{"action":"create","title":"明天开会","deadline_at":"明天下午3点"}</SMARTFLOW_DECISION>
好的,我来帮你记一下。
<SMARTFLOW_DECISION>{"action":"create","title":"下周交报告","deadline_at":"下周五 18:00","priority_group":2,"urgency_threshold_at":"下周四 09:00"}</SMARTFLOW_DECISION>
好的,我也帮你记一下。
<SMARTFLOW_DECISION>{"action":"query","limit":5}</SMARTFLOW_DECISION>
我帮你查一下当前的任务。
<SMARTFLOW_DECISION>{"action":"ask","question":"你想记录什么呢?告诉我具体内容吧。"}</SMARTFLOW_DECISION>
你想记录什么呢?告诉我具体内容吧。`
// BuildQuickTaskSystemPrompt 返回快捷任务阶段的系统提示词。
func BuildQuickTaskSystemPrompt() string {
return strings.TrimSpace(quickTaskSystemPrompt)
}
// BuildQuickTaskMessagesSimple 组装快捷任务阶段的最简 messages无对话历史
func BuildQuickTaskMessagesSimple(userInput string) []*schema.Message {
systemMsg := schema.SystemMessage(BuildQuickTaskSystemPrompt())
userMsg := schema.UserMessage(buildQuickTaskUserPrompt(userInput))
return []*schema.Message{systemMsg, userMsg}
}
func buildQuickTaskUserPrompt(userInput string) string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("当前时间=%s\n", time.Now().In(time.Local).Format("2006-01-02 15:04")))
sb.WriteString("\n请从用户消息中提取操作意图和参数严格按 SMARTFLOW_DECISION 标签格式输出。\n\n")
trimmedInput := strings.TrimSpace(userInput)
if trimmedInput != "" {
sb.WriteString("用户输入:\n")
sb.WriteString(trimmedInput)
sb.WriteString("\n")
}
return sb.String()
}
// BuildQuickTaskMessages 组装快捷任务阶段的完整 messages含对话历史
func BuildQuickTaskMessages(
ctx *newagentmodel.ConversationContext,
userInput string,
toolSchemas []newagentmodel.ToolSchemaContext,
) []*schema.Message {
return buildUnifiedStageMessages(
ctx,
StageMessagesConfig{
SystemPrompt: BuildQuickTaskSystemPrompt(),
Msg1Content: buildChatConversationMessage(ctx),
Msg2Content: buildQuickTaskWorkspace(toolSchemas),
Msg3Suffix: buildQuickTaskUserPrompt(userInput),
Msg3Role: schema.User,
},
)
}
func buildQuickTaskWorkspace(toolSchemas []newagentmodel.ToolSchemaContext) string {
var sb strings.Builder
sb.WriteString("可用工具:\n")
for _, ts := range toolSchemas {
sb.WriteString(fmt.Sprintf("- %s: %s\n 参数: %s\n", ts.Name, ts.Desc, ts.SchemaText))
}
return sb.String()
}