Refactor AI Agent and AI Config handling across multiple files
- Updated function signatures to accept AI Agent and AI Config as non-pointer types for better clarity and safety. - Modified instances where AI Agent and AI Config were dereferenced to improve code readability. - Removed unnecessary nil checks for AI Agent and AI Config, simplifying the logic. - Adjusted related tests and services to align with the new function signatures. - Cleaned up code in runtime, skills, and executor packages to ensure consistency in handling AI configurations.
This commit is contained in:
@@ -20,7 +20,7 @@ type RunLogService struct{}
|
||||
func (s *RunLogService) Build(ctx RuntimeContext, plan *ExecutionPlan, trace *ExecutionTrace, err error) *models.SkillRunLog {
|
||||
log := &models.SkillRunLog{
|
||||
ConversationID: ctx.ConversationID,
|
||||
AIAgentID: resolveRuntimeAIAgentID(ctx, plan),
|
||||
AIAgentID: ctx.AIAgent.ID,
|
||||
ManualSkillCode: ctx.ManualSkillCode,
|
||||
IntentCode: ctx.IntentCode,
|
||||
UserMessage: ctx.UserMessage,
|
||||
@@ -28,11 +28,10 @@ func (s *RunLogService) Build(ctx RuntimeContext, plan *ExecutionPlan, trace *Ex
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
if plan != nil {
|
||||
if plan.AIConfig != nil {
|
||||
log.AIConfigID = plan.AIConfig.ID
|
||||
log.UsedModel = plan.AIConfig.ModelName
|
||||
log.UsedProvider = plan.AIConfig.Provider
|
||||
}
|
||||
log.AIConfigID = plan.AIConfig.ID
|
||||
log.UsedModel = plan.AIConfig.ModelName
|
||||
log.UsedProvider = plan.AIConfig.Provider
|
||||
|
||||
if plan.Skill != nil {
|
||||
log.SkillDefinitionID = plan.Skill.ID
|
||||
log.SkillCode = plan.Skill.Code
|
||||
@@ -53,16 +52,6 @@ func (s *RunLogService) Build(ctx RuntimeContext, plan *ExecutionPlan, trace *Ex
|
||||
return log
|
||||
}
|
||||
|
||||
func resolveRuntimeAIAgentID(ctx RuntimeContext, plan *ExecutionPlan) int64 {
|
||||
if ctx.AIAgent != nil {
|
||||
return ctx.AIAgent.ID
|
||||
}
|
||||
if plan != nil && plan.AIAgent != nil {
|
||||
return plan.AIAgent.ID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Write 写入 Skill 路由日志。
|
||||
func (s *RunLogService) Write(log *models.SkillRunLog) error {
|
||||
if log == nil {
|
||||
|
||||
Reference in New Issue
Block a user