-
Notifications
You must be signed in to change notification settings - Fork 31.8k
/
Copy pathvscode.proposed.languageModelDataPart.d.ts
188 lines (159 loc) · 6.38 KB
/
vscode.proposed.languageModelDataPart.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// version: 2
declare module 'vscode' {
export interface LanguageModelChat {
sendRequest(messages: Array<LanguageModelChatMessage | LanguageModelChatMessage2>, options?: LanguageModelChatRequestOptions, token?: CancellationToken): Thenable<LanguageModelChatResponse>;
countTokens(text: string | LanguageModelChatMessage | LanguageModelChatMessage2, token?: CancellationToken): Thenable<number>;
}
/**
* Represents a message in a chat. Can assume different roles, like user or assistant.
*/
export class LanguageModelChatMessage2 {
/**
* Utility to create a new user message.
*
* @param content The content of the message.
* @param name The optional name of a user for the message.
*/
static User(content: string | Array<LanguageModelTextPart | LanguageModelToolResultPart2 | LanguageModelDataPart | LanguageModelExtraDataPart>, name?: string): LanguageModelChatMessage2;
/**
* Utility to create a new assistant message.
*
* @param content The content of the message.
* @param name The optional name of a user for the message.
*/
static Assistant(content: string | Array<LanguageModelTextPart | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelExtraDataPart>, name?: string): LanguageModelChatMessage2;
/**
* The role of this message.
*/
role: LanguageModelChatMessageRole;
/**
* A string or heterogeneous array of things that a message can contain as content. Some parts may be message-type
* specific for some models.
*/
content: Array<LanguageModelTextPart | LanguageModelToolResultPart2 | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelExtraDataPart>;
/**
* The optional name of a user for this message.
*/
name: string | undefined;
/**
* Create a new user message.
*
* @param role The role of the message.
* @param content The content of the message.
* @param name The optional name of a user for the message.
*/
constructor(role: LanguageModelChatMessageRole, content: string | Array<LanguageModelTextPart | LanguageModelToolResultPart2 | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelExtraDataPart>, name?: string);
}
/**
* A language model response part containing arbitrary data, returned from a {@link LanguageModelChatResponse}.
*/
export class LanguageModelDataPart {
/**
* Factory function to create a `LanguageModelDataPart` for an image.
* @param data Binary image data
* @param mimeType The MIME type of the image
*/
static image(data: Uint8Array, mimeType: ChatImageMimeType): LanguageModelDataPart;
static json(value: object): LanguageModelDataPart;
static text(value: string): LanguageModelDataPart;
/**
* The mime type which determines how the data property is interpreted.
*/
mimeType: string;
/**
* The data of the part.
*/
data: Uint8Array;
/**
* Construct a generic data part with the given content.
* @param value The data of the part.
*/
constructor(data: Uint8Array, mimeType: string);
}
/**
* Enum for supported image MIME types.
*/
export enum ChatImageMimeType {
PNG = 'image/png',
JPEG = 'image/jpeg',
GIF = 'image/gif',
WEBP = 'image/webp',
BMP = 'image/bmp',
}
/**
* Tagging onto this proposal, because otherwise managing two different extensions of LanguageModelChatMessage could be confusing.
* A language model response part containing arbitrary model-specific data, returned from a {@link LanguageModelChatResponse}.
* TODO@API naming, looking at LanguageModelChatRequestOptions.modelOptions, but LanguageModelModelData is not very good.
* LanguageModelOpaqueData from prompt-tsx?
*/
export class LanguageModelExtraDataPart {
/**
* The type of data. The allowed values and data types here are model-specific.
*/
kind: string;
/**
* Extra model-specific data.
*/
data: any;
/**
* Construct an extra data part with the given content.
* @param value The image content of the part.
*/
constructor(kind: string, data: any);
}
/**
* The result of a tool call. This is the counterpart of a {@link LanguageModelToolCallPart tool call} and
* it can only be included in the content of a User message
*/
export class LanguageModelToolResultPart2 {
/**
* The ID of the tool call.
*
* *Note* that this should match the {@link LanguageModelToolCallPart.callId callId} of a tool call part.
*/
callId: string;
/**
* The value of the tool result.
*/
content: Array<LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart | unknown>;
/**
* @param callId The ID of the tool call.
* @param content The content of the tool result.
*/
constructor(callId: string, content: Array<LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart | unknown>);
}
/**
* A tool that can be invoked by a call to a {@link LanguageModelChat}.
*/
export interface LanguageModelTool<T> {
/**
* Invoke the tool with the given input and return a result.
*
* The provided {@link LanguageModelToolInvocationOptions.input} has been validated against the declared schema.
*/
invoke(options: LanguageModelToolInvocationOptions<T>, token: CancellationToken): ProviderResult<LanguageModelToolResult2>;
}
/**
* A result returned from a tool invocation. If using `@vscode/prompt-tsx`, this result may be rendered using a `ToolResult`.
*/
export class LanguageModelToolResult2 {
/**
* A list of tool result content parts. Includes `unknown` becauses this list may be extended with new content types in
* the future.
* @see {@link lm.invokeTool}.
*/
content: Array<LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart | unknown>;
/**
* Create a LanguageModelToolResult
* @param content A list of tool result content parts
*/
constructor(content: Array<LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart | unknown>);
}
export namespace lm {
export function invokeTool(name: string, options: LanguageModelToolInvocationOptions<object>, token?: CancellationToken): Thenable<LanguageModelToolResult2>;
}
}