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