Skip to content

Commit c86fff4

Browse files
committed
Restructure as hints, a list of records
1 parent d2fdabb commit c86fff4

File tree

3 files changed

+47
-24
lines changed

3 files changed

+47
-24
lines changed

docs/spec/sampling.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Message content can be either text or images, allowing for multimodal interactio
3737

3838
### Model Preferences
3939

40-
Servers can express preferences for model selection using the `ModelPreferences` object. This allows servers to indicate priorities for factors like cost, speed, and intelligence, as well as provide name hints for specific models.
40+
Servers can express preferences for model selection using the `ModelPreferences` object. This allows servers to indicate priorities for factors like cost, speed, and intelligence, as well as provide hints for specific models.
4141

4242
## Use Cases
4343

@@ -61,7 +61,11 @@ A server requesting a chat response with model preferences:
6161
"maxTokens": 100,
6262
"temperature": 0.7,
6363
"modelPreferences": {
64-
"nameHints": ["claude-3-sonnet"],
64+
"hints": [
65+
{
66+
"name": "claude-3-sonnet"
67+
}
68+
],
6569
"intelligencePriority": 0.8,
6670
"speedPriority": 0.5
6771
}
@@ -93,7 +97,14 @@ A server requesting analysis of an image:
9397
],
9498
"maxTokens": 200,
9599
"modelPreferences": {
96-
"nameHints": ["claude-3-opus", "claude-3-sonnet"],
100+
"hints": [
101+
{
102+
"name": "claude-3-opus"
103+
},
104+
{
105+
"name": "claude-3-sonnet"
106+
}
107+
],
97108
"intelligencePriority": 1.0
98109
}
99110
}
@@ -168,7 +179,14 @@ Example:
168179
"temperature": 0.7,
169180
"includeContext": "none",
170181
"modelPreferences": {
171-
"nameHints": ["claude-3-sonnet", "claude-3-opus"],
182+
"hints": [
183+
{
184+
"name": "claude-3-sonnet"
185+
},
186+
{
187+
"name": "claude-3-opus"
188+
}
189+
],
172190
"intelligencePriority": 0.9,
173191
"speedPriority": 0.6
174192
}

schema/schema.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -907,19 +907,19 @@
907907
"minimum": 0,
908908
"type": "number"
909909
},
910+
"hints": {
911+
"description": "Optional string hints to use for model selection. How these hints are\ninterpreted depends on the key(s) in each record:\n\n- If the record contains a `name` key:\n - The client SHOULD treat this as a substring of a model name; for example:\n - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`\n - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.\n - `claude` should match any Claude model\n - The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example:\n - `gemini-1.5-flash` could match `claude-3-haiku-20240307`\n\nAll other keys are currently left unspecified by the spec and are up to the\nclient to interpret.\n\nIf multiple hints are specified, the client MUST evaluate them in order\n(such that the first match is taken).\n\nThe client SHOULD prioritize these hints over the numeric priorities, but\nMAY still use the priorities to select from ambiguous matches.",
912+
"items": {
913+
"$ref": "#/definitions/Record<string,string>"
914+
},
915+
"type": "array"
916+
},
910917
"intelligencePriority": {
911918
"description": "How much to prioritize intelligence and capabilities when selecting a\nmodel. A value of 0 means intelligence is not important, while a value of 1\nmeans intelligence is the most important factor.",
912919
"maximum": 1,
913920
"minimum": 0,
914921
"type": "number"
915922
},
916-
"nameHints": {
917-
"description": "Optional string hints to use for model selection.\n\nThe client SHOULD treat these as substrings of model names; for example:\n - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`\n - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.\n - `claude` should match any Claude model\n\nThe client MAY also map hints to a different provider's model or a\ndifferent model family, as long as it fills a similar niche; for example:\n - `gemini-1.5-flash` could match `claude-3-haiku-20240307`\n\nIf multiple hints are specified, the client MUST evaluate them in order\n(such that the first match is taken).\n\nThe client SHOULD prioritize these string hints over the numeric\npriorities, but MAY still use the priorities to select from ambiguous\nmatches.",
918-
"items": {
919-
"type": "string"
920-
},
921-
"type": "array"
922-
},
923923
"speedPriority": {
924924
"description": "How much to prioritize sampling speed (latency) when selecting a model. A\nvalue of 0 means speed is not important, while a value of 1 means speed is\nthe most important factor.",
925925
"maximum": 1,
@@ -1196,6 +1196,9 @@
11961196
],
11971197
"type": "object"
11981198
},
1199+
"Record<string,string>": {
1200+
"type": "object"
1201+
},
11991202
"Request": {
12001203
"properties": {
12011204
"method": {

schema/schema.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -747,32 +747,34 @@ export interface ImageContent {
747747
* faster but less capable, others are more capable but more expensive, and so
748748
* on. This interface allows servers to express their priorities across multiple
749749
* dimensions to help clients make an appropriate selection for their use case.
750-
*
750+
*
751751
* These preferences are always advisory. The client MAY ignore them. It is also
752752
* up to the client to decide how to interpret these preferences and how to
753753
* balance them against other considerations.
754754
*/
755755
export interface ModelPreferences {
756756
/**
757-
* Optional string hints to use for model selection.
757+
* Optional string hints to use for model selection. How these hints are
758+
* interpreted depends on the key(s) in each record:
758759
*
759-
* The client SHOULD treat these as substrings of model names; for example:
760-
* - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`
761-
* - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.
762-
* - `claude` should match any Claude model
760+
* - If the record contains a `name` key:
761+
* - The client SHOULD treat this as a substring of a model name; for example:
762+
* - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`
763+
* - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.
764+
* - `claude` should match any Claude model
765+
* - The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example:
766+
* - `gemini-1.5-flash` could match `claude-3-haiku-20240307`
763767
*
764-
* The client MAY also map hints to a different provider's model or a
765-
* different model family, as long as it fills a similar niche; for example:
766-
* - `gemini-1.5-flash` could match `claude-3-haiku-20240307`
768+
* All other keys are currently left unspecified by the spec and are up to the
769+
* client to interpret.
767770
*
768771
* If multiple hints are specified, the client MUST evaluate them in order
769772
* (such that the first match is taken).
770773
*
771-
* The client SHOULD prioritize these string hints over the numeric
772-
* priorities, but MAY still use the priorities to select from ambiguous
773-
* matches.
774+
* The client SHOULD prioritize these hints over the numeric priorities, but
775+
* MAY still use the priorities to select from ambiguous matches.
774776
*/
775-
nameHints?: string[];
777+
hints?: Record<"name" | string, string>[];
776778

777779
/**
778780
* How much to prioritize cost when selecting a model. A value of 0 means cost

0 commit comments

Comments
 (0)