You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`fieldName`| string | no |`model`| Request-body field to read the requested value from. |
207
+
|`optionalValues.byField`| string | no | (candidate's name) | Candidate attribute compared against `fieldName`'s value for explicit (non-`auto`) matches. |
Filter the candidate model names based on the request body mode name field.
4
-
Support explicit model selection by specifying a model name in the `model` field.
3
+
Filter the candidate models based on a configurable request body field.
4
+
Support explicit selection by specifying a value in that field, matched against each
5
+
candidate's name (by default) or one of its attributes.
5
6
Support using `auto` or `auto/group-name` for selecting more than one model candidate.
6
-
`auto` (or no model name field) enables using all candidate models (no filtering), while using the pattern `auto/group-name` selects
7
+
`auto` (or no value in the field) enables using all candidate models (no filtering), while using the pattern `auto/group-name` selects
7
8
the models that belong to the group `group-name`.
8
9
9
-
It is registered as type `model-group-name-filter` and runs as a modelselector filter. The filter takes no
10
-
plugin parameters: group membership is not configured on the filter itself. Instead it is resolved at filter
11
-
time from each candidate model's `modelgroups.GroupsAttributeKey` attribute in the datalayer, which is
12
-
populated by the `model-config-datasource` plugin (`pkg/framework/plugins/datalayer/modelconfigcollector`)
13
-
from the `groups`section of its config file. This lets group membership be updated dynamically (e.g. via a
14
-
Kubernetes ConfigMap) without restarting or reconfiguring this filter.
10
+
It is registered as type `model-group-name-filter` and runs as a modelselector filter. Group membership is
11
+
not configured on the filter itself: it is resolved at filter time from each candidate model's
12
+
`modelgroups.GroupsAttributeKey` attribute in the datalayer, which is populated by the
13
+
`model-config-datasource` plugin (`pkg/framework/plugins/datalayer/modelconfigcollector`) from the `groups`
14
+
section of its config file. This lets group membership be updated dynamically (e.g. via a Kubernetes
15
+
ConfigMap) without restarting or reconfiguring this filter.
15
16
16
-
When the model name is set to `auto/group-name` the filter matches the requested `group-name` against each
17
-
candidate model's group attribute and keeps only the candidates that belong to that group.
17
+
When the request value is set to `auto/group-name` the filter matches the requested `group-name` against
18
+
each candidate model's group attribute and keeps only the candidates that belong to that group. Group
19
+
membership is always matched by the candidate's name, regardless of the `optionalValues.byField` setting
20
+
below.
18
21
19
22
## What it does
20
23
21
-
1. Reads the `model` field from the request body.
24
+
1. Reads the configured field (`fieldName`, default `model`) from the request body.
22
25
2. If the field is absent, an empty string or `auto`, all incoming candidates are kept.
23
-
3. If the `model`field is formatted as `auto/group-name`, with the prefix `auto` and separator `/`, it extracts `group-name` and keeps the candidate models whose `modelgroups.GroupsAttributeKey` attribute lists that group name.
24
-
4. If the `model`fieldis a non-empty string that is not `auto` and does not start with `auto/`, it is treated as an explicit model name and the single matching candidate is kept.
26
+
3. If the field's value is formatted as `auto/group-name`, with the prefix `auto` and separator `/`, it extracts `group-name` and keeps the candidate models whose `modelgroups.GroupsAttributeKey` attribute lists that group name.
27
+
4. If the field's value is a valid non-empty string that does not start with the prefix `auto`, it is compared against each candidate's comparison value — the candidate's name by default, or the attribute named by `optionalValues.byField` when configured — and the matching candidate(s) are kept.
25
28
5. If the intersection is empty or the field is malformed (not a string), the filter returns no candidates and the pipeline rejects the request with HTTP 429.
26
29
27
-
## Inputs consumed
28
-
29
-
- The `model` field of the request body.
30
-
- The candidate model list passed in by the pipeline, with each model's `modelgroups.GroupsAttributeKey` attribute (if any), as populated by the `model-config-datasource` plugin.
30
+
## Configuration
31
31
32
-
## Example configuration
32
+
The parameters are a flat JSON object with two optional keys:
33
33
34
-
```yaml
35
-
plugins:
36
-
- type: model-group-name-filter
34
+
```json
35
+
{
36
+
"fieldName": "model",
37
+
"optionalValues": {
38
+
"byField": "modelId"
39
+
}
40
+
}
37
41
```
38
42
43
+
-`fieldName` (optional, default `"model"`): the request-body field to read the requested value from.
44
+
-`optionalValues.byField` (optional): the name of the candidate attribute compared against `fieldName`'s value for explicit (non-`auto`) matches. When omitted, the candidate's name (`Model.GetName()`) is used. When set, the candidate must carry that attribute as a `StringAttribute` (a small `Cloneable` wrapper around `string`); candidates missing it never match. This setting does not affect `auto/<group-name>` matching, which is always by name.
45
+
39
46
Group membership itself is configured on the `model-config-datasource` plugin's config file, not here.
40
-
That plugin's config file (pointed to by its `modelsPath` parameter) lists models (omitted in the example) and,
41
-
alongside them, a `groups` section mapping a group name to the model names that belong to it:
47
+
That plugin's config file (pointed to by its `modelsPath` parameter) lists models and, alongside them, a
48
+
`groups` section mapping a group name to the model names that belong to it:
42
49
43
50
```json
44
51
{
@@ -49,7 +56,40 @@ alongside them, a `groups` section mapping a group name to the model names that
49
56
}
50
57
```
51
58
52
-
With this configuration snippet, a request with `model` set to `auto/fast` is filtered to the candidates `qwen3-8b` and
53
-
`gpt-oss-20b`; `auto/planning` is filtered to `gpt-oss-120b` and `gemma4`. A model can appear in more than
54
-
one group's `models` list. A group with an empty `name` or an empty `models` list is skipped (and logged) by `model-config-datasource`, as is a group entry naming a model not present in the top-level
59
+
With this configuration snippet, a request with `model` set to `auto/fast` is filtered to the candidates
60
+
`qwen3-8b` and `gpt-oss-20b`; `auto/planning` is filtered to `gpt-oss-120b` and `gemma4`. A model can appear
61
+
in more than one group's `models` list. A group with an empty `name` or an empty `models` list is skipped
62
+
(and logged) by `model-config-datasource`, as is a group entry naming a model not present in the top-level
55
63
`models` list.
64
+
65
+
## Inputs consumed
66
+
67
+
- The `fieldName` field of the request body.
68
+
- The candidate model list passed in by the pipeline, including each candidate's name, its
69
+
`modelgroups.GroupsAttributeKey` attribute (if any) as populated by the `model-config-datasource` plugin,
70
+
and (when `optionalValues.byField` is set) its other attributes.
71
+
72
+
## Example configurations
73
+
74
+
### Defaults (the field defaults to `model`, matched by name)
75
+
76
+
```yaml
77
+
plugins:
78
+
- type: model-group-name-filter
79
+
```
80
+
81
+
Group membership (for `auto/<group-name>`) is configured separately, on the `model-config-datasource`
82
+
plugin, as shown above.
83
+
84
+
### Matching by a different field/attribute
85
+
86
+
```yaml
87
+
plugins:
88
+
- type: model-group-name-filter
89
+
parameters:
90
+
fieldName: anthropic_version
91
+
optionalValues:
92
+
byField: anthropicVersion
93
+
```
94
+
95
+
Matches `request.Body["anthropic_version"]` (e.g. `"bedrock-2023-05-31"`) against the `anthropicVersion` attribute of each candidate, instead of the candidate's name.
0 commit comments