Files
Agent-System/internal/intent/types.go
T

88 lines
5.1 KiB
Go

package intent
import (
"time"
)
// IntentType 核心意图类别定义
type IntentType string
const (
IntentQueryProgress IntentType = "QUERY_PROGRESS" // 查询进度、成熟度、风险研判或沟通话术
IntentSupplementInfo IntentType = "SUPPLEMENT_INFO" // 补充/修改材料、事实信息或参数
IntentAdvanceStage IntentType = "ADVANCE_STAGE" // 确认推进到下一成熟度阶段 (如 V0.1 -> V0.5)
IntentTriggerTask IntentType = "TRIGGER_TASK" // 显式生成或重新执行特定交付物任务 (如 intake, quote)
IntentCasualChat IntentType = "CASUAL_CHAT" // 问候、闲聊或通用帮助引导
IntentDeclineExpectation IntentType = "DECLINE_EXPECTATION" // 用户明确暂缓/不采纳上轮建议 (非阻塞放弃)
)
// ResolutionBranch 三分支意图消解类别
type ResolutionBranch string
const (
BranchExpectationHit ResolutionBranch = "EXPECTATION_HIT" // 分支 1: 命中历史轮次挂起预期 (肯定/选择/带补丁/取消)
BranchNewIntentPreempt ResolutionBranch = "NEW_INTENT_PREEMPT" // 分支 2: 独立新意图抢占 (用户意图最高优先级)
BranchAmbiguousFallback ResolutionBranch = "AMBIGUOUS_FALLBACK" // 分支 3: 模糊/无实际意义兜底 (参谋主动分析引导)
)
// ExpectationOption 供用户挑选或单字快速兑现的具体选项
type ExpectationOption struct {
OptionID string `json:"option_id"` // 选项代号 (如 "1", "2", "advance_v05")
Title string `json:"title"` // 选项简述 (如 "推进到 V0.5 方案成型与法规对齐")
Description string `json:"description,omitempty"` // 参谋为用户做的工作说明与收益分析
Intent IntentType `json:"intent"` // 对应绑定的业务意图
Slots map[string]string `json:"slots,omitempty"` // 预设槽位键值对
}
// PendingExpectation 挂起预期草稿(非阻塞桌角备忘贴纸)
type PendingExpectation struct {
ContextSnippet string `json:"context_snippet"` // 上一轮建议的业务背景简述
DefaultOption *ExpectationOption `json:"default_option"` // 参谋最推荐的基准选项(用户说“好/行”时默认执行)
Options []ExpectationOption `json:"options"` // 供用户挑选的备选选项列表
AllowAffirmative bool `json:"allow_affirmative"` // 是否允许用单字肯定(好/行/可以)触发
CreatedAt time.Time `json:"created_at"` // 挂起时间
}
// CandidateIntent 候选意图提案(L1 对话层输出,由 L2 协调层终审)
type CandidateIntent struct {
Intent IntentType `json:"intent"`
Confidence float64 `json:"confidence"` // 置信度 0.0 - 1.0
Branch ResolutionBranch `json:"branch"` // 归属的三分支判定
FilledSlots map[string]string `json:"filled_slots"`
MissingSlots []string `json:"missing_slots,omitempty"`
Reasoning string `json:"reasoning"` // 判断依据与文本佐证
ClarificationQuestion string `json:"clarification_question,omitempty"` // 槽位缺失时的澄清追问
MatchedOption *ExpectationOption `json:"matched_option,omitempty"` // 分支 1 命中的具体选项
PatchSlots map[string]string `json:"patch_slots,omitempty"` // 分支 1 复合输入的增量槽位补丁
IsDecline bool `json:"is_decline,omitempty"` // 是否为明确暂缓/放弃
}
// IntentRecognitionResult 意图识别完整输出(多输出策略)
type IntentRecognitionResult struct {
RawInput string `json:"raw_input"`
TopIntent *CandidateIntent `json:"top_intent"`
Candidates []CandidateIntent `json:"candidates"`
ContextSnapshotID string `json:"context_snapshot_id,omitempty"`
RequiresClarifying bool `json:"requires_clarifying"`
Branch ResolutionBranch `json:"branch"` // 顶层分支标记
}
// 常见槽位 Key 常量定义
const (
SlotTargetStage = "target_stage" // 目标阶段 (如 V0.1_triage, V0.5_feasibility, V1.0_quoting)
SlotTargetTask = "target_task" // 目标任务 (如 intake, research, cdo_quote)
SlotFactKey = "fact_key" // 事实键 (如 target_market, device_type)
SlotFactValue = "fact_value" // 事实值
SlotSupplementDoc = "supplement_doc" // 补充内容文本
SlotQueryTopic = "query_topic" // 查询主题 (如 progress, risk, talk_script, quotation)
)
// ContextSnapshot 传递给 L1 意图识别器的轻量上下文快照
type ContextSnapshot struct {
SnapshotID string `json:"snapshot_id,omitempty"`
ProjectName string `json:"project_name,omitempty"`
CurrentStage string `json:"current_stage,omitempty"`
AvailableActions []string `json:"available_actions,omitempty"`
PendingExpectation *PendingExpectation `json:"pending_expectation,omitempty"`
}