Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.ts
4780 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
import { IJSONSchema } from '../../../../../base/common/jsonSchema.js';
7
import { Extensions as JSONExtensions, IJSONContributionRegistry } from '../../../../../platform/jsonschemas/common/jsonContributionRegistry.js';
8
import { Registry } from '../../../../../platform/registry/common/platform.js';
9
10
/**
11
* A schema for parametersSchema
12
* This is a subset of https://json-schema.org/draft-07/schema to capture what is actually supported by language models for tools, mainly, that they must be an object at the top level.
13
* Possibly it can be whittled down some more based on which attributes are supported by language models.
14
*/
15
export const toolsParametersSchemaSchemaId = 'vscode://schemas/toolsParameters';
16
const toolsParametersSchemaSchema: IJSONSchema = {
17
definitions: {
18
schemaArray: {
19
type: 'array',
20
minItems: 1,
21
items: {
22
$ref: '#'
23
}
24
},
25
nonNegativeInteger: {
26
type: 'integer',
27
minimum: 0
28
},
29
nonNegativeIntegerDefault0: {
30
allOf: [
31
{
32
$ref: '#/definitions/nonNegativeInteger'
33
},
34
{
35
default: 0
36
}
37
]
38
},
39
simpleTypes: {
40
enum: [
41
'array',
42
'boolean',
43
'integer',
44
'null',
45
'number',
46
'object',
47
'string'
48
]
49
},
50
stringArray: {
51
type: 'array',
52
items: {
53
type: 'string'
54
},
55
uniqueItems: true,
56
default: []
57
}
58
},
59
type: ['object'],
60
properties: {
61
$id: {
62
type: 'string',
63
format: 'uri-reference'
64
},
65
$schema: {
66
type: 'string',
67
format: 'uri'
68
},
69
$ref: {
70
type: 'string',
71
format: 'uri-reference'
72
},
73
$comment: {
74
type: 'string'
75
},
76
title: {
77
type: 'string'
78
},
79
description: {
80
type: 'string'
81
},
82
readOnly: {
83
type: 'boolean',
84
default: false
85
},
86
writeOnly: {
87
type: 'boolean',
88
default: false
89
},
90
multipleOf: {
91
type: 'number',
92
exclusiveMinimum: 0
93
},
94
maximum: {
95
type: 'number'
96
},
97
exclusiveMaximum: {
98
type: 'number'
99
},
100
minimum: {
101
type: 'number'
102
},
103
exclusiveMinimum: {
104
type: 'number'
105
},
106
maxLength: {
107
$ref: '#/definitions/nonNegativeInteger'
108
},
109
minLength: {
110
$ref: '#/definitions/nonNegativeIntegerDefault0'
111
},
112
pattern: {
113
type: 'string',
114
format: 'regex'
115
},
116
additionalItems: {
117
$ref: '#'
118
},
119
items: {
120
anyOf: [
121
{
122
$ref: '#'
123
},
124
{
125
$ref: '#/definitions/schemaArray'
126
}
127
],
128
default: true
129
},
130
maxItems: {
131
$ref: '#/definitions/nonNegativeInteger'
132
},
133
minItems: {
134
$ref: '#/definitions/nonNegativeIntegerDefault0'
135
},
136
uniqueItems: {
137
type: 'boolean',
138
default: false
139
},
140
contains: {
141
$ref: '#'
142
},
143
maxProperties: {
144
$ref: '#/definitions/nonNegativeInteger'
145
},
146
minProperties: {
147
$ref: '#/definitions/nonNegativeIntegerDefault0'
148
},
149
required: {
150
$ref: '#/definitions/stringArray'
151
},
152
additionalProperties: {
153
$ref: '#'
154
},
155
definitions: {
156
type: 'object',
157
additionalProperties: {
158
$ref: '#'
159
},
160
default: {}
161
},
162
properties: {
163
type: 'object',
164
additionalProperties: {
165
$ref: '#'
166
},
167
default: {}
168
},
169
patternProperties: {
170
type: 'object',
171
additionalProperties: {
172
$ref: '#'
173
},
174
propertyNames: {
175
format: 'regex'
176
},
177
default: {}
178
},
179
dependencies: {
180
type: 'object',
181
additionalProperties: {
182
anyOf: [
183
{
184
$ref: '#'
185
},
186
{
187
$ref: '#/definitions/stringArray'
188
}
189
]
190
}
191
},
192
propertyNames: {
193
$ref: '#'
194
},
195
enum: {
196
type: 'array',
197
minItems: 1,
198
uniqueItems: true
199
},
200
type: {
201
anyOf: [
202
{
203
$ref: '#/definitions/simpleTypes'
204
},
205
{
206
type: 'array',
207
items: {
208
$ref: '#/definitions/simpleTypes'
209
},
210
minItems: 1,
211
uniqueItems: true
212
}
213
]
214
},
215
format: {
216
type: 'string'
217
},
218
contentMediaType: {
219
type: 'string'
220
},
221
contentEncoding: {
222
type: 'string'
223
},
224
if: {
225
$ref: '#'
226
},
227
then: {
228
$ref: '#'
229
},
230
else: {
231
$ref: '#'
232
},
233
allOf: {
234
$ref: '#/definitions/schemaArray'
235
},
236
anyOf: {
237
$ref: '#/definitions/schemaArray'
238
},
239
oneOf: {
240
$ref: '#/definitions/schemaArray'
241
},
242
not: {
243
$ref: '#'
244
}
245
},
246
defaultSnippets: [{
247
body: {
248
type: 'object',
249
properties: {
250
'${1:paramName}': {
251
type: 'string',
252
description: '${2:description}'
253
}
254
}
255
},
256
}],
257
};
258
const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
259
contributionRegistry.registerSchema(toolsParametersSchemaSchemaId, toolsParametersSchemaSchema);
260
261