feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
+13
-1
@@ -20,6 +20,7 @@ type TokenRoutingPolicy struct {
|
||||
AutoPreference string `json:"auto_preference,omitempty"`
|
||||
AllowDegraded bool `json:"allow_degraded,omitempty"`
|
||||
SkipDegradedGroups bool `json:"skip_degraded_groups,omitempty"`
|
||||
ExcludedGroups []string `json:"excluded_groups,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Mode string `json:"mode"`
|
||||
Groups []TokenGroupEntry `json:"groups"`
|
||||
@@ -33,7 +34,7 @@ func (p *TokenRoutingPolicy) Validate(maxGroups int, allowed func(string) bool)
|
||||
if p.Mode == "custom" && len(p.Groups) == 0 {
|
||||
return fmt.Errorf("a group pool must contain at least one group")
|
||||
}
|
||||
if p.Mode == "smart" && (len(p.ModelRules) != 0 || (p.AutoPreference != "" && p.AutoPreference != "cost" && p.AutoPreference != "speed" && p.AutoPreference != "stable")) {
|
||||
if p.Mode == "smart" && (len(p.ModelRules) != 0 || (p.AutoPreference != "" && p.AutoPreference != "cost" && p.AutoPreference != "speed" && p.AutoPreference != "throughput" && p.AutoPreference != "stable")) {
|
||||
return fmt.Errorf("invalid automatic routing settings")
|
||||
}
|
||||
if p.Mode != "custom" && len(p.Groups) != 0 {
|
||||
@@ -43,6 +44,13 @@ func (p *TokenRoutingPolicy) Validate(maxGroups int, allowed func(string) bool)
|
||||
return fmt.Errorf("routing policy exceeds configured limits")
|
||||
}
|
||||
pool := map[string]bool{}
|
||||
excluded := map[string]bool{}
|
||||
for _, group := range p.ExcludedGroups {
|
||||
if group == "" || group == "auto" || group != strings.TrimSpace(group) || excluded[group] {
|
||||
return common.NewMessage("Invalid group blacklist")
|
||||
}
|
||||
excluded[group] = true
|
||||
}
|
||||
for _, entry := range p.Groups {
|
||||
if entry.Group == "" || entry.Group == "auto" || entry.Group != strings.TrimSpace(entry.Group) || pool[entry.Group] || entry.Priority < 0 || entry.Priority > 10000 || !allowed(entry.Group) {
|
||||
return fmt.Errorf("invalid or inaccessible pool group: %s", entry.Group)
|
||||
@@ -66,6 +74,10 @@ func (p *TokenRoutingPolicy) Validate(maxGroups int, allowed func(string) bool)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *TokenRoutingPolicy) ExcludesGroup(group string) bool {
|
||||
return p != nil && p.Mode == "smart" && slices.Contains(p.ExcludedGroups, group)
|
||||
}
|
||||
|
||||
// Resolve is shared by routing and the management preview. Model preferences
|
||||
// precede remaining defaults; matching priorities stay in the same tier.
|
||||
func (p *TokenRoutingPolicy) Resolve(modelName string, inherited []string, allowed func(string) bool) []TokenGroupEntry {
|
||||
|
||||
Reference in new issue
Block a user