Refactored orchestrator for staged file handling, added structured prompt support, adjusted Feishu file handling
This commit is contained in:
31
internal/agent/router_parser.go
Normal file
31
internal/agent/router_parser.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type capabilityRouteDecision struct {
|
||||
NeedSkills bool `json:"need_skills"`
|
||||
SelectedTools []string `json:"selected_tools"`
|
||||
SelectedSkills []string `json:"selected_skills"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func parseCapabilityRoute(raw string) (capabilityRouteDecision, error) {
|
||||
raw = normalizeJSON(raw)
|
||||
start := strings.Index(raw, "{")
|
||||
end := strings.LastIndex(raw, "}")
|
||||
if start < 0 || end < start {
|
||||
return capabilityRouteDecision{}, fmt.Errorf("no json object found")
|
||||
}
|
||||
raw = raw[start : end+1]
|
||||
|
||||
var out capabilityRouteDecision
|
||||
if err := json.Unmarshal([]byte(raw), &out); err != nil {
|
||||
return capabilityRouteDecision{}, err
|
||||
}
|
||||
out.Reason = strings.TrimSpace(out.Reason)
|
||||
return out, nil
|
||||
}
|
||||
Reference in New Issue
Block a user