Files
ai-agent/internal/ai/skills/candidate_loader.go
T
mlogclub 976b9defde 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.
2026-04-17 17:57:01 +08:00

34 lines
912 B
Go

package skills
import (
"cs-agent/internal/models"
"cs-agent/internal/pkg/enums"
"cs-agent/internal/pkg/utils"
"cs-agent/internal/repositories"
"github.com/mlogclub/simple/sqls"
)
var newCandidateLoader = func() *candidateLoader {
return &candidateLoader{}
}
type candidateLoader struct {
}
func (l *candidateLoader) findManualSkillDefinition(skillCode string) *models.SkillDefinition {
return repositories.SkillDefinitionRepository.GetByCode(sqls.DB(), skillCode)
}
func (l *candidateLoader) loadCandidateSkills(aiAgent models.AIAgent) []models.SkillDefinition {
skillIDs := utils.SplitInt64s(aiAgent.SkillIDs)
skills := repositories.SkillDefinitionRepository.GetByIDs(sqls.DB(), skillIDs)
ret := make([]models.SkillDefinition, 0, len(skillIDs))
for _, id := range skillIDs {
if skill, ok := skills[id]; ok && skill.Status == enums.StatusOk {
ret = append(ret, skill)
}
}
return ret
}