66 "os"
77 "regexp"
88 "runtime"
9+ "slices"
910 "sort"
1011 "strconv"
1112 "strings"
@@ -29,6 +30,9 @@ type ModelConfig struct {
2930
3031 // Limit concurrency of HTTP requests to process
3132 ConcurrencyLimit int `yaml:"concurrencyLimit"`
33+
34+ // Model filters see issue #174
35+ Filters ModelFilters `yaml:"filters"`
3236}
3337
3438func (m * ModelConfig ) UnmarshalYAML (unmarshal func (interface {}) error ) error {
@@ -63,6 +67,46 @@ func (m *ModelConfig) SanitizedCommand() ([]string, error) {
6367 return SanitizeCommand (m .Cmd )
6468}
6569
70+ // ModelFilters see issue #174
71+ type ModelFilters struct {
72+ StripParams string `yaml:"strip_params"`
73+ }
74+
75+ func (m * ModelFilters ) UnmarshalYAML (unmarshal func (interface {}) error ) error {
76+ type rawModelFilters ModelFilters
77+ defaults := rawModelFilters {
78+ StripParams : "" ,
79+ }
80+
81+ if err := unmarshal (& defaults ); err != nil {
82+ return err
83+ }
84+
85+ * m = ModelFilters (defaults )
86+ return nil
87+ }
88+
89+ func (f ModelFilters ) SanitizedStripParams () ([]string , error ) {
90+ if f .StripParams == "" {
91+ return nil , nil
92+ }
93+
94+ params := strings .Split (f .StripParams , "," )
95+ cleaned := make ([]string , 0 , len (params ))
96+
97+ for _ , param := range params {
98+ trimmed := strings .TrimSpace (param )
99+ if trimmed == "model" || trimmed == "" {
100+ continue
101+ }
102+ cleaned = append (cleaned , strings .TrimSpace (param ))
103+ }
104+
105+ // sort cleaned
106+ slices .Sort (cleaned )
107+ return cleaned , nil
108+ }
109+
66110type GroupConfig struct {
67111 Swap bool `yaml:"swap"`
68112 Exclusive bool `yaml:"exclusive"`
@@ -212,6 +256,7 @@ func LoadConfigFromReader(r io.Reader) (Config, error) {
212256 modelConfig .CmdStop = strings .ReplaceAll (modelConfig .CmdStop , macroSlug , macroValue )
213257 modelConfig .Proxy = strings .ReplaceAll (modelConfig .Proxy , macroSlug , macroValue )
214258 modelConfig .CheckEndpoint = strings .ReplaceAll (modelConfig .CheckEndpoint , macroSlug , macroValue )
259+ modelConfig .Filters .StripParams = strings .ReplaceAll (modelConfig .Filters .StripParams , macroSlug , macroValue )
215260 }
216261
217262 // enforce ${PORT} used in both cmd and proxy
0 commit comments