diff --git a/src/vs/workbench/contrib/chat/electron-sandbox/tools/fetchPageTool.ts b/src/vs/workbench/contrib/chat/electron-sandbox/tools/fetchPageTool.ts index b4969f303b3..f05445610f5 100644 --- a/src/vs/workbench/contrib/chat/electron-sandbox/tools/fetchPageTool.ts +++ b/src/vs/workbench/contrib/chat/electron-sandbox/tools/fetchPageTool.ts @@ -59,14 +59,14 @@ export class FetchWebPageTool implements IToolImpl { const contents = await this._readerModeService.extract(validUris); // Make an array that contains either the content or undefined for invalid URLs - const contentsWithUndefined = new Map(); + const contentsWithUndefined: (string | undefined)[] = []; let indexInContents = 0; - parsedUriResults.forEach((uri, url) => { + parsedUriResults.forEach((uri) => { if (uri) { - contentsWithUndefined.set(url, contents[indexInContents]); + contentsWithUndefined.push(contents[indexInContents]); indexInContents++; } else { - contentsWithUndefined.set(url, undefined); + contentsWithUndefined.push(undefined); } }); @@ -154,21 +154,10 @@ export class FetchWebPageTool implements IToolImpl { return results; } - private _getPromptPartsForResults(results: Map): IToolResultTextPart[] { - const arr = new Array(); - for (const [url, content] of results.entries()) { - if (content) { - arr.push({ - kind: 'text', - value: `\n\n` + content - }); - } else { - arr.push({ - kind: 'text', - value: `\n\n` + localize('fetchWebPage.invalidUrl', 'Invalid URL') - }); - } - } - return arr; + private _getPromptPartsForResults(results: (string | undefined)[]): IToolResultTextPart[] { + return results.map(value => ({ + kind: 'text', + value: value || localize('fetchWebPage.invalidUrl', 'Invalid URL') + })); } }