Files
smartmate/backend/newAgent/prompt/chat.go
Losita b1eb6bedf9 Version: 0.9.1.dev.260406
后端:
  1.新建conv/schedule_persist.go:ScheduleState Diff 持久化,事务内逐变更写库,支持 place/move/unplace 三种操作(当前
  event source)
  2.新建conv/schedule_provider.go:ScheduleState 加载适配,从 DB 合并 existing events + pending task items
  3.新建dao/agent_state_store_adapter.go:Redis 状态快照存取适配,实现 AgentStateStore 接口
  4.新建service/agentsvc/agent_newagent.go:newAgent service 集成层,串联 LLM
  客户端、ScheduleProvider、SchedulePersistor 和 ChunkEmitter
  5.更新node/execute.go:接入 SchedulePersistor(写操作确认后持久化)、完善 confirm resume 路径(PendingConfirmTool
  恢复分支)、correction 机制增加连续失败计数上限
  6.更新api/agent.go + cmd/start.go:接入 newAgent service,完成 API 层路由注册
  7.新建node/execute_confirm_flow_test.go + llm_tool_orchestration_test.go:确认回路 7 个测试 + 端到端排课 5
  个测试全部通过
  8.新建newAgent/ARCHITECTURE.md + ROADMAP.md:全链路架构文档和缺口分析
  9.代码审查整理:提取 prompt/base.go(通用 buildStageMessages 等5个辅助)、tools/args.go(参数解析辅助);write_tools
  尾部辅助移入 write_helpers;修复 queryRangeSpecific sb.Reset() 逻辑缺陷和 Unplace guest Duration
  未恢复;ScheduleStateProvider/SchedulePersistor 归入 state_store.go;emitter 内部 Build*Text 函数降级为私有
前端:无
仓库:无
2026-04-06 15:33:34 +08:00

64 lines
2.2 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 (
"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...)
}
}
// 只在 history 末尾还没有当前用户消息时才追加,
// 避免与 loadConversationContext 的预追加产生重复。
trimmedInput := strings.TrimSpace(userInput)
if trimmedInput != "" {
alreadyLast := len(messages) > 0 &&
messages[len(messages)-1].Role == schema.User &&
messages[len(messages)-1].Content == trimmedInput
if !alreadyLast {
messages = append(messages, schema.UserMessage(trimmedInput))
}
}
return messages
}