Skip to content

Commit

Permalink
move toolsParametersSchemaSchema to separate schema (#231852)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli authored Oct 22, 2024
1 parent 6c2e9ff commit 527fc2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ILogService } from '../../../../../platform/log/common/log.js';
import { IWorkbenchContribution } from '../../../../common/contributions.js';
import { ILanguageModelToolsService, IToolData } from '../languageModelToolsService.js';
import * as extensionsRegistry from '../../../../services/extensions/common/extensionsRegistry.js';
import { toolsParametersSchemaSchema } from './languageModelToolsParametersSchema.js';
import { toolsParametersSchemaSchemaId } from './languageModelToolsParametersSchema.js';

export interface IRawToolContribution {
name: string;
Expand Down Expand Up @@ -84,8 +84,8 @@ const languageModelToolsExtensionPoint = extensionsRegistry.ExtensionsRegistry.r
type: 'string'
},
parametersSchema: {
...toolsParametersSchemaSchema,
description: localize('parametersSchema', "A JSON schema for the parameters this tool accepts. The parameters must be an object at the top level. A particular language model may not support all JSON schema features. See the documentation for the language model family you are using for more information."),
$ref: toolsParametersSchemaSchemaId,
},
canBeReferencedInPrompt: {
markdownDescription: localize('canBeReferencedInPrompt', "If true, this tool shows up as an attachment that the user can add manually to their request. Chat participants will receive the tool in {0}.", '`ChatRequest#toolReferences`'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
*--------------------------------------------------------------------------------------------*/

import { IJSONSchema } from '../../../../../base/common/jsonSchema.js';
import { Extensions as JSONExtensions, IJSONContributionRegistry } from '../../../../../platform/jsonschemas/common/jsonContributionRegistry.js';
import { Registry } from '../../../../../platform/registry/common/platform.js';

/**
* A schema for parametersSchema
* 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.
* Possibly it can be whittled down some more based on which attributes are supported by language models.
*/
export const toolsParametersSchemaSchema: IJSONSchema = {
export const toolsParametersSchemaSchemaId = 'vscode://schemas/toolsParameters';
const toolsParametersSchemaSchema: IJSONSchema = {
definitions: {
schemaArray: {
type: 'array',
Expand Down Expand Up @@ -252,3 +255,5 @@ export const toolsParametersSchemaSchema: IJSONSchema = {
},
}],
};
const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
contributionRegistry.registerSchema(toolsParametersSchemaSchemaId, toolsParametersSchemaSchema);

0 comments on commit 527fc2d

Please sign in to comment.