package subsession import ( "context" "time" "git.yeij.top/AskaEth/Cyrene/ai-core/internal/llm" "git.yeij.top/AskaEth/Cyrene/ai-core/internal/model" "git.yeij.top/AskaEth/Cyrene/ai-core/internal/persona" ) // Provider 子会话提供者接口 // 每种子会话类型实现此接口 type Provider interface { // Type 返回子会话类型标识 Type() model.SubSessionType // CanHandle 判断是否需要为此消息创建子会话 CanHandle(ctx context.Context, intent *model.IntentResult, userMessage string) bool // Priority 返回优先级 (数字越小优先级越高) Priority() int // CreateContext 创建子会话的 LLM 上下文 // 不包含对话历史(历史由 Orchestrator 统一管理) CreateContext(ctx context.Context, params CreateContextParams) ([]model.LLMMessage, error) // Timeout 返回此子会话的超时时间 Timeout() time.Duration // Execute 执行子会话逻辑,返回结果 // 子会话可以调用 LLM、执行工具调用等 Execute(ctx context.Context, subCtx []model.LLMMessage) (*model.SubSessionResult, error) } // CreateContextParams 创建上下文参数 type CreateContextParams struct { UserID string SessionID string UserMessage string PersonaConfig *persona.PersonaConfig DeviceContext string // IoT 设备状态文本 Intent *model.IntentResult Nickname string // 用户昵称 } // LLMClient LLM 调用接口(避免循环依赖) type LLMClient interface { Chat(ctx context.Context, messages []model.LLMMessage) (*model.LLMResponse, error) ChatWithTools(ctx context.Context, messages []model.LLMMessage, tools []llm.OpenAITool) (*model.LLMResponse, error) }