Files
ai-agent/internal/builders/skill_builder.go
T
mlogclub 541e4c5874 refactor: replace skill code with skill ID across the application
- Updated skill handling to use skill IDs instead of skill codes in various components, services, and models.
- Modified tests to reflect changes in skill identification.
- Removed references to skill codes in favor of skill IDs for consistency and clarity.
- Updated localization files to remove skill code references and adjust error messages accordingly.
2026-06-20 20:42:07 +08:00

43 lines
1.1 KiB
Go

package builders
import (
"encoding/json"
"agent-desk/internal/models"
"agent-desk/internal/pkg/dto/response"
"agent-desk/internal/pkg/enums"
)
func BuildSkillDefinitionResponse(item *models.SkillDefinition) response.SkillDefinitionResponse {
examples := make([]string, 0)
if raw := item.Examples; raw != "" {
_ = json.Unmarshal([]byte(raw), &examples)
}
toolWhitelist := make([]string, 0)
if raw := item.ToolWhitelist; raw != "" {
_ = json.Unmarshal([]byte(raw), &toolWhitelist)
}
return response.SkillDefinitionResponse{
ID: item.ID,
Name: item.Name,
Description: item.Description,
Instruction: item.Instruction,
Examples: examples,
ToolWhitelist: toolWhitelist,
Status: int(item.Status),
StatusName: getSkillStatusName(item.Status),
Remark: item.Remark,
CreatedAt: item.CreatedAt,
UpdatedAt: item.UpdatedAt,
CreateUserName: item.CreateUserName,
UpdateUserName: item.UpdateUserName,
}
}
func getSkillStatusName(status enums.Status) string {
if label := enums.GetStatusLabel(status); label != "" {
return label
}
return "未知"
}