Version: 0.8.3.dev.260328
后端: 1.彻底删除原agent文件夹,并将现agent2文件夹全量重命名为agent(包括全部涉及到的文件以及文档、注释),迁移工作完美结束 2.修复了重试消息的相关逻辑问题 前端: 1.改善了一些交互体验,修复了一些bug,现在只剩少的功能了,现存的bug基本都修复完毕 全仓库: 1.更新了决策记录和README文档
This commit is contained in:
50
backend/agent/llm/route.go
Normal file
50
backend/agent/llm/route.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package agentllm
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
agentmodel "github.com/LoveLosita/smartflow/backend/agent/model"
|
||||
)
|
||||
|
||||
// RouteDecisionOutput 是一级路由模型的结构化输出契约。
|
||||
//
|
||||
// 说明:
|
||||
// 1. 这里只定义“模型应该吐什么 JSON”;
|
||||
// 2. 真正的 prompt 归 prompt/ 管;
|
||||
// 3. 真正的业务分发归 router/ 管。
|
||||
type RouteDecisionOutput struct {
|
||||
Action string `json:"action"`
|
||||
TrustRoute bool `json:"trust_route"`
|
||||
Detail string `json:"detail"`
|
||||
Confidence float64 `json:"confidence"`
|
||||
}
|
||||
|
||||
// ToDecision 把模型契约输出映射成 Agent 内部统一路由结果。
|
||||
func (o *RouteDecisionOutput) ToDecision() *agentmodel.RouteDecision {
|
||||
if o == nil {
|
||||
return &agentmodel.RouteDecision{Action: agentmodel.ActionChat}
|
||||
}
|
||||
|
||||
action := normalizeRouteAction(o.Action)
|
||||
return &agentmodel.RouteDecision{
|
||||
Action: action,
|
||||
TrustRoute: o.TrustRoute,
|
||||
Detail: strings.TrimSpace(o.Detail),
|
||||
Confidence: o.Confidence,
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeRouteAction(raw string) agentmodel.AgentAction {
|
||||
switch strings.TrimSpace(strings.ToLower(raw)) {
|
||||
case "quick_note", "quick_note_create":
|
||||
return agentmodel.ActionQuickNoteCreate
|
||||
case "task_query":
|
||||
return agentmodel.ActionTaskQuery
|
||||
case "schedule_plan", "schedule_plan_create":
|
||||
return agentmodel.ActionSchedulePlanCreate
|
||||
case "schedule_refine", "schedule_plan_refine":
|
||||
return agentmodel.ActionSchedulePlanRefine
|
||||
default:
|
||||
return agentmodel.ActionChat
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user