From 826571b410691d9db838f4ffe83308c64bcd8610 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 24 May 2025 17:09:35 -0700 Subject: [PATCH] remove ToolName from extractGrammar --- .../electron-main/llmMessage/extractGrammar.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/void/electron-main/llmMessage/extractGrammar.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/extractGrammar.ts index 3f1a4224..66e16791 100644 --- a/src/vs/workbench/contrib/void/electron-main/llmMessage/extractGrammar.ts +++ b/src/vs/workbench/contrib/void/electron-main/llmMessage/extractGrammar.ts @@ -7,7 +7,7 @@ import { generateUuid } from '../../../../../base/common/uuid.js' import { endsWithAnyPrefixOf, SurroundingsRemover } from '../../common/helpers/extractCodeFromResult.js' import { availableTools, InternalToolInfo } from '../../common/prompt/prompts.js' import { OnFinalMessage, OnText, RawToolCallObj, RawToolParamsObj } from '../../common/sendLLMMessageTypes.js' -import { BuiltinToolName, BuiltinToolParamName } from '../../common/toolsServiceTypes.js' +import { ToolName, ToolParamName } from '../../common/toolsServiceTypes.js' import { ChatMode } from '../../common/voidSettingsTypes.js' @@ -165,15 +165,15 @@ const findIndexOfAny = (fullText: string, matches: string[]) => { type ToolOfToolName = { [toolName: string]: InternalToolInfo | undefined } -const parseXMLPrefixToToolCall = (toolName: BuiltinToolName, toolId: string, str: string, toolOfToolName: ToolOfToolName): RawToolCallObj => { +const parseXMLPrefixToToolCall = (toolName: T, toolId: string, str: string, toolOfToolName: ToolOfToolName): RawToolCallObj => { const paramsObj: RawToolParamsObj = {} - const doneParams: BuiltinToolParamName[] = [] + const doneParams: ToolParamName[] = [] let isDone = false const getAnswer = (): RawToolCallObj => { // trim off all whitespace at and before first \n and after last \n for each param for (const p in paramsObj) { - const paramName = p as BuiltinToolParamName + const paramName = p as ToolParamName const orig = paramsObj[paramName] if (orig === undefined) continue paramsObj[paramName] = trimBeforeAndAfterNewLines(orig) @@ -203,16 +203,16 @@ const parseXMLPrefixToToolCall = (toolName: BuiltinToolName, toolId: string, str const pm = new SurroundingsRemover(str) - const allowedParams = Object.keys(toolOfToolName[toolName]?.params ?? {}) as BuiltinToolParamName[] + const allowedParams = Object.keys(toolOfToolName[toolName]?.params ?? {}) as ToolParamName[] if (allowedParams.length === 0) return getAnswer() - let latestMatchedOpenParam: null | BuiltinToolParamName = null + let latestMatchedOpenParam: null | ToolParamName = null let n = 0 while (true) { n += 1 if (n > 10) return getAnswer() // just for good measure as this code is early // find the param name opening tag - let matchedOpenParam: null | BuiltinToolParamName = null + let matchedOpenParam: null | ToolParamName = null for (const paramName of allowedParams) { const removed = pm.removeFromStartUntilFullMatch(`<${paramName}>`, true) if (removed) { @@ -282,7 +282,7 @@ export const extractXMLToolsWrapper = ( let trueFullText = '' let latestToolCall: RawToolCallObj | undefined = undefined - let foundOpenTag: { idx: number, toolName: BuiltinToolName } | null = null + let foundOpenTag: { idx: number, toolName: ToolName } | null = null let openToolTagBuffer = '' // the characters we've seen so far that come after a < with no space afterwards, not yet added to fullText let prevFullTextLen = 0 @@ -312,7 +312,7 @@ export const extractXMLToolsWrapper = ( const i = findIndexOfAny(fullText, toolOpenTags) if (i !== null) { const [idx, toolTag] = i - const toolName = toolTag.substring(1, toolTag.length - 1) as BuiltinToolName + const toolName = toolTag.substring(1, toolTag.length - 1) as ToolName // console.log('found ', toolName) foundOpenTag = { idx, toolName }