Skip to content

Commit 9102c10

Browse files
authored
Only have ToolSet#referenceName but no more displayName and toolReferenceName (microsoft#250294)
* use `toolReferenceName` for tool sets fixes microsoft#250254 * Only have `ToolSet#referenceName` but no more displayName and toolReferenceName re microsoft#250254
1 parent 8c6a304 commit 9102c10

File tree

11 files changed

+40
-35
lines changed

11 files changed

+40
-35
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class ToolsContextPickerPick implements IChatContextPickerItem {
7878
if (entry instanceof ToolSet) {
7979
items.push({
8080
toolInfo: ToolDataSource.classify(entry.source),
81-
label: entry.toolReferenceName,
81+
label: entry.referenceName,
8282
description: entry.description,
8383
asAttachment: (): IChatRequestToolSetEntry => {
8484
return {
8585
kind: 'toolset',
8686
id: entry.id,
8787
icon: entry.icon,
88-
name: entry.displayName,
88+
name: entry.referenceName,
8989
value: undefined,
9090
};
9191
}

src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export async function showToolsPicker(
194194
type: 'item',
195195
picked,
196196
toolset: toolSetOrTool,
197-
label: toolSetOrTool.toolReferenceName,
197+
label: toolSetOrTool.referenceName,
198198
description: toolSetOrTool.description,
199199
indented: true,
200200
buttons

src/vs/workbench/contrib/chat/browser/chatAttachmentWidgets.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ export class ToolSetOrToolItemAttachmentWidget extends AbstractChatAttachmentWid
491491
let name = attachment.name;
492492
const icon = attachment.icon ?? Codicon.tools;
493493

494-
if (toolOrToolSet) {
494+
if (toolOrToolSet instanceof ToolSet) {
495+
name = toolOrToolSet.referenceName;
496+
} else if (toolOrToolSet) {
495497
name = toolOrToolSet.toolReferenceName ?? name;
496498
}
497499

@@ -503,7 +505,7 @@ export class ToolSetOrToolItemAttachmentWidget extends AbstractChatAttachmentWid
503505
let hoverContent: string | undefined;
504506

505507
if (toolOrToolSet instanceof ToolSet) {
506-
hoverContent = localize('toolset', "{0} - {1}", toolOrToolSet.description ?? toolOrToolSet.displayName, toolOrToolSet.source.label);
508+
hoverContent = localize('toolset', "{0} - {1}", toolOrToolSet.description ?? toolOrToolSet.referenceName, toolOrToolSet.source.label);
507509
} else if (toolOrToolSet) {
508510
hoverContent = localize('tool', "{0} - {1}", toolOrToolSet.userDescription ?? toolOrToolSet.modelDescription, toolOrToolSet.source.label);
509511
}

src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,21 +1124,24 @@ class ToolCompletions extends Disposable {
11241124

11251125
for (const item of iter) {
11261126

1127-
if (usedNames.has(item.toolReferenceName ?? '')) {
1128-
continue;
1129-
}
1130-
11311127
let detail: string | undefined;
11321128

1129+
let name: string;
11331130
if (item instanceof ToolSet) {
11341131
detail = item.description;
1132+
name = item.referenceName;
11351133

11361134
} else {
11371135
const source = item.source;
11381136
detail = localize('tool_source_completion', "{0}: {1}", source.label, item.displayName);
1137+
name = item.toolReferenceName ?? item.displayName;
1138+
}
1139+
1140+
if (usedNames.has(name)) {
1141+
continue;
11391142
}
11401143

1141-
const withLeader = `${chatVariableLeader}${item.toolReferenceName ?? item.displayName}`;
1144+
const withLeader = `${chatVariableLeader}${name}`;
11421145
suggestions.push({
11431146
label: withLeader,
11441147
range,

src/vs/workbench/contrib/chat/browser/languageModelToolsService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
467467
}
468468

469469
for (const toolSet of this._toolSets) {
470-
if (toolOrToolset.has(toolSet.toolReferenceName)) {
471-
result[toolSet.toolReferenceName] = true;
470+
if (toolOrToolset.has(toolSet.referenceName)) {
471+
result[toolSet.referenceName] = true;
472472
}
473473
for (const tool of toolSet.getTools()) {
474474
if (toolOrToolset.has(tool.id)) {
@@ -486,14 +486,14 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
486486

487487
getToolSetByName(name: string): ToolSet | undefined {
488488
for (const toolSet of this._toolSets) {
489-
if (toolSet.toolReferenceName === name) {
489+
if (toolSet.referenceName === name) {
490490
return toolSet;
491491
}
492492
}
493493
return undefined;
494494
}
495495

496-
createToolSet(source: ToolDataSource, id: string, displayName: string, options?: { icon?: ThemeIcon; toolReferenceName?: string; description?: string }): ToolSet & IDisposable {
496+
createToolSet(source: ToolDataSource, id: string, referenceName: string, options?: { icon?: ThemeIcon; description?: string }): ToolSet & IDisposable {
497497

498498
const that = this;
499499

@@ -505,7 +505,7 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
505505
}
506506

507507
}
508-
}(id, displayName, options?.icon ?? Codicon.tools, source, options?.toolReferenceName ?? displayName, options?.description);
508+
}(id, referenceName, options?.icon ?? Codicon.tools, source, options?.description);
509509

510510
this._toolSets.add(result);
511511
return result;

src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class PromptToolsCodeLensProvider extends Disposable implements CodeLensProvider
8585
selectedToolsNow.set(tool, toolNames.has(tool.toolReferenceName ?? tool.displayName));
8686
}
8787
for (const toolSet of this.languageModelToolsService.toolSets.get()) {
88-
selectedToolsNow.set(toolSet, toolNames.has(toolSet.toolReferenceName));
88+
selectedToolsNow.set(toolSet, toolNames.has(toolSet.referenceName));
8989
}
9090

9191
const newSelectedAfter = await this.instantiationService.invokeFunction(showToolsPicker, localize('placeholder', "Select tools"), selectedToolsNow);
@@ -96,7 +96,11 @@ class PromptToolsCodeLensProvider extends Disposable implements CodeLensProvider
9696
const newToolNames: string[] = [];
9797
for (const [item, picked] of newSelectedAfter) {
9898
if (picked) {
99-
newToolNames.push(item.toolReferenceName ?? item.displayName);
99+
if (item instanceof ToolSet) {
100+
newToolNames.push(item.referenceName);
101+
} else {
102+
newToolNames.push(item.toolReferenceName ?? item.displayName);
103+
}
100104
}
101105
}
102106

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ abstract class RawToolSetsShape {
109109
map.set(name, {
110110
name,
111111
tools: value.tools,
112-
referenceName: value.referenceName,
113112
description: value.description,
114113
icon: value.icon,
115114
});
@@ -155,7 +154,7 @@ export class UserToolSetsContributions extends Disposable implements IWorkbenchC
155154
name: string;
156155
sourceLabel: string;
157156
sourceOrdinal: number;
158-
description: string;
157+
description?: string;
159158
};
160159

161160
const data: ToolDesc[] = [];
@@ -171,10 +170,10 @@ export class UserToolSetsContributions extends Disposable implements IWorkbenchC
171170
}
172171
for (const toolSet of toolSets) {
173172
data.push({
174-
name: toolSet.toolReferenceName,
173+
name: toolSet.referenceName,
175174
sourceLabel: ToolDataSource.classify(toolSet.source).label,
176175
sourceOrdinal: ToolDataSource.classify(toolSet.source).ordinal,
177-
description: toolSet.description ?? toolSet.displayName
176+
description: toolSet.description
178177
});
179178
}
180179

@@ -340,7 +339,7 @@ export class ConfigureToolSets extends Action2 {
340339
}
341340

342341
picks.push({
343-
label: toolSet.displayName,
342+
label: toolSet.referenceName,
344343
toolset: toolSet,
345344
tooltip: toolSet.description,
346345
iconClass: ThemeIcon.asClassName(toolSet.icon)

src/vs/workbench/contrib/chat/common/chatRequestParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ChatRequestParser {
4040
.map(t => [t.toolReferenceName!, t]));
4141

4242
const toolSetsByName = new Map<string, ToolSet>(this.variableService.getSelectedToolSets(sessionId)
43-
.map(t => [t.displayName, t]));
43+
.map(t => [t.referenceName, t]));
4444

4545
let lineNumber = 1;
4646
let column = 1;
@@ -165,7 +165,7 @@ export class ChatRequestParser {
165165

166166
const toolset = toolSetsByName.get(name);
167167
if (toolset) {
168-
return new ChatRequestToolSetPart(varRange, varEditorRange, toolset.id, toolset.displayName, toolset.icon);
168+
return new ChatRequestToolSetPart(varRange, varEditorRange, toolset.id, toolset.referenceName, toolset.icon);
169169
}
170170

171171
return;

src/vs/workbench/contrib/chat/common/languageModelToolsService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ export class ToolSet {
200200

201201
constructor(
202202
readonly id: string,
203-
readonly displayName: string,
203+
readonly referenceName: string,
204204
readonly icon: ThemeIcon,
205205
readonly source: ToolDataSource,
206-
readonly toolReferenceName: string,
207206
readonly description?: string,
208207
) {
209208

@@ -259,7 +258,7 @@ export interface ILanguageModelToolsService {
259258

260259
readonly toolSets: IObservable<Iterable<ToolSet>>;
261260
getToolSetByName(name: string): ToolSet | undefined;
262-
createToolSet(source: ToolDataSource, id: string, displayName: string, options?: { icon?: ThemeIcon; toolReferenceName?: string; description?: string }): ToolSet & IDisposable;
261+
createToolSet(source: ToolDataSource, id: string, referenceName: string, options?: { icon?: ThemeIcon; description?: string }): ToolSet & IDisposable;
263262
}
264263

265264
export function createToolInputUri(toolOrId: IToolData | string): URI {

src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ const languageModelToolsExtensionPoint = extensionsRegistry.ExtensionsRegistry.r
136136

137137
export interface IRawToolSetContribution {
138138
name: string;
139+
/**
140+
* @deprecated
141+
*/
139142
referenceName?: string;
140143
description: string;
141144
icon?: string;
@@ -161,11 +164,7 @@ const languageModelToolSetsExtensionPoint = extensionsRegistry.ExtensionsRegistr
161164
required: ['name', 'description', 'tools'],
162165
properties: {
163166
name: {
164-
description: localize('toolSetName', "A name for this tool set."),
165-
type: 'string',
166-
},
167-
referenceName: {
168-
description: localize('toolSetReferenceName', "A name that users can use to reference this tool set. Name must not contain whitespace."),
167+
description: localize('toolSetName', "A name for this tool set. Used as reference and should not contain white."),
169168
type: 'string',
170169
pattern: '^[\\w-]+$'
171170
},
@@ -339,8 +338,8 @@ export class LanguageModelToolsExtensionPointHandler implements IWorkbenchContri
339338
const obj = languageModelToolsService.createToolSet(
340339
source,
341340
toToolSetKey(extension.description.identifier, toolSet.name),
342-
toolSet.name,
343-
{ icon: toolSet.icon ? ThemeIcon.fromString(toolSet.icon) : undefined, toolReferenceName: toolSet.referenceName, description: toolSet.description }
341+
toolSet.referenceName ?? toolSet.name,
342+
{ icon: toolSet.icon ? ThemeIcon.fromString(toolSet.icon) : undefined, description: toolSet.description }
344343
);
345344

346345
transaction(tx => {

0 commit comments

Comments
 (0)