Refactor skill execution and definition handling to support content-based execution and enhance skill definition structure
This commit is contained in:
@@ -1,29 +1,38 @@
|
||||
package builders
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"cs-agent/internal/models"
|
||||
"cs-agent/internal/pkg/dto/response"
|
||||
"cs-agent/internal/pkg/enums"
|
||||
)
|
||||
|
||||
func BuildSkillDefinitionResponse(item *models.SkillDefinition) response.SkillDefinitionResponse {
|
||||
examples := make([]string, 0)
|
||||
if raw := item.Examples; raw != "" {
|
||||
_ = json.Unmarshal([]byte(raw), &examples)
|
||||
}
|
||||
allowedToolCodes := make([]string, 0)
|
||||
if raw := item.AllowedToolCodes; raw != "" {
|
||||
_ = json.Unmarshal([]byte(raw), &allowedToolCodes)
|
||||
}
|
||||
return response.SkillDefinitionResponse{
|
||||
ID: item.ID,
|
||||
Code: item.Code,
|
||||
Name: item.Name,
|
||||
Description: item.Description,
|
||||
Prompt: item.Prompt,
|
||||
ExecutionMode: string(item.ExecutionMode),
|
||||
ExecutionModeName: enums.GetSkillExecutionModeLabel(item.ExecutionMode),
|
||||
ExecutionConfig: item.ExecutionConfig,
|
||||
Priority: item.Priority,
|
||||
Status: int(item.Status),
|
||||
StatusName: getSkillStatusName(item.Status),
|
||||
Remark: item.Remark,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
CreateUserName: item.CreateUserName,
|
||||
UpdateUserName: item.UpdateUserName,
|
||||
ID: item.ID,
|
||||
Code: item.Code,
|
||||
Name: item.Name,
|
||||
Description: item.Description,
|
||||
Content: item.Content,
|
||||
Examples: examples,
|
||||
AllowedToolCodes: allowedToolCodes,
|
||||
Priority: item.Priority,
|
||||
Status: int(item.Status),
|
||||
StatusName: getSkillStatusName(item.Status),
|
||||
Remark: item.Remark,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
CreateUserName: item.CreateUserName,
|
||||
UpdateUserName: item.UpdateUserName,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user