Skip to content

Commit 935a430

Browse files
jriekenjoaomoreno
andauthored
tool set tweaks (microsoft#249952)
* tweak tool set template * tweak tool set tools enum configuration Co-authored-by: João Moreno <[email protected]>
1 parent 40e1b40 commit 935a430

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.ts

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { IExtensionService } from '../../../../services/extensions/common/extens
2424
import { ILifecycleService, LifecyclePhase } from '../../../../services/lifecycle/common/lifecycle.js';
2525
import { IUserDataProfileService } from '../../../../services/userDataProfile/common/userDataProfile.js';
2626
import { CHAT_CATEGORY } from '../actions/chatActions.js';
27-
import { ILanguageModelToolsService, IToolData, ToolSet } from '../../common/languageModelToolsService.js';
27+
import { ILanguageModelToolsService, IToolData, ToolDataSource, ToolSet } from '../../common/languageModelToolsService.js';
2828
import { IRawToolSetContribution } from '../../common/tools/languageModelToolsContribution.js';
2929
import { IEditorService } from '../../../../services/editor/common/editorService.js';
3030
import { Codicon, getAllCodicons } from '../../../../../base/common/codicons.js';
@@ -46,7 +46,7 @@ const toolSetsSchema: IJSONSchema = {
4646
allowTrailingCommas: true,
4747
defaultSnippets: [{
4848
label: localize('schema.default', "Empty tool set"),
49-
body: { '${1:toolSetName}': { 'tools': ['${2:toolName}'], 'description': '${3:description}', 'icon': '${4:$(tools)}' } }
49+
body: { '${1:toolSetName}': { 'tools': ['${2:someTool}', '${3:anotherTool}'], 'description': '${4:description}', 'icon': '${5:tools}' } }
5050
}],
5151
type: 'object',
5252
description: localize('toolsetSchema.json', 'User tool sets configuration'),
@@ -150,19 +150,52 @@ export class UserToolSetsContributions extends Disposable implements IWorkbenchC
150150
const tools = toolsObs.read(r);
151151
const toolSets = this._languageModelToolsService.toolSets.read(r);
152152

153-
toolEnumValues.length = 0;
154-
toolEnumDescriptions.length = 0;
155153

154+
type ToolDesc = {
155+
name: string;
156+
sourceLabel: string;
157+
sourceOrdinal: number;
158+
description: string;
159+
};
160+
161+
const data: ToolDesc[] = [];
156162
for (const tool of tools) {
157-
if (tool.toolReferenceName && tool.canBeReferencedInPrompt) {
158-
toolEnumValues.push(tool.toolReferenceName);
159-
toolEnumDescriptions.push(localize('tooldesc', "{0} - {1}", tool.source.label, tool.userDescription ?? tool.modelDescription));
163+
if (tool.canBeReferencedInPrompt) {
164+
data.push({
165+
name: tool.toolReferenceName ?? tool.displayName,
166+
sourceLabel: ToolDataSource.classify(tool.source).label,
167+
sourceOrdinal: ToolDataSource.classify(tool.source).ordinal,
168+
description: tool.userDescription ?? tool.modelDescription
169+
});
160170
}
161171
}
162172
for (const toolSet of toolSets) {
163-
toolEnumValues.push(toolSet.toolReferenceName);
164-
toolEnumDescriptions.push(localize('toolsetdesc', "{0} - {1}", toolSet.source.label, toolSet.description ?? toolSet.displayName ?? ''));
173+
data.push({
174+
name: toolSet.toolReferenceName,
175+
sourceLabel: ToolDataSource.classify(toolSet.source).label,
176+
sourceOrdinal: ToolDataSource.classify(toolSet.source).ordinal,
177+
description: toolSet.description ?? toolSet.displayName
178+
});
179+
}
180+
181+
toolEnumValues.length = 0;
182+
toolEnumDescriptions.length = 0;
183+
184+
data.sort((a, b) => {
185+
if (a.sourceOrdinal !== b.sourceOrdinal) {
186+
return a.sourceOrdinal - b.sourceOrdinal;
187+
}
188+
if (a.sourceLabel !== b.sourceLabel) {
189+
return a.sourceLabel.localeCompare(b.sourceLabel);
190+
}
191+
return a.name.localeCompare(b.name);
192+
});
193+
194+
for (const item of data) {
195+
toolEnumValues.push(item.name);
196+
toolEnumDescriptions.push(localize('tool.description', "{1} ({0})\n\n{2}", item.sourceLabel, item.name, item.description));
165197
}
198+
166199
store.clear(); // reset old schema
167200
reg.registerSchema(toolSetSchemaId, toolSetsSchema, store);
168201
}));
@@ -364,10 +397,11 @@ export class ConfigureToolSets extends Action2 {
364397
'// {',
365398
'// \t"toolSetName": {',
366399
'// \t\t"tools": [',
367-
'// \t\t\t"toolName"',
400+
'// \t\t\t"someTool",',
401+
'// \t\t\t"anotherTool"',
368402
'// \t\t],',
369403
'// \t\t"description": "description",',
370-
'// \t\t"icon": "$(tools)"',
404+
'// \t\t"icon": "tools"',
371405
'// \t}',
372406
'// }',
373407
].join('\n'));

0 commit comments

Comments
 (0)