Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.chatProvider.d.ts
5257 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
// version: 4
7
8
declare module 'vscode' {
9
10
/**
11
* The provider version of {@linkcode LanguageModelChatRequestOptions}
12
*/
13
export interface ProvideLanguageModelChatResponseOptions {
14
15
/**
16
* What extension initiated the request to the language model
17
*/
18
readonly requestInitiator: string;
19
}
20
21
/**
22
* All the information representing a single language model contributed by a {@linkcode LanguageModelChatProvider}.
23
*/
24
export interface LanguageModelChatInformation {
25
26
/**
27
* When present, this gates the use of `requestLanguageModelAccess` behind an authorization flow where
28
* the user must approve of another extension accessing the models contributed by this extension.
29
* Additionally, the extension can provide a label that will be shown in the UI.
30
* A common example of a label is an account name that is signed in.
31
*
32
*/
33
requiresAuthorization?: true | { label: string };
34
35
/**
36
* A multiplier indicating how many requests this model counts towards a quota.
37
* For example, "2x" means each request counts twice.
38
*/
39
readonly multiplier?: string;
40
41
/**
42
* A numeric form of the `multiplier` label
43
*/
44
readonly multiplierNumeric?: number;
45
46
/**
47
* Whether or not this will be selected by default in the model picker
48
* NOT BEING FINALIZED
49
*/
50
readonly isDefault?: boolean | { [K in ChatLocation]?: boolean };
51
52
/**
53
* Whether or not the model will show up in the model picker immediately upon being made known via {@linkcode LanguageModelChatProvider.provideLanguageModelChatInformation}.
54
* NOT BEING FINALIZED
55
*/
56
readonly isUserSelectable?: boolean;
57
58
/**
59
* Optional category to group models by in the model picker.
60
* The lower the order, the higher the category appears in the list.
61
* Has no effect if `isUserSelectable` is `false`.
62
*
63
* WONT BE FINALIZED
64
*/
65
readonly category?: { label: string; order: number };
66
67
readonly statusIcon?: ThemeIcon;
68
}
69
70
export interface LanguageModelChatCapabilities {
71
/**
72
* The tools the model prefers for making file edits. If not provided or if none of the tools,
73
* are recognized, the editor will try multiple edit tools and pick the best one. The available
74
* edit tools WILL change over time and this capability only serves as a hint to the editor.
75
*
76
* Edit tools currently recognized include:
77
* - 'find-replace': Find and replace text in a document.
78
* - 'multi-find-replace': Find and replace multiple text snippets across documents.
79
* - 'apply-patch': A file-oriented diff format used by some OpenAI models
80
* - 'code-rewrite': A general but slower editing tool that allows the model
81
* to rewrite and code snippet and provide only the replacement to the editor.
82
*
83
* The order of edit tools in this array has no significance; all of the recognized edit
84
* tools will be made available to the model.
85
*/
86
readonly editTools?: string[];
87
}
88
89
export type LanguageModelResponsePart2 = LanguageModelResponsePart | LanguageModelDataPart | LanguageModelThinkingPart;
90
91
export interface LanguageModelChatProvider<T extends LanguageModelChatInformation = LanguageModelChatInformation> {
92
provideLanguageModelChatInformation(options: PrepareLanguageModelChatModelOptions, token: CancellationToken): ProviderResult<T[]>;
93
provideLanguageModelChatResponse(model: T, messages: readonly LanguageModelChatRequestMessage[], options: ProvideLanguageModelChatResponseOptions, progress: Progress<LanguageModelResponsePart2>, token: CancellationToken): Thenable<void>;
94
}
95
96
/**
97
* The list of options passed into {@linkcode LanguageModelChatProvider.provideLanguageModelChatInformation}
98
*/
99
export interface PrepareLanguageModelChatModelOptions {
100
/**
101
* Configuration for the model. This is only present if the provider has declared that it requires configuration via the `configuration` property.
102
* The object adheres to the schema that the extension provided during declaration.
103
*/
104
readonly configuration?: {
105
readonly [key: string]: any;
106
};
107
}
108
}
109
110