Skip to content

Commit cfa7c4d

Browse files
authored
more API notes (#251215)
* more API notes #250007 * fix compile error
1 parent 7443076 commit cfa7c4d

File tree

3 files changed

+91
-8
lines changed

3 files changed

+91
-8
lines changed

.vscode/notebooks/api.github-issues

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"kind": 2,
99
"language": "github-issues",
10-
"value": "$REPO=repo:microsoft/vscode\n$MILESTONE=milestone:\"May 2025\""
10+
"value": "$REPO=repo:microsoft/vscode\n$MILESTONE=milestone:\"June 2025\""
1111
},
1212
{
1313
"kind": 1,

src/vscode-dts/vscode.proposed.chatProvider.d.ts

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ declare module 'vscode' {
1414

1515

1616
// TODO@API name scheme
17-
export interface LanguageModelChatResponseOptions {
17+
export interface LanguageModelChatRequestHandleOptions {
1818

1919
// initiator
2020
readonly extensionId: string;
@@ -44,17 +44,99 @@ declare module 'vscode' {
4444
toolMode?: LanguageModelChatToolMode;
4545
}
4646

47-
export interface LanguageModelChatData {
48-
// like ChatResponseProviderMetadata
47+
// TODO@API names: LanguageModelChatMetadata, LanguageModelChatItem
48+
export interface LanguageModelChatInformation {
49+
50+
// TODO@API IMPLICT from package-json registration
51+
// readonly vendor: string;
52+
53+
readonly id: string;
54+
55+
/**
56+
* Human-readable name of the language model.
57+
*/
58+
readonly name: string;
59+
/**
60+
* Opaque family-name of the language model. Values might be `gpt-3.5-turbo`, `gpt4`, `phi2`, or `llama`
61+
* but they are defined by extensions contributing languages and subject to change.
62+
*/
63+
readonly family: string;
64+
65+
/**
66+
* An optional, human-readable description of the language model.
67+
*/
68+
readonly description?: string;
69+
70+
/**
71+
* An optional, human-readable string representing the cost of using the language model.
72+
*/
73+
readonly cost?: string;
74+
75+
/**
76+
* Opaque version string of the model. This is defined by the extension contributing the language model
77+
* and subject to change while the identifier is stable.
78+
*/
79+
readonly version: string;
80+
81+
readonly maxInputTokens: number;
82+
83+
readonly maxOutputTokens: number;
84+
85+
/**
86+
* When present, this gates the use of `requestLanguageModelAccess` behind an authorization flow where
87+
* the user must approve of another extension accessing the models contributed by this extension.
88+
* Additionally, the extension can provide a label that will be shown in the UI.
89+
*/
90+
auth?: true | { label: string };
91+
92+
// TODO@API maybe an enum, LanguageModelChatProviderPickerAvailability?
93+
// TODO@API isPreselected proposed
94+
readonly isDefault?: boolean;
95+
96+
// TODO@API nuke
97+
readonly isUserSelectable?: boolean;
98+
99+
readonly capabilities?: {
100+
101+
// TODO@API have mimeTypes that you support
102+
readonly vision?: boolean;
103+
104+
// TODO@API should be `boolean | number` so extensions can express how many tools they support
105+
readonly toolCalling?: boolean | number;
106+
107+
// TODO@API DO NOT SUPPORT THIS
108+
// readonly agentMode?: boolean;
109+
110+
// TODO@API support prompt TSX style messages, MAYBE leave it out for now
111+
readonly promptTsx?: boolean;
112+
};
113+
114+
/**
115+
* Optional category to group models by in the model picker.
116+
* The lower the order, the higher the category appears in the list.
117+
* Has no effect if `isUserSelectable` is `false`.
118+
* If not specified, the model will appear in the "Other Models" category.
119+
*/
120+
readonly category?: { label: string; order: number };
49121
}
50122

51-
export interface LanguageModelChatProvider2 {
123+
export interface LanguageModelChatProvider2<T extends LanguageModelChatInformation = LanguageModelChatInformation> {
124+
125+
// signals a change from the provider to the editor so that prepareLanguageModelChat is called again
126+
onDidChange?: Event<void>;
52127

53-
provideLanguageModelChatData(options: { force: boolean }, token: CancellationToken): ProviderResult<LanguageModelChatData[]>;
128+
// NOT cacheable (between reloads)
129+
prepareLanguageModelChat(options: { silent: boolean }, token: CancellationToken): ProviderResult<T[]>;
54130

55-
provideResponse(model: LanguageModelChatData, messages: Array<LanguageModelChatMessage | LanguageModelChatMessage2>, options: LanguageModelChatResponseOptions, progress: Progress<LanguageModelTextPart | LanguageModelToolCallPart>, token: CancellationToken): Thenable<any>;
131+
provideLanguageModelChatResponse(model: T, messages: Array<LanguageModelChatMessage | LanguageModelChatMessage2>, options: LanguageModelChatRequestHandleOptions, progress: Progress<LanguageModelTextPart | LanguageModelToolCallPart>, token: CancellationToken): Thenable<any>;
132+
133+
provideTokenCount(model: T, text: string | LanguageModelChatMessage | LanguageModelChatMessage2, token: CancellationToken): Thenable<number>;
134+
}
135+
136+
export namespace lm {
56137

57-
provideTokenCount(model: LanguageModelChatData, text: string | LanguageModelChatMessage | LanguageModelChatMessage2, token: CancellationToken): Thenable<number>;
138+
//
139+
// export function registerChatModelProvider(vendor: string, provider: LanguageModelChatProvider2): Disposable;
58140
}
59141

60142

src/vscode-dts/vscode.proposed.languageModelDataPart.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ declare module 'vscode' {
6868
* @param data Binary image data
6969
* @param mimeType The MIME type of the image
7070
*/
71+
// TODO@API just use string, no enum required
7172
static image(data: Uint8Array, mimeType: ChatImageMimeType): LanguageModelDataPart;
7273

7374
static json(value: any, mime?: string): LanguageModelDataPart;

0 commit comments

Comments
 (0)