From 18b278577d5776f5f4dc2e1261926292e14deb8d Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 8 Feb 2025 21:17:38 -0800 Subject: [PATCH 01/17] tools --- .../platform/void/common/voidSettingsTypes.ts | 2 +- .../void/electron-main/llmMessage/greptile.ts | 68 ----------- .../void/electron-main/llmMessage/openai.ts | 5 +- .../void/electron-main/llmMessageChannel.ts | 2 +- .../void/electron-main/templates/templates.ts | 12 ++ .../void/electron-main/templates/tools.ts | 111 ++++++++++++++++++ 6 files changed, 129 insertions(+), 71 deletions(-) delete mode 100644 src/vs/platform/void/electron-main/llmMessage/greptile.ts create mode 100644 src/vs/platform/void/electron-main/templates/templates.ts create mode 100644 src/vs/platform/void/electron-main/templates/tools.ts diff --git a/src/vs/platform/void/common/voidSettingsTypes.ts b/src/vs/platform/void/common/voidSettingsTypes.ts index c9eadefd..0a5bdc64 100644 --- a/src/vs/platform/void/common/voidSettingsTypes.ts +++ b/src/vs/platform/void/common/voidSettingsTypes.ts @@ -253,7 +253,7 @@ export const displayInfoOfProviderName = (providerName: ProviderName): DisplayIn } else if (providerName === 'groq') { return { - title: 'Groq API', + title: 'Groq.com API', } } else if (providerName === 'mistral') { diff --git a/src/vs/platform/void/electron-main/llmMessage/greptile.ts b/src/vs/platform/void/electron-main/llmMessage/greptile.ts deleted file mode 100644 index f61f87af..00000000 --- a/src/vs/platform/void/electron-main/llmMessage/greptile.ts +++ /dev/null @@ -1,68 +0,0 @@ -/*-------------------------------------------------------------------------------------- - * Copyright 2025 Glass Devtools, Inc. All rights reserved. - * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. - *--------------------------------------------------------------------------------------*/ - -// // Greptile -// // https://docs.greptile.com/api-reference/query -// // https://docs.greptile.com/quickstart#sample-response-streamed - -// import { SendLLMMessageFnTypeInternal } from '../../common/llmMessageTypes.js'; - -// export const sendGreptileMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinalMessage, onError, settingsOfProvider, _setAborter }) => { - -// let fullText = '' - -// const thisConfig = settingsOfProvider.greptile - -// fetch('https://api.greptile.com/v2/query', { -// method: 'POST', -// headers: { -// 'Authorization': `Bearer ${thisConfig.apikey}`, -// 'X-Github-Token': `${thisConfig.githubPAT}`, -// 'Content-Type': `application/json`, -// }, -// body: JSON.stringify({ -// messages, -// stream: true, -// repositories: [thisConfig.repoinfo], -// }), -// }) -// // this is {message}\n{message}\n{message}...\n -// .then(async response => { -// const text = await response.text() -// console.log('got greptile', text) -// return JSON.parse(`[${text.trim().split('\n').join(',')}]`) -// }) -// // TODO make this actually stream, right now it just sends one message at the end -// // TODO add _setAborter() when add streaming -// .then(async responseArr => { - -// for (const response of responseArr) { -// const type: string = response['type'] -// const message = response['message'] - -// // when receive text -// if (type === 'message') { -// fullText += message -// onText({ newText: message, fullText }) -// } -// else if (type === 'sources') { -// const { filepath, linestart: _, lineend: _2 } = message as { filepath: string; linestart: number | null; lineend: number | null } -// fullText += filepath -// onText({ newText: filepath, fullText }) -// } -// // type: 'status' with an empty 'message' means last message -// else if (type === 'status') { -// if (!message) { -// onFinalMessage({ fullText }) -// } -// } -// } - -// }) -// .catch(error => { -// onError({ error }) -// }); - -// } diff --git a/src/vs/platform/void/electron-main/llmMessage/openai.ts b/src/vs/platform/void/electron-main/llmMessage/openai.ts index 268eadfb..8fd49684 100644 --- a/src/vs/platform/void/electron-main/llmMessage/openai.ts +++ b/src/vs/platform/void/electron-main/llmMessage/openai.ts @@ -9,7 +9,11 @@ import { Model } from 'openai/resources/models.js'; // import { parseMaxTokensStr } from './util.js'; +// https://cdn.openai.com/spec/model-spec-2024-05-08.html#follow-the-chain-of-command +// https://platform.openai.com/docs/guides/reasoning#advice-on-prompting + +// might not currently be used in the code export const openaiCompatibleList: _InternalModelListFnType = async ({ onSuccess: onSuccess_, onError: onError_, settingsOfProvider }) => { const onSuccess = ({ models }: { models: Model[] }) => { onSuccess_({ models }) @@ -116,7 +120,6 @@ export const sendOpenAIChat: _InternalSendLLMChatMessageFnType = ({ messages, on model: modelName, messages: messages, stream: true, - // max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens) } openai.chat.completions diff --git a/src/vs/platform/void/electron-main/llmMessageChannel.ts b/src/vs/platform/void/electron-main/llmMessageChannel.ts index 2c44e2ec..3575e34e 100644 --- a/src/vs/platform/void/electron-main/llmMessageChannel.ts +++ b/src/vs/platform/void/electron-main/llmMessageChannel.ts @@ -66,7 +66,7 @@ export class LLMMessageChannel implements IServerChannel { } } - // browser uses this to call + // browser uses this to call (see this.channel.call() in llmMessageService.ts for all usages) async call(_: unknown, command: string, params: any): Promise { try { if (command === 'sendLLMMessage') { diff --git a/src/vs/platform/void/electron-main/templates/templates.ts b/src/vs/platform/void/electron-main/templates/templates.ts new file mode 100644 index 00000000..0f74197e --- /dev/null +++ b/src/vs/platform/void/electron-main/templates/templates.ts @@ -0,0 +1,12 @@ +/* + +modelName -> { + system_message_type: 'system' | 'developer' (openai) | null // if null, we will just do a string of system message + supports_tools: boolean // we will just do a string of tool use if it doesn't support + supports_autocomplete_FIM (suffix) // we will just do a description of FIM if it doens't support <|fim_hole|> + max_tokens + + +} + +*/ diff --git a/src/vs/platform/void/electron-main/templates/tools.ts b/src/vs/platform/void/electron-main/templates/tools.ts new file mode 100644 index 00000000..70c250e6 --- /dev/null +++ b/src/vs/platform/void/electron-main/templates/tools.ts @@ -0,0 +1,111 @@ + +import Anthropic from '@anthropic-ai/sdk' +import OpenAI from 'openai' + +const pagination = { + desc: `Very large results may be paginated (indicated in the result). Pagination fails gracefully if out of bounds or invalid page number.`, + param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } +} as const + +// we do this using Anthropic's style and convert to OpenAI style later +type InternalToolInfo = { + description: string, + params: { + [paramName: string]: { type: string, description: string | undefined } // name -> type + }, + required: string[], // required paramNames +} +const contextTools = { + read_file: { + description: 'Returns file contents of a given URI.', + params: { + uri: { type: 'string', description: undefined }, + }, + required: ['uri'], + }, + + list_dir: { + description: `Returns all file names and folder names in a given URI. ${pagination.desc}`, + params: { + uri: { type: 'string', description: undefined }, + ...pagination.param + }, + required: ['uri'], + }, + + pathname_search: { + description: `Returns all pathnames that match a given grep query. You should use this when looking for a file with a specific name or path. This does NOT search file content. ${pagination.desc}`, + params: { + query: { type: 'string', description: undefined }, + ...pagination.param, + }, + required: ['query'] + }, + + grep_search: { + description: `Returns all code excerpts containing the given string or grep query. Does not search filename. As a follow-up, you may want to use read_file to view the full file contents of the results. ${pagination.desc}`, + params: { + query: { type: 'string', description: undefined }, + ...pagination.param, + }, + required: ['query'], + }, + + // semantic_search: { + // description: 'Searches files semantically for the given string query.', + // // RAG + // }, + +} as const satisfies { [name: string]: InternalToolInfo } + +type ContextToolName = keyof typeof contextTools +type ContextParams = keyof typeof contextTools[T]['params'] + +const contextFunctions: { [ToolName in ContextToolName]: (p: ({ [paramName in ContextParams]: string })) => string } = { + read_file: ({ uri }) => { + return '' + }, + list_dir: ({ }) => { + return '' + }, + pathname_search: ({ }) => { + return '' + }, + grep_search: ({ }) => { + return '' + }, + +} + + + +const toOpenAITool = (toolName: string, toolInfo: InternalToolInfo) => { + const { description, params, required } = toolInfo + return { + type: 'function', + function: { + name: toolName, + description: description, + parameters: { + type: 'object', + properties: params, + required: required, + } + } + } satisfies OpenAI.Chat.Completions.ChatCompletionTool +} + + + +const toAnthropicTool = (toolName: string, toolInfo: InternalToolInfo) => { + const { description, params, required } = toolInfo + return { + name: toolName, + description: description, + input_schema: { + type: 'object', + properties: params, + required: required, + } + } satisfies Anthropic.Messages.Tool +} From 00da05f24f7a5d5d95191d7f8dcabbf51abf136f Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 8 Feb 2025 22:53:13 -0800 Subject: [PATCH 02/17] context tools --- src/vs/platform/void/common/toolsService.ts | 193 ++++++++++++++++++ .../electron-main/llmMessage/anthropic.ts | 21 ++ .../void/electron-main/llmMessage/openai.ts | 26 ++- .../void/electron-main/templates/tools.ts | 111 ---------- .../contrib/void/browser/prompt/prompts.ts | 4 +- 5 files changed, 240 insertions(+), 115 deletions(-) create mode 100644 src/vs/platform/void/common/toolsService.ts delete mode 100644 src/vs/platform/void/electron-main/templates/tools.ts diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts new file mode 100644 index 00000000..6e87e974 --- /dev/null +++ b/src/vs/platform/void/common/toolsService.ts @@ -0,0 +1,193 @@ +import { URI } from '../../../base/common/uri' +import { IModelService } from '../../../editor/common/services/model' +import { VSReadFile } from '../../../workbench/contrib/void/browser/helpers/readFile' +import { IFileService, IFileStat } from '../../files/common/files' +import { registerSingleton, InstantiationType } from '../../instantiation/common/extensions' +import { createDecorator } from '../../instantiation/common/instantiation' + + +const pagination = { + desc: `Very large results may be paginated (indicated in the result). Pagination fails gracefully if out of bounds or invalid page number.`, + param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } +} as const + + + +// we do this using Anthropic's style and convert to OpenAI style later +export type InternalToolInfo = { + description: string, + params: { + [paramName: string]: { type: string, description: string | undefined } // name -> type + }, + required: string[], // required paramNames +} +const contextTools = { + read_file: { + description: 'Returns file contents of a given URI.', + params: { + uri: { type: 'string', description: undefined }, + }, + required: ['uri'], + }, + + list_dir: { + description: `Returns all file names and folder names in a given URI. ${pagination.desc}`, + params: { + uri: { type: 'string', description: undefined }, + ...pagination.param + }, + required: ['uri'], + }, + + pathname_search: { + description: `Returns all pathnames that match a given grep query. You should use this when looking for a file with a specific name or path. This does NOT search file content. ${pagination.desc}`, + params: { + query: { type: 'string', description: undefined }, + ...pagination.param, + }, + required: ['query'] + }, + + grep_search: { + description: `Returns all code excerpts containing the given string or grep query. Does not search filename. As a follow-up, you may want to use read_file to view the full file contents of the results. ${pagination.desc}`, + params: { + query: { type: 'string', description: undefined }, + ...pagination.param, + }, + required: ['query'], + }, + + // semantic_search: { + // description: 'Searches files semantically for the given string query.', + // // RAG + // }, + +} as const satisfies { [name: string]: InternalToolInfo } + +type ContextToolName = keyof typeof contextTools +type ContextParamNames = keyof typeof contextTools[T]['params'] +type ContextParams = { [paramName in ContextParamNames]: string } + +type ContextToolCallFns = { + [ToolName in ContextToolName]: ((p: (ContextParams)) => Promise) +} + + + + + + + + +/* +Generates something that looks like this: + ++ folder1 +│ ├── file1.py +│ ├── subfolder1 +│ │ ├── file1.json +│ │ └── file2.py +│ └── another_file.txt +└── folder2 + ├── script.js + └── styles.css +*/ + + +/** + * Generates a Markdown tree starting at the given URI. + * The root folder is printed as a header (without a bullet). + */ +export async function generateMarkdownTree(fileService: IFileService, uri: URI): Promise { + + let output = '' + + function traverseChildren(children: IFileStat[], depth: number) { + const indentation = ' '.repeat(depth); + for (const child of children) { + output += `${indentation}- ${child.name}\n`; + output += traverseChildren(child.children ?? [], depth + 1); + } + } + const stat = await fileService.resolve(uri, { resolveMetadata: false }); + + // kickstart recursion + output += `${stat.name}\n`; + traverseChildren(stat.children ?? [], 1); + + return output; +} + + +const validateURI = (uriStr: unknown) => { + if (typeof uriStr !== 'string') throw new Error('(uri was not a string)') + console.log('uriStr!!!!', uriStr) + const uri = URI.file(uriStr) + console.log('uri!!!!', uri) + return uri +} + + + + + + + + + + + + + + + + +export interface IToolService { + readonly _serviceBrand: undefined; + callContextTool: (toolName: T, params: ContextParams) => Promise +} + +export const IToolService = createDecorator('ToolService'); + + +// implemented by calling channel +export class ToolService implements IToolService { + + readonly _serviceBrand: undefined; + + contextToolCallFns: ContextToolCallFns + + constructor( + @IFileService fileService: IFileService, + @IModelService modelService: IModelService, + ) { + this.contextToolCallFns = { + read_file: async ({ uri: uriStr }) => { + const uri = validateURI(uriStr) + const fileContents = await VSReadFile(modelService, uri) + return fileContents ?? '(could not read file)' + }, + list_dir: async ({ uri: uriStr }) => { + const uri = validateURI(uriStr) + const treeStr = await generateMarkdownTree(fileService, uri) + return treeStr + }, + pathname_search: async ({ query }) => { + return '' + }, + grep_search: async ({ query }) => { + return '' + }, + + } + } + + callContextTool: IToolService['callContextTool'] = (toolName, params) => { + return this.contextToolCallFns[toolName](params) + } + + +} + +registerSingleton(IToolService, ToolService, InstantiationType.Eager); + diff --git a/src/vs/platform/void/electron-main/llmMessage/anthropic.ts b/src/vs/platform/void/electron-main/llmMessage/anthropic.ts index ea220eed..91461b16 100644 --- a/src/vs/platform/void/electron-main/llmMessage/anthropic.ts +++ b/src/vs/platform/void/electron-main/llmMessage/anthropic.ts @@ -6,6 +6,27 @@ import Anthropic from '@anthropic-ai/sdk'; import { _InternalSendLLMChatMessageFnType } from '../../common/llmMessageTypes.js'; import { anthropicMaxPossibleTokens } from '../../common/voidSettingsTypes.js'; +import { InternalToolInfo } from '../../common/toolsService.js'; + + + + +export const toAnthropicTool = (toolName: string, toolInfo: InternalToolInfo) => { + const { description, params, required } = toolInfo + return { + name: toolName, + description: description, + input_schema: { + type: 'object', + properties: params, + required: required, + } + } satisfies Anthropic.Messages.Tool +} + + + + export const sendAnthropicChat: _InternalSendLLMChatMessageFnType = ({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter }) => { diff --git a/src/vs/platform/void/electron-main/llmMessage/openai.ts b/src/vs/platform/void/electron-main/llmMessage/openai.ts index 8fd49684..3a3c4818 100644 --- a/src/vs/platform/void/electron-main/llmMessage/openai.ts +++ b/src/vs/platform/void/electron-main/llmMessage/openai.ts @@ -6,11 +6,33 @@ import OpenAI from 'openai'; import { _InternalModelListFnType, _InternalSendLLMFIMMessageFnType, _InternalSendLLMChatMessageFnType } from '../../common/llmMessageTypes.js'; import { Model } from 'openai/resources/models.js'; +import { InternalToolInfo } from '../../common/toolsService.js'; // import { parseMaxTokensStr } from './util.js'; -// https://cdn.openai.com/spec/model-spec-2024-05-08.html#follow-the-chain-of-command -// https://platform.openai.com/docs/guides/reasoning#advice-on-prompting +// developer command - https://cdn.openai.com/spec/model-spec-2024-05-08.html#follow-the-chain-of-command +// prompting - https://platform.openai.com/docs/guides/reasoning#advice-on-prompting + + +export const toOpenAITool = (toolName: string, toolInfo: InternalToolInfo) => { + const { description, params, required } = toolInfo + return { + type: 'function', + function: { + name: toolName, + description: description, + parameters: { + type: 'object', + properties: params, + required: required, + } + } + } satisfies OpenAI.Chat.Completions.ChatCompletionTool +} + + + + // might not currently be used in the code diff --git a/src/vs/platform/void/electron-main/templates/tools.ts b/src/vs/platform/void/electron-main/templates/tools.ts deleted file mode 100644 index 70c250e6..00000000 --- a/src/vs/platform/void/electron-main/templates/tools.ts +++ /dev/null @@ -1,111 +0,0 @@ - -import Anthropic from '@anthropic-ai/sdk' -import OpenAI from 'openai' - -const pagination = { - desc: `Very large results may be paginated (indicated in the result). Pagination fails gracefully if out of bounds or invalid page number.`, - param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } -} as const - -// we do this using Anthropic's style and convert to OpenAI style later -type InternalToolInfo = { - description: string, - params: { - [paramName: string]: { type: string, description: string | undefined } // name -> type - }, - required: string[], // required paramNames -} -const contextTools = { - read_file: { - description: 'Returns file contents of a given URI.', - params: { - uri: { type: 'string', description: undefined }, - }, - required: ['uri'], - }, - - list_dir: { - description: `Returns all file names and folder names in a given URI. ${pagination.desc}`, - params: { - uri: { type: 'string', description: undefined }, - ...pagination.param - }, - required: ['uri'], - }, - - pathname_search: { - description: `Returns all pathnames that match a given grep query. You should use this when looking for a file with a specific name or path. This does NOT search file content. ${pagination.desc}`, - params: { - query: { type: 'string', description: undefined }, - ...pagination.param, - }, - required: ['query'] - }, - - grep_search: { - description: `Returns all code excerpts containing the given string or grep query. Does not search filename. As a follow-up, you may want to use read_file to view the full file contents of the results. ${pagination.desc}`, - params: { - query: { type: 'string', description: undefined }, - ...pagination.param, - }, - required: ['query'], - }, - - // semantic_search: { - // description: 'Searches files semantically for the given string query.', - // // RAG - // }, - -} as const satisfies { [name: string]: InternalToolInfo } - -type ContextToolName = keyof typeof contextTools -type ContextParams = keyof typeof contextTools[T]['params'] - -const contextFunctions: { [ToolName in ContextToolName]: (p: ({ [paramName in ContextParams]: string })) => string } = { - read_file: ({ uri }) => { - return '' - }, - list_dir: ({ }) => { - return '' - }, - pathname_search: ({ }) => { - return '' - }, - grep_search: ({ }) => { - return '' - }, - -} - - - -const toOpenAITool = (toolName: string, toolInfo: InternalToolInfo) => { - const { description, params, required } = toolInfo - return { - type: 'function', - function: { - name: toolName, - description: description, - parameters: { - type: 'object', - properties: params, - required: required, - } - } - } satisfies OpenAI.Chat.Completions.ChatCompletionTool -} - - - -const toAnthropicTool = (toolName: string, toolInfo: InternalToolInfo) => { - const { description, params, required } = toolInfo - return { - name: toolName, - description: description, - input_schema: { - type: 'object', - properties: params, - required: required, - } - } satisfies Anthropic.Messages.Tool -} diff --git a/src/vs/workbench/contrib/void/browser/prompt/prompts.ts b/src/vs/workbench/contrib/void/browser/prompt/prompts.ts index 7dc23d53..468de855 100644 --- a/src/vs/workbench/contrib/void/browser/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/browser/prompt/prompts.ts @@ -133,8 +133,8 @@ Store Result: After computing fib(n), the result is stored in memo for future re ` -type FileSelnLocal = FileSelection & { content: string } -const stringifyFileSelection = ({ fileURI, selectionStr, range, content }: FileSelnLocal) => { +type FileSelnLocal = { fileURI: URI, content: string } +const stringifyFileSelection = ({ fileURI, content }: FileSelnLocal) => { return `\ ${fileURI.fsPath} \`\`\`${filenameToVscodeLanguage(fileURI.fsPath) ?? ''} From d3e73b92e0e1d4bcf3393509923c931b75eb2dec Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 8 Feb 2025 22:56:55 -0800 Subject: [PATCH 03/17] + --- src/vs/platform/void/common/toolsService.ts | 27 +++------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index 6e87e974..77666b84 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -49,7 +49,7 @@ const contextTools = { }, grep_search: { - description: `Returns all code excerpts containing the given string or grep query. Does not search filename. As a follow-up, you may want to use read_file to view the full file contents of the results. ${pagination.desc}`, + description: `Returns all code excerpts containing the given string or grep query. This does NOT search pathname. As a follow-up, you may want to use read_file to view the full file contents of the results. ${pagination.desc}`, params: { query: { type: 'string', description: undefined }, ...pagination.param, @@ -79,26 +79,7 @@ type ContextToolCallFns = { -/* -Generates something that looks like this: - -+ folder1 -│ ├── file1.py -│ ├── subfolder1 -│ │ ├── file1.json -│ │ └── file2.py -│ └── another_file.txt -└── folder2 - ├── script.js - └── styles.css -*/ - - -/** - * Generates a Markdown tree starting at the given URI. - * The root folder is printed as a header (without a bullet). - */ -export async function generateMarkdownTree(fileService: IFileService, uri: URI): Promise { +export async function generateDirectoryTreeMd(fileService: IFileService, uri: URI): Promise { let output = '' @@ -149,8 +130,6 @@ export interface IToolService { export const IToolService = createDecorator('ToolService'); - -// implemented by calling channel export class ToolService implements IToolService { readonly _serviceBrand: undefined; @@ -169,7 +148,7 @@ export class ToolService implements IToolService { }, list_dir: async ({ uri: uriStr }) => { const uri = validateURI(uriStr) - const treeStr = await generateMarkdownTree(fileService, uri) + const treeStr = await generateDirectoryTreeMd(fileService, uri) return treeStr }, pathname_search: async ({ query }) => { From 812014d6d37b448a121e5c2994cff56ad5a769e2 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:26:42 -0800 Subject: [PATCH 04/17] all tools seem to work! --- .../void/browser/void.contribution.ts | 3 + src/vs/platform/void/common/toolsService.ts | 119 ++++++++++++------ .../void/electron-main/templates/templates.ts | 4 +- .../contrib/void/browser/helpers/readFile.ts | 7 ++ 4 files changed, 95 insertions(+), 38 deletions(-) diff --git a/src/vs/platform/void/browser/void.contribution.ts b/src/vs/platform/void/browser/void.contribution.ts index 276d6e72..25d7b529 100644 --- a/src/vs/platform/void/browser/void.contribution.ts +++ b/src/vs/platform/void/browser/void.contribution.ts @@ -19,3 +19,6 @@ import '../common/metricsService.js' // updates import '../common/voidUpdateService.js' + +// tools +import '../common/toolsService.js' diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index 77666b84..4a97508d 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -1,15 +1,18 @@ -import { URI } from '../../../base/common/uri' -import { IModelService } from '../../../editor/common/services/model' -import { VSReadFile } from '../../../workbench/contrib/void/browser/helpers/readFile' -import { IFileService, IFileStat } from '../../files/common/files' -import { registerSingleton, InstantiationType } from '../../instantiation/common/extensions' -import { createDecorator } from '../../instantiation/common/instantiation' +import { CancellationToken } from '../../../base/common/cancellation.js' +import { URI } from '../../../base/common/uri.js' +import { IModelService } from '../../../editor/common/services/model.js' +import { VSReadFileRaw } from '../../../workbench/contrib/void/browser/helpers/readFile.js' +import { QueryBuilder } from '../../../workbench/services/search/common/queryBuilder.js' +import { ISearchService } from '../../../workbench/services/search/common/search.js' +import { IFileService, IFileStat } from '../../files/common/files.js' +import { registerSingleton, InstantiationType } from '../../instantiation/common/extensions.js' +import { createDecorator, IInstantiationService } from '../../instantiation/common/instantiation.js' +import { IWorkspaceContextService } from '../../workspace/common/workspace.js' +// import { IWorkspacesService } from '../../workspaces/common/workspaces.js' -const pagination = { - desc: `Very large results may be paginated (indicated in the result). Pagination fails gracefully if out of bounds or invalid page number.`, - param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } -} as const +// tool use for AI + @@ -21,6 +24,13 @@ export type InternalToolInfo = { }, required: string[], // required paramNames } + +// helper +const pagination = { + desc: `Very large results may be paginated (indicated in the result). Pagination fails gracefully if out of bounds or invalid page number.`, + param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } +} as const + const contextTools = { read_file: { description: 'Returns file contents of a given URI.', @@ -48,7 +58,7 @@ const contextTools = { required: ['query'] }, - grep_search: { + search: { description: `Returns all code excerpts containing the given string or grep query. This does NOT search pathname. As a follow-up, you may want to use read_file to view the full file contents of the results. ${pagination.desc}`, params: { query: { type: 'string', description: undefined }, @@ -66,7 +76,7 @@ const contextTools = { type ContextToolName = keyof typeof contextTools type ContextParamNames = keyof typeof contextTools[T]['params'] -type ContextParams = { [paramName in ContextParamNames]: string } +type ContextParams = { [paramName in ContextParamNames]: unknown } type ContextToolCallFns = { [ToolName in ContextToolName]: ((p: (ContextParams)) => Promise) @@ -78,20 +88,22 @@ type ContextToolCallFns = { +// TODO check to make sure in workspace +// TODO check to make sure is not gitignored -export async function generateDirectoryTreeMd(fileService: IFileService, uri: URI): Promise { +async function generateDirectoryTreeMd(fileService: IFileService, rootURI: URI): Promise { let output = '' - function traverseChildren(children: IFileStat[], depth: number) { const indentation = ' '.repeat(depth); for (const child of children) { output += `${indentation}- ${child.name}\n`; - output += traverseChildren(child.children ?? [], depth + 1); + traverseChildren(child.children ?? [], depth + 1); } } - const stat = await fileService.resolve(uri, { resolveMetadata: false }); + const stat = await fileService.resolve(rootURI, { resolveMetadata: false }); + console.log('statttttttttt', JSON.stringify(stat, null, 2)) // kickstart recursion output += `${stat.name}\n`; traverseChildren(stat.children ?? [], 1); @@ -99,30 +111,42 @@ export async function generateDirectoryTreeMd(fileService: IFileService, uri: UR return output; } +// async function searchPathnameRegex(fileService: IFileService, pathnameRegex: string, workspaceURI: URI) { +// let output: string[] = [] +// let regex: RegExp +// try { +// regex = new RegExp(pathnameRegex) +// } catch (e) { +// return [`(Error: invalid regex: ${e})`] +// } + +// function traverseChildren(children: IFileStat[]) { +// for (const child of children) { +// // if it's a file, match its name +// if (child.isFile) { +// if (regex.test(child.resource.fsPath)) { output.push(child.resource.fsPath) } +// } +// // otherwise traverse children +// else { +// traverseChildren(child.children ?? []) +// } +// } +// } +// const stat = await fileService.resolve(workspaceURI, { resolveMetadata: false }); +// traverseChildren(stat.children ?? []); +// return output; +// } + + const validateURI = (uriStr: unknown) => { if (typeof uriStr !== 'string') throw new Error('(uri was not a string)') console.log('uriStr!!!!', uriStr) const uri = URI.file(uriStr) - console.log('uri!!!!', uri) + console.log('uri!!!!', uri.fsPath) return uri } - - - - - - - - - - - - - - - export interface IToolService { readonly _serviceBrand: undefined; callContextTool: (toolName: T, params: ContextParams) => Promise @@ -139,26 +163,47 @@ export class ToolService implements IToolService { constructor( @IFileService fileService: IFileService, @IModelService modelService: IModelService, + @IWorkspaceContextService w: IWorkspaceContextService, + @ISearchService s: ISearchService, + @IInstantiationService instantiationService: IInstantiationService, ) { + + + const queryBuilder = instantiationService.createInstance(QueryBuilder); + this.contextToolCallFns = { read_file: async ({ uri: uriStr }) => { const uri = validateURI(uriStr) - const fileContents = await VSReadFile(modelService, uri) + const fileContents = await VSReadFileRaw(fileService, uri) return fileContents ?? '(could not read file)' }, list_dir: async ({ uri: uriStr }) => { const uri = validateURI(uriStr) const treeStr = await generateDirectoryTreeMd(fileService, uri) + console.log('!!PIZA', treeStr) return treeStr }, - pathname_search: async ({ query }) => { - return '' + pathname_search: async ({ query: queryStr }) => { + if (typeof queryStr !== 'string') return '(Error: query was not a string)' + const query = queryBuilder.file(w.getWorkspace().folders.map(f => f.uri), { filePattern: queryStr, }); + + const data = await s.fileSearch(query, CancellationToken.None); + const str = data.results.map(({ resource, results }) => resource.fsPath).join('\n') + return str }, - grep_search: async ({ query }) => { - return '' + search: async ({ query: queryStr }) => { + if (typeof queryStr !== 'string') return '(Error: query was not a string)' + const query = queryBuilder.text({ pattern: queryStr, }, w.getWorkspace().folders.map(f => f.uri)); + + const data = await s.textSearch(query, CancellationToken.None); + const str = data.results.map(({ resource, results }) => resource.fsPath).join('\n') + return str }, } + + + } callContextTool: IToolService['callContextTool'] = (toolName, params) => { diff --git a/src/vs/platform/void/electron-main/templates/templates.ts b/src/vs/platform/void/electron-main/templates/templates.ts index 0f74197e..9b90dfee 100644 --- a/src/vs/platform/void/electron-main/templates/templates.ts +++ b/src/vs/platform/void/electron-main/templates/templates.ts @@ -4,7 +4,9 @@ modelName -> { system_message_type: 'system' | 'developer' (openai) | null // if null, we will just do a string of system message supports_tools: boolean // we will just do a string of tool use if it doesn't support supports_autocomplete_FIM (suffix) // we will just do a description of FIM if it doens't support <|fim_hole|> - max_tokens + + supports_streaming: boolean (o1 does NOT) + max_tokens: number } diff --git a/src/vs/workbench/contrib/void/browser/helpers/readFile.ts b/src/vs/workbench/contrib/void/browser/helpers/readFile.ts index 60e5dc5c..d511239b 100644 --- a/src/vs/workbench/contrib/void/browser/helpers/readFile.ts +++ b/src/vs/workbench/contrib/void/browser/helpers/readFile.ts @@ -1,6 +1,7 @@ import { URI } from '../../../../../base/common/uri' import { EndOfLinePreference } from '../../../../../editor/common/model' import { IModelService } from '../../../../../editor/common/services/model.js' +import { IFileService } from '../../../../../platform/files/common/files' // read files from VSCode export const VSReadFile = async (modelService: IModelService, uri: URI): Promise => { @@ -8,3 +9,9 @@ export const VSReadFile = async (modelService: IModelService, uri: URI): Promise if (!model) return null return model.getValue(EndOfLinePreference.LF) } + +export const VSReadFileRaw = async (fileService: IFileService, uri: URI) => { + const res = await fileService.readFile(uri) + const str = res.value.toString() + return str +} From 165b5a4fd218e166816003305fa565f81d5eeeb4 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:26:58 -0800 Subject: [PATCH 05/17] + --- src/vs/workbench/contrib/void/browser/helpers/readFile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/void/browser/helpers/readFile.ts b/src/vs/workbench/contrib/void/browser/helpers/readFile.ts index d511239b..ff3a78e7 100644 --- a/src/vs/workbench/contrib/void/browser/helpers/readFile.ts +++ b/src/vs/workbench/contrib/void/browser/helpers/readFile.ts @@ -3,7 +3,7 @@ import { EndOfLinePreference } from '../../../../../editor/common/model' import { IModelService } from '../../../../../editor/common/services/model.js' import { IFileService } from '../../../../../platform/files/common/files' -// read files from VSCode +// read files from VSCode (looks like only works if model exists already, use raw if not) export const VSReadFile = async (modelService: IModelService, uri: URI): Promise => { const model = modelService.getModel(uri) if (!model) return null From 0d9be68aff4a2abd3ce15dcb334072209cb75922 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:27:21 -0800 Subject: [PATCH 06/17] rm comment --- src/vs/platform/void/common/toolsService.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index 4a97508d..fba6900b 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -103,7 +103,6 @@ async function generateDirectoryTreeMd(fileService: IFileService, rootURI: URI): } const stat = await fileService.resolve(rootURI, { resolveMetadata: false }); - console.log('statttttttttt', JSON.stringify(stat, null, 2)) // kickstart recursion output += `${stat.name}\n`; traverseChildren(stat.children ?? [], 1); From 20da82762e47f5e8aeacaadfcc6e4f5e2cd36c4a Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:27:36 -0800 Subject: [PATCH 07/17] rm comment --- src/vs/platform/void/common/toolsService.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index fba6900b..56c433b4 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -179,7 +179,6 @@ export class ToolService implements IToolService { list_dir: async ({ uri: uriStr }) => { const uri = validateURI(uriStr) const treeStr = await generateDirectoryTreeMd(fileService, uri) - console.log('!!PIZA', treeStr) return treeStr }, pathname_search: async ({ query: queryStr }) => { From 231990088a79fe532e0900494d4a17db81f550c3 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:28:44 -0800 Subject: [PATCH 08/17] uri --- src/vs/platform/void/common/toolsService.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index 56c433b4..fd226ec2 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -1,6 +1,5 @@ import { CancellationToken } from '../../../base/common/cancellation.js' import { URI } from '../../../base/common/uri.js' -import { IModelService } from '../../../editor/common/services/model.js' import { VSReadFileRaw } from '../../../workbench/contrib/void/browser/helpers/readFile.js' import { QueryBuilder } from '../../../workbench/services/search/common/queryBuilder.js' import { ISearchService } from '../../../workbench/services/search/common/search.js' @@ -140,9 +139,7 @@ async function generateDirectoryTreeMd(fileService: IFileService, rootURI: URI): const validateURI = (uriStr: unknown) => { if (typeof uriStr !== 'string') throw new Error('(uri was not a string)') - console.log('uriStr!!!!', uriStr) const uri = URI.file(uriStr) - console.log('uri!!!!', uri.fsPath) return uri } @@ -161,7 +158,6 @@ export class ToolService implements IToolService { constructor( @IFileService fileService: IFileService, - @IModelService modelService: IModelService, @IWorkspaceContextService w: IWorkspaceContextService, @ISearchService s: ISearchService, @IInstantiationService instantiationService: IInstantiationService, From 3fd36342572a228560755045566e56f48039fbd5 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:36:03 -0800 Subject: [PATCH 09/17] void message --- src/vs/platform/void/common/toolsService.ts | 12 ++++++------ src/vs/workbench/api/browser/mainThreadInlineDiff.ts | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index fd226ec2..4490d8c1 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -74,11 +74,11 @@ const contextTools = { } as const satisfies { [name: string]: InternalToolInfo } type ContextToolName = keyof typeof contextTools -type ContextParamNames = keyof typeof contextTools[T]['params'] -type ContextParams = { [paramName in ContextParamNames]: unknown } +type ContextToolParamNames = keyof typeof contextTools[T]['params'] +type ContextToolParams = { [paramName in ContextToolParamNames]: unknown } -type ContextToolCallFns = { - [ToolName in ContextToolName]: ((p: (ContextParams)) => Promise) +type AllContextToolCallFns = { + [ToolName in ContextToolName]: ((p: (ContextToolParams)) => Promise) } @@ -145,7 +145,7 @@ const validateURI = (uriStr: unknown) => { export interface IToolService { readonly _serviceBrand: undefined; - callContextTool: (toolName: T, params: ContextParams) => Promise + callContextTool: (toolName: T, params: ContextToolParams) => Promise } export const IToolService = createDecorator('ToolService'); @@ -154,7 +154,7 @@ export class ToolService implements IToolService { readonly _serviceBrand: undefined; - contextToolCallFns: ContextToolCallFns + contextToolCallFns: AllContextToolCallFns constructor( @IFileService fileService: IFileService, diff --git a/src/vs/workbench/api/browser/mainThreadInlineDiff.ts b/src/vs/workbench/api/browser/mainThreadInlineDiff.ts index 344458f9..d43fc633 100644 --- a/src/vs/workbench/api/browser/mainThreadInlineDiff.ts +++ b/src/vs/workbench/api/browser/mainThreadInlineDiff.ts @@ -14,6 +14,8 @@ import { WorkspaceEdit } from '../../../editor/common/languages.js'; // import { IHistoryService } from '../../services/history/common/history.js'; +// VOID: THIS FILE IS OUTDATED!!!!!! No longer used anywhere. + @extHostNamedCustomer(MainContext.MainThreadInlineDiff) export class MainThreadInlineDiff extends Disposable implements MainThreadInlineDiffShape { From e46b29544933a7b6d3b17ddd37de2283c96e6eb0 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:45:06 -0800 Subject: [PATCH 10/17] names --- src/vs/platform/void/common/toolsService.ts | 40 ++++----------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index 4490d8c1..fd0ad4b1 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -7,7 +7,6 @@ import { IFileService, IFileStat } from '../../files/common/files.js' import { registerSingleton, InstantiationType } from '../../instantiation/common/extensions.js' import { createDecorator, IInstantiationService } from '../../instantiation/common/instantiation.js' import { IWorkspaceContextService } from '../../workspace/common/workspace.js' -// import { IWorkspacesService } from '../../workspaces/common/workspaces.js' // tool use for AI @@ -109,33 +108,6 @@ async function generateDirectoryTreeMd(fileService: IFileService, rootURI: URI): return output; } -// async function searchPathnameRegex(fileService: IFileService, pathnameRegex: string, workspaceURI: URI) { -// let output: string[] = [] -// let regex: RegExp -// try { -// regex = new RegExp(pathnameRegex) -// } catch (e) { -// return [`(Error: invalid regex: ${e})`] -// } - -// function traverseChildren(children: IFileStat[]) { -// for (const child of children) { -// // if it's a file, match its name -// if (child.isFile) { -// if (regex.test(child.resource.fsPath)) { output.push(child.resource.fsPath) } -// } -// // otherwise traverse children -// else { -// traverseChildren(child.children ?? []) -// } -// } -// } -// const stat = await fileService.resolve(workspaceURI, { resolveMetadata: false }); -// traverseChildren(stat.children ?? []); -// return output; -// } - - const validateURI = (uriStr: unknown) => { if (typeof uriStr !== 'string') throw new Error('(uri was not a string)') @@ -158,8 +130,8 @@ export class ToolService implements IToolService { constructor( @IFileService fileService: IFileService, - @IWorkspaceContextService w: IWorkspaceContextService, - @ISearchService s: ISearchService, + @IWorkspaceContextService workspaceContextService: IWorkspaceContextService, + @ISearchService searchService: ISearchService, @IInstantiationService instantiationService: IInstantiationService, ) { @@ -179,17 +151,17 @@ export class ToolService implements IToolService { }, pathname_search: async ({ query: queryStr }) => { if (typeof queryStr !== 'string') return '(Error: query was not a string)' - const query = queryBuilder.file(w.getWorkspace().folders.map(f => f.uri), { filePattern: queryStr, }); + const query = queryBuilder.file(workspaceContextService.getWorkspace().folders.map(f => f.uri), { filePattern: queryStr, }); - const data = await s.fileSearch(query, CancellationToken.None); + const data = await searchService.fileSearch(query, CancellationToken.None); const str = data.results.map(({ resource, results }) => resource.fsPath).join('\n') return str }, search: async ({ query: queryStr }) => { if (typeof queryStr !== 'string') return '(Error: query was not a string)' - const query = queryBuilder.text({ pattern: queryStr, }, w.getWorkspace().folders.map(f => f.uri)); + const query = queryBuilder.text({ pattern: queryStr, }, workspaceContextService.getWorkspace().folders.map(f => f.uri)); - const data = await s.textSearch(query, CancellationToken.None); + const data = await searchService.textSearch(query, CancellationToken.None); const str = data.results.map(({ resource, results }) => resource.fsPath).join('\n') return str }, From 9cbe83b57cc8a269fe10d58f382845435f2d946d Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 9 Feb 2025 00:46:39 -0800 Subject: [PATCH 11/17] comment --- src/vs/workbench/contrib/void/browser/helpers/readFile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/void/browser/helpers/readFile.ts b/src/vs/workbench/contrib/void/browser/helpers/readFile.ts index ff3a78e7..b0f154d1 100644 --- a/src/vs/workbench/contrib/void/browser/helpers/readFile.ts +++ b/src/vs/workbench/contrib/void/browser/helpers/readFile.ts @@ -3,7 +3,7 @@ import { EndOfLinePreference } from '../../../../../editor/common/model' import { IModelService } from '../../../../../editor/common/services/model.js' import { IFileService } from '../../../../../platform/files/common/files' -// read files from VSCode (looks like only works if model exists already, use raw if not) +// read files from VSCode. preferred (but appears to only work if the model of this URI already exists. If it doesn't use the other function.) export const VSReadFile = async (modelService: IModelService, uri: URI): Promise => { const model = modelService.getModel(uri) if (!model) return null From c1be46646744fc016ab6bf2d923b094915f325e8 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 10 Feb 2025 15:34:07 -0800 Subject: [PATCH 12/17] tool tests --- src/vs/platform/void/common/toolsService.ts | 3 +- .../void/electron-main/llmMessage/openai.ts | 80 ++++++++++--------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index fd0ad4b1..1b846b9d 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -13,7 +13,6 @@ import { IWorkspaceContextService } from '../../workspace/common/workspace.js' - // we do this using Anthropic's style and convert to OpenAI style later export type InternalToolInfo = { description: string, @@ -29,7 +28,7 @@ const pagination = { param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } } as const -const contextTools = { +export const contextTools = { read_file: { description: 'Returns file contents of a given URI.', params: { diff --git a/src/vs/platform/void/electron-main/llmMessage/openai.ts b/src/vs/platform/void/electron-main/llmMessage/openai.ts index 3a3c4818..8f4d8b04 100644 --- a/src/vs/platform/void/electron-main/llmMessage/openai.ts +++ b/src/vs/platform/void/electron-main/llmMessage/openai.ts @@ -6,7 +6,7 @@ import OpenAI from 'openai'; import { _InternalModelListFnType, _InternalSendLLMFIMMessageFnType, _InternalSendLLMChatMessageFnType } from '../../common/llmMessageTypes.js'; import { Model } from 'openai/resources/models.js'; -import { InternalToolInfo } from '../../common/toolsService.js'; +import { contextTools, InternalToolInfo } from '../../common/toolsService.js'; // import { parseMaxTokensStr } from './util.js'; @@ -34,41 +34,6 @@ export const toOpenAITool = (toolName: string, toolInfo: InternalToolInfo) => { - -// might not currently be used in the code -export const openaiCompatibleList: _InternalModelListFnType = async ({ onSuccess: onSuccess_, onError: onError_, settingsOfProvider }) => { - const onSuccess = ({ models }: { models: Model[] }) => { - onSuccess_({ models }) - } - - const onError = ({ error }: { error: string }) => { - onError_({ error }) - } - - try { - const thisConfig = settingsOfProvider.openAICompatible - const openai = new OpenAI({ baseURL: thisConfig.endpoint, apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true }) - - openai.models.list() - .then(async (response) => { - const models: Model[] = [] - models.push(...response.data) - while (response.hasNextPage()) { - models.push(...(await response.getNextPage()).data) - } - onSuccess({ models }) - }) - .catch((error) => { - onError({ error: error + '' }) - }) - } - catch (error) { - onError({ error: error + '' }) - } -} - - - type NewParams = Pick[0] & Parameters<_InternalSendLLMFIMMessageFnType>[0], 'settingsOfProvider' | 'providerName'> const newOpenAI = ({ settingsOfProvider, providerName }: NewParams) => { @@ -107,6 +72,40 @@ const newOpenAI = ({ settingsOfProvider, providerName }: NewParams) => { +// might not currently be used in the code +export const openaiCompatibleList: _InternalModelListFnType = async ({ onSuccess: onSuccess_, onError: onError_, settingsOfProvider }) => { + const onSuccess = ({ models }: { models: Model[] }) => { + onSuccess_({ models }) + } + + const onError = ({ error }: { error: string }) => { + onError_({ error }) + } + + try { + const openai = newOpenAI({ providerName: 'openAICompatible', settingsOfProvider }) + + openai.models.list() + .then(async (response) => { + const models: Model[] = [] + models.push(...response.data) + while (response.hasNextPage()) { + models.push(...(await response.getNextPage()).data) + } + onSuccess({ models }) + }) + .catch((error) => { + onError({ error: error + '' }) + }) + } + catch (error) { + onError({ error: error + '' }) + } +} + + + + export const sendOpenAIFIM: _InternalSendLLMFIMMessageFnType = ({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }) => { @@ -142,6 +141,7 @@ export const sendOpenAIChat: _InternalSendLLMChatMessageFnType = ({ messages, on model: modelName, messages: messages, stream: true, + tools: [toOpenAITool('list_dir', contextTools['list_dir'])], } openai.chat.completions @@ -150,7 +150,13 @@ export const sendOpenAIChat: _InternalSendLLMChatMessageFnType = ({ messages, on _setAborter(() => response.controller.abort()) // when receive text for await (const chunk of response) { - const newText = chunk.choices[0]?.delta?.content || ''; + console.log('!!!', JSON.stringify(chunk, null, 2)) + + + let newText = '' + newText += chunk.choices[0]?.delta?.tool_calls?.[0]?.function?.name ?? '' + newText += chunk.choices[0]?.delta?.tool_calls?.[0]?.function?.arguments ?? '' + newText += chunk.choices[0]?.delta?.content ?? '' fullText += newText; onText({ newText, fullText }); } From 995357710e090e67f2ad1b17009c180f137cb902 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 10 Feb 2025 18:33:51 -0800 Subject: [PATCH 13/17] misc --- src/vs/platform/void/common/toolsService.ts | 4 ++-- src/vs/platform/void/electron-main/llmMessage/groq.ts | 2 -- src/vs/platform/void/electron-main/llmMessage/mistral.ts | 2 -- src/vs/platform/void/electron-main/llmMessage/openai.ts | 6 ++---- .../void/electron-main/llmMessage/sendLLMMessage.ts | 9 +++++++-- .../platform/void/electron-main/templates/templates.ts | 5 ++--- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/platform/void/common/toolsService.ts index 1b846b9d..2a0c051c 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/platform/void/common/toolsService.ts @@ -25,7 +25,7 @@ export type InternalToolInfo = { // helper const pagination = { desc: `Very large results may be paginated (indicated in the result). Pagination fails gracefully if out of bounds or invalid page number.`, - param: { pageNumber: { type: 'number', description: 'The page number (optional, defaults to 1).' }, } + param: { pageNumber: { type: 'number', description: 'The page number (optional, default is 1).' }, } } as const export const contextTools = { @@ -71,7 +71,7 @@ export const contextTools = { } as const satisfies { [name: string]: InternalToolInfo } -type ContextToolName = keyof typeof contextTools +export type ContextToolName = keyof typeof contextTools type ContextToolParamNames = keyof typeof contextTools[T]['params'] type ContextToolParams = { [paramName in ContextToolParamNames]: unknown } diff --git a/src/vs/platform/void/electron-main/llmMessage/groq.ts b/src/vs/platform/void/electron-main/llmMessage/groq.ts index b8c29981..8f7efd14 100644 --- a/src/vs/platform/void/electron-main/llmMessage/groq.ts +++ b/src/vs/platform/void/electron-main/llmMessage/groq.ts @@ -22,8 +22,6 @@ export const sendGroqChat: _InternalSendLLMChatMessageFnType = async ({ messages messages: messages, model: modelName, stream: true, - // temperature: 0.7, - // max_tokens: parseMaxTokensStr(thisConfig.maxTokens), }) .then(async response => { _setAborter(() => response.controller.abort()) diff --git a/src/vs/platform/void/electron-main/llmMessage/mistral.ts b/src/vs/platform/void/electron-main/llmMessage/mistral.ts index 8fddaf2e..cfddc2a5 100644 --- a/src/vs/platform/void/electron-main/llmMessage/mistral.ts +++ b/src/vs/platform/void/electron-main/llmMessage/mistral.ts @@ -21,8 +21,6 @@ export const sendMistralChat: _InternalSendLLMChatMessageFnType = async ({ messa messages: messages, model: modelName, stream: true, - // temperature: 0.7, - // maxTokens: 2048, }) .then(async response => { // Mistral has a really nonstandard API - no interrupt and weird stream types diff --git a/src/vs/platform/void/electron-main/llmMessage/openai.ts b/src/vs/platform/void/electron-main/llmMessage/openai.ts index 8f4d8b04..1ac2a748 100644 --- a/src/vs/platform/void/electron-main/llmMessage/openai.ts +++ b/src/vs/platform/void/electron-main/llmMessage/openai.ts @@ -6,7 +6,7 @@ import OpenAI from 'openai'; import { _InternalModelListFnType, _InternalSendLLMFIMMessageFnType, _InternalSendLLMChatMessageFnType } from '../../common/llmMessageTypes.js'; import { Model } from 'openai/resources/models.js'; -import { contextTools, InternalToolInfo } from '../../common/toolsService.js'; +import { InternalToolInfo } from '../../common/toolsService.js'; // import { parseMaxTokensStr } from './util.js'; @@ -141,7 +141,7 @@ export const sendOpenAIChat: _InternalSendLLMChatMessageFnType = ({ messages, on model: modelName, messages: messages, stream: true, - tools: [toOpenAITool('list_dir', contextTools['list_dir'])], + // tools: Object.keys(contextTools).map(name => toOpenAITool(name, contextTools[name as ContextToolName])), } openai.chat.completions @@ -150,8 +150,6 @@ export const sendOpenAIChat: _InternalSendLLMChatMessageFnType = ({ messages, on _setAborter(() => response.controller.abort()) // when receive text for await (const chunk of response) { - console.log('!!!', JSON.stringify(chunk, null, 2)) - let newText = '' newText += chunk.choices[0]?.delta?.tool_calls?.[0]?.function?.name ?? '' diff --git a/src/vs/platform/void/electron-main/llmMessage/sendLLMMessage.ts b/src/vs/platform/void/electron-main/llmMessage/sendLLMMessage.ts index 7cea9d5a..ffffc223 100644 --- a/src/vs/platform/void/electron-main/llmMessage/sendLLMMessage.ts +++ b/src/vs/platform/void/electron-main/llmMessage/sendLLMMessage.ts @@ -65,9 +65,14 @@ export const sendLLMMessage = ({ metricsService: IMetricsService ) => { - // messages.unshift({ role: 'system', content: aiInstructions }) - const messagesArr = messagesType === 'chatMessages' ? cleanChatMessages(messages_) : [] + let messagesArr: _InternalLLMChatMessage[] = [] + if (messagesType === 'chatMessages') { + messagesArr = cleanChatMessages([ + { role: 'system', content: aiInstructions }, + ...messages_ + ]) + } // only captures number of messages and message "shape", no actual code, instructions, prompts, etc const captureLLMEvent = (eventId: string, extras?: object) => { diff --git a/src/vs/platform/void/electron-main/templates/templates.ts b/src/vs/platform/void/electron-main/templates/templates.ts index 9b90dfee..138f7be3 100644 --- a/src/vs/platform/void/electron-main/templates/templates.ts +++ b/src/vs/platform/void/electron-main/templates/templates.ts @@ -5,9 +5,8 @@ modelName -> { supports_tools: boolean // we will just do a string of tool use if it doesn't support supports_autocomplete_FIM (suffix) // we will just do a description of FIM if it doens't support <|fim_hole|> - supports_streaming: boolean (o1 does NOT) - max_tokens: number - + supports_streaming: boolean // (o1 does NOT) we will just dump the final result if doesn't support it + max_tokens: number // required, DEFAULT is Infinity } From 5ed1f465a2b48d6707bd16d6b2cad6206a3c8b1b Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 10 Feb 2025 18:59:26 -0800 Subject: [PATCH 14/17] MOVE VOID FILES TO WORKBENCH --- src/vs/code/electron-main/app.ts | 10 ++++---- .../void/browser/void.contribution.ts | 24 ------------------- .../void/browser/autocompleteService.ts | 2 +- .../contrib/void/browser/chatThreadService.ts | 2 +- .../void/browser/inlineDiffsService.ts | 6 ++--- .../contrib/void/browser/quickEditActions.ts | 2 +- .../src/quick-edit-tsx/QuickEditChat.tsx | 2 +- .../react/src/sidebar-tsx/ErrorDisplay.tsx | 2 +- .../react/src/sidebar-tsx/SidebarChat.tsx | 2 +- .../void/browser/react/src/util/services.tsx | 14 +++++------ .../src/void-settings-tsx/ModelDropdown.tsx | 4 ++-- .../react/src/void-settings-tsx/Settings.tsx | 2 +- .../contrib/void/browser/sidebarActions.ts | 2 +- .../contrib/void/browser/void.contribution.ts | 23 ++++++++++++++++++ .../contrib/void/browser/voidUpdateActions.ts | 4 ++-- .../contrib}/void/common/llmMessageService.ts | 15 ++++++------ .../contrib}/void/common/llmMessageTypes.ts | 0 .../contrib}/void/common/metricsService.ts | 16 ++++++------- .../void/common/refreshModelService.ts | 8 +++---- .../contrib}/void/common/toolsService.ts | 18 +++++++------- .../void/common/voidSettingsService.ts | 14 +++++------ .../contrib}/void/common/voidSettingsTypes.ts | 0 .../contrib}/void/common/voidUpdateService.ts | 8 +++---- .../electron-main/llmMessage/anthropic.ts | 0 .../void/electron-main/llmMessage/gemini.ts | 0 .../void/electron-main/llmMessage/groq.ts | 0 .../void/electron-main/llmMessage/mistral.ts | 0 .../void/electron-main/llmMessage/ollama.ts | 0 .../void/electron-main/llmMessage/openai.ts | 0 .../llmMessage/sendLLMMessage.ts | 0 .../void/electron-main/llmMessageChannel.ts | 4 ++-- .../void/electron-main/metricsMainService.ts | 15 ++++++------ .../void/electron-main/templates/templates.ts | 0 .../electron-main/voidUpdateMainService.ts | 7 +++--- src/vs/workbench/workbench.common.main.ts | 1 - 35 files changed, 102 insertions(+), 105 deletions(-) delete mode 100644 src/vs/platform/void/browser/void.contribution.ts rename src/vs/{platform => workbench/contrib}/void/common/llmMessageService.ts (93%) rename src/vs/{platform => workbench/contrib}/void/common/llmMessageTypes.ts (100%) rename src/vs/{platform => workbench/contrib}/void/common/metricsService.ts (74%) rename src/vs/{platform => workbench/contrib}/void/common/refreshModelService.ts (95%) rename src/vs/{platform => workbench/contrib}/void/common/toolsService.ts (86%) rename src/vs/{platform => workbench/contrib}/void/common/voidSettingsService.ts (95%) rename src/vs/{platform => workbench/contrib}/void/common/voidSettingsTypes.ts (100%) rename src/vs/{platform => workbench/contrib}/void/common/voidUpdateService.ts (78%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/anthropic.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/gemini.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/groq.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/mistral.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/ollama.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/openai.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessage/sendLLMMessage.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/llmMessageChannel.ts (97%) rename src/vs/{platform => workbench/contrib}/void/electron-main/metricsMainService.ts (86%) rename src/vs/{platform => workbench/contrib}/void/electron-main/templates/templates.ts (100%) rename src/vs/{platform => workbench/contrib}/void/electron-main/voidUpdateMainService.ts (82%) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index f9c50efa..faadd1cd 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -121,11 +121,11 @@ import { normalizeNFC } from '../../base/common/normalization.js'; import { ICSSDevelopmentService, CSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js'; import { ExtensionSignatureVerificationService, IExtensionSignatureVerificationService } from '../../platform/extensionManagement/node/extensionSignatureVerificationService.js'; -import { LLMMessageChannel } from '../../platform/void/electron-main/llmMessageChannel.js'; -import { IMetricsService } from '../../platform/void/common/metricsService.js'; -import { MetricsMainService } from '../../platform/void/electron-main/metricsMainService.js'; -import { VoidMainUpdateService } from '../../platform/void/electron-main/voidUpdateMainService.js'; -import { IVoidUpdateService } from '../../platform/void/common/voidUpdateService.js'; +import { LLMMessageChannel } from '../../workbench/contrib/void/electron-main/llmMessageChannel.js'; +import { IMetricsService } from '../../workbench/contrib/void/common/metricsService.js'; +import { MetricsMainService } from '../../workbench/contrib/void/electron-main/metricsMainService.js'; +import { VoidMainUpdateService } from '../../workbench/contrib/void/electron-main/voidUpdateMainService.js'; +import { IVoidUpdateService } from '../../workbench/contrib/void/common/voidUpdateService.js'; /** * The main VS Code application. There will only ever be one instance, * even if the user starts many instances (e.g. from the command line). diff --git a/src/vs/platform/void/browser/void.contribution.ts b/src/vs/platform/void/browser/void.contribution.ts deleted file mode 100644 index 25d7b529..00000000 --- a/src/vs/platform/void/browser/void.contribution.ts +++ /dev/null @@ -1,24 +0,0 @@ -/*-------------------------------------------------------------------------------------- - * Copyright 2025 Glass Devtools, Inc. All rights reserved. - * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. - *--------------------------------------------------------------------------------------*/ - -// ---------- common ---------- - -// llmMessage -import '../common/llmMessageService.js' - -// voidSettings -import '../common/voidSettingsService.js' - -// refreshModel -import '../common/refreshModelService.js' - -// metrics -import '../common/metricsService.js' - -// updates -import '../common/voidUpdateService.js' - -// tools -import '../common/toolsService.js' diff --git a/src/vs/workbench/contrib/void/browser/autocompleteService.ts b/src/vs/workbench/contrib/void/browser/autocompleteService.ts index 6b67c6be..77ac8807 100644 --- a/src/vs/workbench/contrib/void/browser/autocompleteService.ts +++ b/src/vs/workbench/contrib/void/browser/autocompleteService.ts @@ -11,7 +11,6 @@ import { Position } from '../../../../editor/common/core/position.js'; import { InlineCompletion, InlineCompletionContext, } from '../../../../editor/common/languages.js'; import { CancellationToken } from '../../../../base/common/cancellation.js'; import { Range } from '../../../../editor/common/core/range.js'; -import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js'; import { IEditorService } from '../../../services/editor/common/editorService.js'; import { isCodeEditor } from '../../../../editor/browser/editorBrowser.js'; import { EditorResourceAccessor } from '../../../common/editor.js'; @@ -19,6 +18,7 @@ import { IModelService } from '../../../../editor/common/services/model.js'; import { extractCodeFromRegular } from './helpers/extractCodeFromResult.js'; import { isWindows } from '../../../../base/common/platform.js'; import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js'; +import { ILLMMessageService } from '../common/llmMessageService.js'; // import { IContextGatheringService } from './contextGatheringService.js'; // The extension this was called from is here - https://github.com/voideditor/void/blob/autocomplete/extensions/void/src/extension/extension.ts diff --git a/src/vs/workbench/contrib/void/browser/chatThreadService.ts b/src/vs/workbench/contrib/void/browser/chatThreadService.ts index 03683732..a3452eb2 100644 --- a/src/vs/workbench/contrib/void/browser/chatThreadService.ts +++ b/src/vs/workbench/contrib/void/browser/chatThreadService.ts @@ -11,7 +11,7 @@ import { IStorageService, StorageScope, StorageTarget } from '../../../../platfo import { URI } from '../../../../base/common/uri.js'; import { Emitter, Event } from '../../../../base/common/event.js'; import { IRange } from '../../../../editor/common/core/range.js'; -import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js'; +import { ILLMMessageService } from '../common/llmMessageService.js'; import { IModelService } from '../../../../editor/common/services/model.js'; import { chat_userMessage, chat_systemMessage } from './prompt/prompts.js'; diff --git a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts index d4d7d065..31d4d175 100644 --- a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts +++ b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts @@ -26,14 +26,11 @@ import { Widget } from '../../../../base/browser/ui/widget.js'; import { URI } from '../../../../base/common/uri.js'; import { IConsistentEditorItemService, IConsistentItemService } from './helperServices/consistentItemService.js'; import { voidPrefixAndSuffix, ctrlKStream_userMessage, ctrlKStream_systemMessage, fastApply_userMessage, fastApply_systemMessage, defaultFimTags } from './prompt/prompts.js'; -import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js'; import { mountCtrlK } from '../browser/react/out/quick-edit-tsx/index.js' import { QuickEditPropsType } from './quickEditActions.js'; -import { errorDetails, LLMChatMessage } from '../../../../platform/void/common/llmMessageTypes.js'; import { IModelContentChangedEvent } from '../../../../editor/common/textModelEvents.js'; import { extractCodeFromFIM, extractCodeFromRegular } from './helpers/extractCodeFromResult.js'; -import { IMetricsService } from '../../../../platform/void/common/metricsService.js'; import { filenameToVscodeLanguage } from './helpers/detectLanguage.js'; import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js'; import { isMacintosh } from '../../../../base/common/platform.js'; @@ -41,6 +38,9 @@ import { EditorOption } from '../../../../editor/common/config/editorOptions.js' import { Emitter } from '../../../../base/common/event.js'; import { VOID_OPEN_SETTINGS_ACTION_ID } from './voidSettingsPane.js'; import { ICommandService } from '../../../../platform/commands/common/commands.js'; +import { ILLMMessageService } from '../common/llmMessageService.js'; +import { LLMChatMessage, errorDetails } from '../common/llmMessageTypes.js'; +import { IMetricsService } from '../common/metricsService.js'; const configOfBG = (color: Color) => { return { dark: color, light: color, hcDark: color, hcLight: color, } diff --git a/src/vs/workbench/contrib/void/browser/quickEditActions.ts b/src/vs/workbench/contrib/void/browser/quickEditActions.ts index 1498c8f6..1a6e0deb 100644 --- a/src/vs/workbench/contrib/void/browser/quickEditActions.ts +++ b/src/vs/workbench/contrib/void/browser/quickEditActions.ts @@ -7,12 +7,12 @@ import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js'; import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js'; import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js'; import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js'; -import { IMetricsService } from '../../../../platform/void/common/metricsService.js'; import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js'; import { IInlineDiffsService } from './inlineDiffsService.js'; import { roundRangeToLines } from './sidebarActions.js'; import { VOID_CTRL_K_ACTION_ID } from './actionIDs.js'; import { localize2 } from '../../../../nls.js'; +import { IMetricsService } from '../common/metricsService.js'; export type QuickEditPropsType = { diff --git a/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx index 7edf1e5b..37dd91bf 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx @@ -12,7 +12,7 @@ import { ModelDropdown } from '../void-settings-tsx/ModelDropdown.js'; import { VOID_CTRL_K_ACTION_ID } from '../../../actionIDs.js'; import { useRefState } from '../util/helpers.js'; import { useScrollbarStyles } from '../util/useScrollbarStyles.js'; -import { isFeatureNameDisabled } from '../../../../../../../platform/void/common/voidSettingsTypes.js'; +import { isFeatureNameDisabled } from '../../../../../../../workbench/contrib/void/common/voidSettingsTypes.js'; export const QuickEditChat = ({ diffareaid, diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/ErrorDisplay.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/ErrorDisplay.tsx index 425ce3c9..9aef4b72 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/ErrorDisplay.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/ErrorDisplay.tsx @@ -5,7 +5,7 @@ import React, { useEffect, useState } from 'react'; import { AlertCircle, ChevronDown, ChevronUp, X } from 'lucide-react'; -import { errorDetails } from '../../../../../../../platform/void/common/llmMessageTypes.js'; +import { errorDetails } from '../../../../../../../workbench/contrib/void/common/llmMessageTypes.js'; import { useSettingsState } from '../util/services.js'; diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index b2aa35a9..0816dac5 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -22,7 +22,7 @@ import { VOID_CTRL_L_ACTION_ID } from '../../../actionIDs.js'; import { filenameToVscodeLanguage } from '../../../helpers/detectLanguage.js'; import { VOID_OPEN_SETTINGS_ACTION_ID } from '../../../voidSettingsPane.js'; import { Pencil, X } from 'lucide-react'; -import { FeatureName, isFeatureNameDisabled } from '../../../../../../../platform/void/common/voidSettingsTypes.js'; +import { FeatureName, isFeatureNameDisabled } from '../../../../../../../workbench/contrib/void/common/voidSettingsTypes.js'; import { WarningBox } from '../void-settings-tsx/WarningBox.js'; diff --git a/src/vs/workbench/contrib/void/browser/react/src/util/services.tsx b/src/vs/workbench/contrib/void/browser/react/src/util/services.tsx index e5280c14..52af76f2 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/util/services.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/util/services.tsx @@ -5,14 +5,14 @@ import React, { useState, useEffect } from 'react' import { ThreadStreamState, ThreadsState } from '../../../chatThreadService.js' -import { RefreshableProviderName, SettingsOfProvider } from '../../../../../../../platform/void/common/voidSettingsTypes.js' +import { RefreshableProviderName, SettingsOfProvider } from '../../../../../../../workbench/contrib/void/common/voidSettingsTypes.js' import { IDisposable } from '../../../../../../../base/common/lifecycle.js' import { VoidSidebarState } from '../../../sidebarStateService.js' -import { VoidSettingsState } from '../../../../../../../platform/void/common/voidSettingsService.js' +import { VoidSettingsState } from '../../../../../../../workbench/contrib/void/common/voidSettingsService.js' import { ColorScheme } from '../../../../../../../platform/theme/common/theme.js' import { VoidUriState } from '../../../voidUriStateService.js'; import { VoidQuickEditState } from '../../../quickEditStateService.js' -import { RefreshModelStateOfProvider } from '../../../../../../../platform/void/common/refreshModelService.js' +import { RefreshModelStateOfProvider } from '../../../../../../../workbench/contrib/void/common/refreshModelService.js' @@ -25,9 +25,9 @@ import { IContextViewService, IContextMenuService } from '../../../../../../../p import { IFileService } from '../../../../../../../platform/files/common/files.js'; import { IHoverService } from '../../../../../../../platform/hover/browser/hover.js'; import { IThemeService } from '../../../../../../../platform/theme/common/themeService.js'; -import { ILLMMessageService } from '../../../../../../../platform/void/common/llmMessageService.js'; -import { IRefreshModelService } from '../../../../../../../platform/void/common/refreshModelService.js'; -import { IVoidSettingsService } from '../../../../../../../platform/void/common/voidSettingsService.js'; +import { ILLMMessageService } from '../../../../../../../workbench/contrib/void/common/llmMessageService.js'; +import { IRefreshModelService } from '../../../../../../../workbench/contrib/void/common/refreshModelService.js'; +import { IVoidSettingsService } from '../../../../../../../workbench/contrib/void/common/voidSettingsService.js'; import { IInlineDiffsService } from '../../../inlineDiffsService.js'; import { IVoidUriStateService } from '../../../voidUriStateService.js'; import { IQuickEditStateService } from '../../../quickEditStateService.js'; @@ -46,7 +46,7 @@ import { IKeybindingService } from '../../../../../../../platform/keybinding/com import { IEnvironmentService } from '../../../../../../../platform/environment/common/environment.js' import { IConfigurationService } from '../../../../../../../platform/configuration/common/configuration.js' import { IPathService } from '../../../../../../../workbench/services/path/common/pathService.js' -import { IMetricsService } from '../../../../../../../platform/void/common/metricsService.js' +import { IMetricsService } from '../../../../../../../workbench/contrib/void/common/metricsService.js' diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx index 8016b4b8..2931b671 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx @@ -4,13 +4,13 @@ *--------------------------------------------------------------------------------------*/ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import { FeatureName, featureNames, isFeatureNameDisabled, ModelSelection, modelSelectionsEqual, ProviderName, providerNames, SettingsOfProvider } from '../../../../../../../platform/void/common/voidSettingsTypes.js' +import { FeatureName, featureNames, isFeatureNameDisabled, ModelSelection, modelSelectionsEqual, ProviderName, providerNames, SettingsOfProvider } from '../../../../../../../workbench/contrib/void/common/voidSettingsTypes.js' import { useSettingsState, useRefreshModelState, useAccessor } from '../util/services.js' import { _VoidSelectBox, VoidCustomDropdownBox } from '../util/inputs.js' import { SelectBox } from '../../../../../../../base/browser/ui/selectBox/selectBox.js' import { IconWarning } from '../sidebar-tsx/SidebarChat.js' import { VOID_OPEN_SETTINGS_ACTION_ID, VOID_TOGGLE_SETTINGS_ACTION_ID } from '../../../voidSettingsPane.js' -import { ModelOption } from '../../../../../../../platform/void/common/voidSettingsService.js' +import { ModelOption } from '../../../../../../../workbench/contrib/void/common/voidSettingsService.js' import { WarningBox } from './WarningBox.js' const optionsEqual = (m1: ModelOption[], m2: ModelOption[]) => { diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx index 0cd796e4..62511563 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx @@ -5,7 +5,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { InputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js' -import { ProviderName, SettingName, displayInfoOfSettingName, providerNames, VoidModelInfo, globalSettingNames, customSettingNamesOfProvider, RefreshableProviderName, refreshableProviderNames, displayInfoOfProviderName, defaultProviderSettings, nonlocalProviderNames, localProviderNames, GlobalSettingName, featureNames, displayInfoOfFeatureName, isProviderNameDisabled } from '../../../../../../../platform/void/common/voidSettingsTypes.js' +import { ProviderName, SettingName, displayInfoOfSettingName, providerNames, VoidModelInfo, globalSettingNames, customSettingNamesOfProvider, RefreshableProviderName, refreshableProviderNames, displayInfoOfProviderName, defaultProviderSettings, nonlocalProviderNames, localProviderNames, GlobalSettingName, featureNames, displayInfoOfFeatureName, isProviderNameDisabled } from '../../../../common/voidSettingsTypes.js' import ErrorBoundary from '../sidebar-tsx/ErrorBoundary.js' import { VoidButton, VoidCheckBox, VoidCustomDropdownBox, VoidInputBox, VoidInputBox2, VoidSwitch } from '../util/inputs.js' import { useAccessor, useIsDark, useRefreshModelListener, useRefreshModelState, useSettingsState } from '../util/services.js' diff --git a/src/vs/workbench/contrib/void/browser/sidebarActions.ts b/src/vs/workbench/contrib/void/browser/sidebarActions.ts index 0b60ae8f..d65c51a7 100644 --- a/src/vs/workbench/contrib/void/browser/sidebarActions.ts +++ b/src/vs/workbench/contrib/void/browser/sidebarActions.ts @@ -17,7 +17,7 @@ import { ICodeEditorService } from '../../../../editor/browser/services/codeEdit import { IRange } from '../../../../editor/common/core/range.js'; import { ITextModel } from '../../../../editor/common/model.js'; import { VOID_VIEW_CONTAINER_ID, VOID_VIEW_ID } from './sidebarPane.js'; -import { IMetricsService } from '../../../../platform/void/common/metricsService.js'; +import { IMetricsService } from '../common/metricsService.js'; import { ISidebarStateService } from './sidebarStateService.js'; import { ICommandService } from '../../../../platform/commands/common/commands.js'; import { VOID_TOGGLE_SETTINGS_ACTION_ID } from './voidSettingsPane.js'; diff --git a/src/vs/workbench/contrib/void/browser/void.contribution.ts b/src/vs/workbench/contrib/void/browser/void.contribution.ts index 110a5a26..817b6a9a 100644 --- a/src/vs/workbench/contrib/void/browser/void.contribution.ts +++ b/src/vs/workbench/contrib/void/browser/void.contribution.ts @@ -33,3 +33,26 @@ import './media/void.css' // update (frontend part, also see platform/) import './voidUpdateActions.js' + + + + +// ---------- common ---------- + +// // llmMessage +// import '../common/llmMessageService.js' + +// // voidSettings +// import '../common/voidSettingsService.js' + +// // refreshModel +// import '../common/refreshModelService.js' + +// // metrics +// import '../common/metricsService.js' + +// // updates +// import '../common/voidUpdateService.js' + +// // tools +// import '../common/toolsService.js' diff --git a/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts b/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts index 04b263b4..9d161b4e 100644 --- a/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts +++ b/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts @@ -9,8 +9,8 @@ import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js import { localize2 } from '../../../../nls.js'; import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js'; import { INotificationService } from '../../../../platform/notification/common/notification.js'; -import { IMetricsService } from '../../../../platform/void/common/metricsService.js'; -import { IVoidUpdateService } from '../../../../platform/void/common/voidUpdateService.js'; +import { IMetricsService } from '../common/metricsService.js'; +import { IVoidUpdateService } from '../common/voidUpdateService.js'; import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js'; diff --git a/src/vs/platform/void/common/llmMessageService.ts b/src/vs/workbench/contrib/void/common/llmMessageService.ts similarity index 93% rename from src/vs/platform/void/common/llmMessageService.ts rename to src/vs/workbench/contrib/void/common/llmMessageService.ts index 4718e6c2..314031d4 100644 --- a/src/vs/platform/void/common/llmMessageService.ts +++ b/src/vs/workbench/contrib/void/common/llmMessageService.ts @@ -4,13 +4,14 @@ *--------------------------------------------------------------------------------------*/ import { EventLLMMessageOnTextParams, EventLLMMessageOnErrorParams, EventLLMMessageOnFinalMessageParams, ServiceSendLLMMessageParams, MainSendLLMMessageParams, MainLLMMessageAbortParams, ServiceModelListParams, EventModelListOnSuccessParams, EventModelListOnErrorParams, MainModelListParams, OllamaModelResponse, OpenaiCompatibleModelResponse, } from './llmMessageTypes.js'; -import { IChannel } from '../../../base/parts/ipc/common/ipc.js'; -import { IMainProcessService } from '../../ipc/common/mainProcessService.js'; -import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js'; -import { generateUuid } from '../../../base/common/uuid.js'; -import { createDecorator } from '../../instantiation/common/instantiation.js'; -import { Event } from '../../../base/common/event.js'; -import { Disposable } from '../../../base/common/lifecycle.js'; + +import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; +import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js'; +import { IChannel } from '../../../../base/parts/ipc/common/ipc.js'; +import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js'; +import { generateUuid } from '../../../../base/common/uuid.js'; +import { Event } from '../../../../base/common/event.js'; +import { Disposable } from '../../../../base/common/lifecycle.js'; import { IVoidSettingsService } from './voidSettingsService.js'; import { displayInfoOfProviderName, isFeatureNameDisabled } from './voidSettingsTypes.js'; // import { INotificationService } from '../../notification/common/notification.js'; diff --git a/src/vs/platform/void/common/llmMessageTypes.ts b/src/vs/workbench/contrib/void/common/llmMessageTypes.ts similarity index 100% rename from src/vs/platform/void/common/llmMessageTypes.ts rename to src/vs/workbench/contrib/void/common/llmMessageTypes.ts diff --git a/src/vs/platform/void/common/metricsService.ts b/src/vs/workbench/contrib/void/common/metricsService.ts similarity index 74% rename from src/vs/platform/void/common/metricsService.ts rename to src/vs/workbench/contrib/void/common/metricsService.ts index a3aeb6a8..d6892dd8 100644 --- a/src/vs/platform/void/common/metricsService.ts +++ b/src/vs/workbench/contrib/void/common/metricsService.ts @@ -3,14 +3,14 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { createDecorator } from '../../instantiation/common/instantiation.js'; -import { ProxyChannel } from '../../../base/parts/ipc/common/ipc.js'; -import { IMainProcessService } from '../../ipc/common/mainProcessService.js'; -import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js'; -import { Action2, registerAction2 } from '../../actions/common/actions.js'; -import { localize2 } from '../../../nls.js'; -import { ServicesAccessor } from '../../../editor/browser/editorExtensions.js'; -import { INotificationService } from '../../notification/common/notification.js'; +import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; +import { ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js'; +import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js'; +import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js'; +import { localize2 } from '../../../../nls.js'; +import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js'; +import { registerAction2, Action2 } from '../../../../platform/actions/common/actions.js'; +import { INotificationService } from '../../../../platform/notification/common/notification.js'; export interface IMetricsService { readonly _serviceBrand: undefined; diff --git a/src/vs/platform/void/common/refreshModelService.ts b/src/vs/workbench/contrib/void/common/refreshModelService.ts similarity index 95% rename from src/vs/platform/void/common/refreshModelService.ts rename to src/vs/workbench/contrib/void/common/refreshModelService.ts index 7ef6a068..ff61e8a8 100644 --- a/src/vs/platform/void/common/refreshModelService.ts +++ b/src/vs/workbench/contrib/void/common/refreshModelService.ts @@ -3,14 +3,14 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { createDecorator } from '../../instantiation/common/instantiation.js'; -import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js'; import { IVoidSettingsService } from './voidSettingsService.js'; import { ILLMMessageService } from './llmMessageService.js'; -import { Emitter, Event } from '../../../base/common/event.js'; -import { Disposable, IDisposable } from '../../../base/common/lifecycle.js'; +import { Emitter, Event } from '../../../../base/common/event.js'; +import { Disposable, IDisposable } from '../../../../base/common/lifecycle.js'; import { RefreshableProviderName, refreshableProviderNames, SettingsOfProvider } from './voidSettingsTypes.js'; import { OllamaModelResponse, OpenaiCompatibleModelResponse } from './llmMessageTypes.js'; +import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js'; +import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; diff --git a/src/vs/platform/void/common/toolsService.ts b/src/vs/workbench/contrib/void/common/toolsService.ts similarity index 86% rename from src/vs/platform/void/common/toolsService.ts rename to src/vs/workbench/contrib/void/common/toolsService.ts index 2a0c051c..8ffd6b9b 100644 --- a/src/vs/platform/void/common/toolsService.ts +++ b/src/vs/workbench/contrib/void/common/toolsService.ts @@ -1,12 +1,12 @@ -import { CancellationToken } from '../../../base/common/cancellation.js' -import { URI } from '../../../base/common/uri.js' -import { VSReadFileRaw } from '../../../workbench/contrib/void/browser/helpers/readFile.js' -import { QueryBuilder } from '../../../workbench/services/search/common/queryBuilder.js' -import { ISearchService } from '../../../workbench/services/search/common/search.js' -import { IFileService, IFileStat } from '../../files/common/files.js' -import { registerSingleton, InstantiationType } from '../../instantiation/common/extensions.js' -import { createDecorator, IInstantiationService } from '../../instantiation/common/instantiation.js' -import { IWorkspaceContextService } from '../../workspace/common/workspace.js' +import { CancellationToken } from '../../../../base/common/cancellation.js' +import { URI } from '../../../../base/common/uri.js' +import { IFileService, IFileStat } from '../../../../platform/files/common/files.js' +import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js' +import { createDecorator, IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' +import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js' +import { VSReadFileRaw } from '../../../../workbench/contrib/void/browser/helpers/readFile.js' +import { QueryBuilder } from '../../../../workbench/services/search/common/queryBuilder.js' +import { ISearchService } from '../../../../workbench/services/search/common/search.js' // tool use for AI diff --git a/src/vs/platform/void/common/voidSettingsService.ts b/src/vs/workbench/contrib/void/common/voidSettingsService.ts similarity index 95% rename from src/vs/platform/void/common/voidSettingsService.ts rename to src/vs/workbench/contrib/void/common/voidSettingsService.ts index e9c57aa2..4322eaf4 100644 --- a/src/vs/platform/void/common/voidSettingsService.ts +++ b/src/vs/workbench/contrib/void/common/voidSettingsService.ts @@ -3,13 +3,13 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { Emitter, Event } from '../../../base/common/event.js'; -import { Disposable } from '../../../base/common/lifecycle.js'; -import { deepClone } from '../../../base/common/objects.js'; -import { IEncryptionService } from '../../encryption/common/encryptionService.js'; -import { registerSingleton, InstantiationType } from '../../instantiation/common/extensions.js'; -import { createDecorator } from '../../instantiation/common/instantiation.js'; -import { IStorageService, StorageScope, StorageTarget } from '../../storage/common/storage.js'; +import { Emitter, Event } from '../../../../base/common/event.js'; +import { Disposable } from '../../../../base/common/lifecycle.js'; +import { deepClone } from '../../../../base/common/objects.js'; +import { IEncryptionService } from '../../../../platform/encryption/common/encryptionService.js'; +import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js'; +import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; +import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js'; import { IMetricsService } from './metricsService.js'; import { defaultSettingsOfProvider, FeatureName, ProviderName, ModelSelectionOfFeature, SettingsOfProvider, SettingName, providerNames, ModelSelection, modelSelectionsEqual, featureNames, modelInfoOfDefaultModelNames, VoidModelInfo, GlobalSettings, GlobalSettingName, defaultGlobalSettings, displayInfoOfProviderName, defaultProviderSettings } from './voidSettingsTypes.js'; diff --git a/src/vs/platform/void/common/voidSettingsTypes.ts b/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts similarity index 100% rename from src/vs/platform/void/common/voidSettingsTypes.ts rename to src/vs/workbench/contrib/void/common/voidSettingsTypes.ts diff --git a/src/vs/platform/void/common/voidUpdateService.ts b/src/vs/workbench/contrib/void/common/voidUpdateService.ts similarity index 78% rename from src/vs/platform/void/common/voidUpdateService.ts rename to src/vs/workbench/contrib/void/common/voidUpdateService.ts index fd3467dd..f552594f 100644 --- a/src/vs/platform/void/common/voidUpdateService.ts +++ b/src/vs/workbench/contrib/void/common/voidUpdateService.ts @@ -3,10 +3,10 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { createDecorator } from '../../instantiation/common/instantiation.js'; -import { ProxyChannel } from '../../../base/parts/ipc/common/ipc.js'; -import { IMainProcessService } from '../../ipc/common/mainProcessService.js'; -import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js'; +import { ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js'; +import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js'; +import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; +import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js'; diff --git a/src/vs/platform/void/electron-main/llmMessage/anthropic.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/anthropic.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/anthropic.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/anthropic.ts diff --git a/src/vs/platform/void/electron-main/llmMessage/gemini.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/gemini.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/gemini.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/gemini.ts diff --git a/src/vs/platform/void/electron-main/llmMessage/groq.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/groq.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/groq.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/groq.ts diff --git a/src/vs/platform/void/electron-main/llmMessage/mistral.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/mistral.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/mistral.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/mistral.ts diff --git a/src/vs/platform/void/electron-main/llmMessage/ollama.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/ollama.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/ollama.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/ollama.ts diff --git a/src/vs/platform/void/electron-main/llmMessage/openai.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/openai.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/openai.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/openai.ts diff --git a/src/vs/platform/void/electron-main/llmMessage/sendLLMMessage.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/sendLLMMessage.ts similarity index 100% rename from src/vs/platform/void/electron-main/llmMessage/sendLLMMessage.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessage/sendLLMMessage.ts diff --git a/src/vs/platform/void/electron-main/llmMessageChannel.ts b/src/vs/workbench/contrib/void/electron-main/llmMessageChannel.ts similarity index 97% rename from src/vs/platform/void/electron-main/llmMessageChannel.ts rename to src/vs/workbench/contrib/void/electron-main/llmMessageChannel.ts index 3575e34e..98725631 100644 --- a/src/vs/platform/void/electron-main/llmMessageChannel.ts +++ b/src/vs/workbench/contrib/void/electron-main/llmMessageChannel.ts @@ -6,8 +6,8 @@ // registered in app.ts // code convention is to make a service responsible for this stuff, and not a channel, but having fewer files is simpler... -import { IServerChannel } from '../../../base/parts/ipc/common/ipc.js'; -import { Emitter, Event } from '../../../base/common/event.js'; +import { IServerChannel } from '../../../../base/parts/ipc/common/ipc.js'; +import { Emitter, Event } from '../../../../base/common/event.js'; import { EventLLMMessageOnTextParams, EventLLMMessageOnErrorParams, EventLLMMessageOnFinalMessageParams, MainSendLLMMessageParams, AbortRef, SendLLMMessageParams, MainLLMMessageAbortParams, MainModelListParams, ModelListParams, EventModelListOnSuccessParams, EventModelListOnErrorParams, OllamaModelResponse, OpenaiCompatibleModelResponse, } from '../common/llmMessageTypes.js'; import { sendLLMMessage } from './llmMessage/sendLLMMessage.js' import { IMetricsService } from '../common/metricsService.js'; diff --git a/src/vs/platform/void/electron-main/metricsMainService.ts b/src/vs/workbench/contrib/void/electron-main/metricsMainService.ts similarity index 86% rename from src/vs/platform/void/electron-main/metricsMainService.ts rename to src/vs/workbench/contrib/void/electron-main/metricsMainService.ts index cd8abf2b..592f79c4 100644 --- a/src/vs/platform/void/electron-main/metricsMainService.ts +++ b/src/vs/workbench/contrib/void/electron-main/metricsMainService.ts @@ -3,14 +3,13 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { Disposable } from '../../../base/common/lifecycle.js'; -import { isLinux, isMacintosh, isWindows } from '../../../base/common/platform.js'; -import { generateUuid } from '../../../base/common/uuid.js'; -import { IEnvironmentMainService } from '../../environment/electron-main/environmentMainService.js'; - -import { IProductService } from '../../product/common/productService.js'; -import { StorageScope, StorageTarget } from '../../storage/common/storage.js'; -import { IApplicationStorageMainService } from '../../storage/electron-main/storageMainService.js'; +import { Disposable } from '../../../../base/common/lifecycle.js'; +import { isLinux, isMacintosh, isWindows } from '../../../../base/common/platform.js'; +import { generateUuid } from '../../../../base/common/uuid.js'; +import { IEnvironmentMainService } from '../../../../platform/environment/electron-main/environmentMainService.js'; +import { IProductService } from '../../../../platform/product/common/productService.js'; +import { StorageTarget, StorageScope } from '../../../../platform/storage/common/storage.js'; +import { IApplicationStorageMainService } from '../../../../platform/storage/electron-main/storageMainService.js'; import { IMetricsService } from '../common/metricsService.js'; import { PostHog } from 'posthog-node' diff --git a/src/vs/platform/void/electron-main/templates/templates.ts b/src/vs/workbench/contrib/void/electron-main/templates/templates.ts similarity index 100% rename from src/vs/platform/void/electron-main/templates/templates.ts rename to src/vs/workbench/contrib/void/electron-main/templates/templates.ts diff --git a/src/vs/platform/void/electron-main/voidUpdateMainService.ts b/src/vs/workbench/contrib/void/electron-main/voidUpdateMainService.ts similarity index 82% rename from src/vs/platform/void/electron-main/voidUpdateMainService.ts rename to src/vs/workbench/contrib/void/electron-main/voidUpdateMainService.ts index 029db5f4..c691ff56 100644 --- a/src/vs/platform/void/electron-main/voidUpdateMainService.ts +++ b/src/vs/workbench/contrib/void/electron-main/voidUpdateMainService.ts @@ -3,10 +3,9 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { Disposable } from '../../../base/common/lifecycle.js'; -import { IEnvironmentMainService } from '../../environment/electron-main/environmentMainService.js'; - -import { IProductService } from '../../product/common/productService.js'; +import { Disposable } from '../../../../base/common/lifecycle.js'; +import { IEnvironmentMainService } from '../../../../platform/environment/electron-main/environmentMainService.js'; +import { IProductService } from '../../../../platform/product/common/productService.js'; import { IVoidUpdateService } from '../common/voidUpdateService.js'; diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index 14f3fec1..394da127 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -17,7 +17,6 @@ import './browser/workbench.contribution.js'; //#region --- Void // Void added this: import './contrib/void/browser/void.contribution.js'; -import '../platform/void/browser/void.contribution.js'; //#endregion From e2e8279fce2c3c0d142ce7b69dcfbcc71e4270f6 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 10 Feb 2025 20:18:45 -0800 Subject: [PATCH 15/17] add back imports --- .../react/src/sidebar-tsx/SidebarChat.tsx | 2 +- .../contrib/void/browser/void.contribution.ts | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 0816dac5..ddc52f72 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -702,7 +702,7 @@ const ChatBubble = ({ chatMessage, isLoading, messageIdx }: { chatMessage: ChatM `} > {chatbubbleContents} - {isLoading && } + {isLoading && } {/* edit button */} diff --git a/src/vs/workbench/contrib/void/browser/void.contribution.ts b/src/vs/workbench/contrib/void/browser/void.contribution.ts index 817b6a9a..19d20201 100644 --- a/src/vs/workbench/contrib/void/browser/void.contribution.ts +++ b/src/vs/workbench/contrib/void/browser/void.contribution.ts @@ -37,22 +37,22 @@ import './voidUpdateActions.js' -// ---------- common ---------- +// ---------- common (unclear if these actually need to be imported, because they're already imported wherever they're used) ---------- -// // llmMessage -// import '../common/llmMessageService.js' +// llmMessage +import '../common/llmMessageService.js' -// // voidSettings -// import '../common/voidSettingsService.js' +// voidSettings +import '../common/voidSettingsService.js' -// // refreshModel -// import '../common/refreshModelService.js' +// refreshModel +import '../common/refreshModelService.js' -// // metrics -// import '../common/metricsService.js' +// metrics +import '../common/metricsService.js' -// // updates -// import '../common/voidUpdateService.js' +// updates +import '../common/voidUpdateService.js' -// // tools -// import '../common/toolsService.js' +// tools +import '../common/toolsService.js' From 96b5b72d30590fd895aaeed79159734f5c0656d6 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 10 Feb 2025 20:22:31 -0800 Subject: [PATCH 16/17] triple tick --- .../contrib/void/browser/prompt/prompts.ts | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/prompt/prompts.ts b/src/vs/workbench/contrib/void/browser/prompt/prompts.ts index 468de855..a13a7deb 100644 --- a/src/vs/workbench/contrib/void/browser/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/browser/prompt/prompts.ts @@ -10,6 +10,10 @@ import { CodeSelection, StagingSelectionItem, FileSelection } from '../chatThrea import { VSReadFile } from '../helpers/readFile.js'; import { IModelService } from '../../../../../editor/common/services/model.js'; + +// this is just for ease of readability +const tripleTick = ['```', '```'] + export const chat_systemMessage = `\ You are a coding assistant. You are given a list of instructions to follow \`INSTRUCTIONS\`, and optionally a list of relevant files \`FILES\`, and selections inside of files \`SELECTIONS\`. @@ -29,7 +33,7 @@ Do not tell the user anything about the examples below. ## EXAMPLE 1 FILES math.ts -\`\`\`typescript +${tripleTick[0]}typescript const addNumbers = (a, b) => a + b const multiplyNumbers = (a, b) => a * b const subtractNumbers = (a, b) => a - b @@ -58,21 +62,21 @@ const normalized = (vector: number[]) => { const v2 = [...vector] // clone vector return normalize(v2) } -\`\`\` +${tripleTick[1]} SELECTIONS math.ts (lines 3:3) -\`\`\`typescript +${tripleTick[0]}typescript const subtractNumbers = (a, b) => a - b -\`\`\` +${tripleTick[1]} INSTRUCTIONS add a function that exponentiates a number below this, and use it to make a power function that raises all entries of a vector to a power ACCEPTED OUTPUT We can add the following code to the file: -\`\`\`typescript +${tripleTick[0]}typescript // existing code... const subtractNumbers = (a, b) => a - b const exponentiateNumbers = (a, b) => Math.pow(a, b) @@ -84,13 +88,13 @@ const raiseAll = (vector: number[], power: number) => { vector[i] = exponentiateNumbers(vector[i], power) return vector } -\`\`\` +${tripleTick[1]} ## EXAMPLE 2 FILES fib.ts -\`\`\`typescript +${tripleTick[0]}typescript const dfs = (root) => { if (!root) return; @@ -102,20 +106,20 @@ const fib = (n) => { if (n < 1) return 1 return fib(n - 1) + fib(n - 2) } -\`\`\` +${tripleTick[1]} SELECTIONS fib.ts (lines 10:10) -\`\`\`typescript +${tripleTick[0]}typescript return fib(n - 1) + fib(n - 2) -\`\`\` +${tripleTick[1]} INSTRUCTIONS memoize results ACCEPTED OUTPUT To implement memoization in your Fibonacci function, you can use a JavaScript object to store previously computed results. This will help avoid redundant calculations and improve performance. Here's how you can modify your function: -\`\`\`typescript +${tripleTick[0]}typescript // existing code... const fib = (n, memo = {}) => { if (n < 1) return 1; @@ -123,7 +127,7 @@ const fib = (n, memo = {}) => { memo[n] = fib(n - 1, memo) + fib(n - 2, memo); // Store result in memo return memo[n]; } -\`\`\` +${tripleTick[1]} Explanation: Memoization Object: A memo object is used to store the results of Fibonacci calculations for each n. Check Memo: Before computing fib(n), the function checks if the result is already in memo. If it is, it returns the stored result. @@ -137,17 +141,17 @@ type FileSelnLocal = { fileURI: URI, content: string } const stringifyFileSelection = ({ fileURI, content }: FileSelnLocal) => { return `\ ${fileURI.fsPath} -\`\`\`${filenameToVscodeLanguage(fileURI.fsPath) ?? ''} +${tripleTick[0]}${filenameToVscodeLanguage(fileURI.fsPath) ?? ''} ${content} -\`\`\` +${tripleTick[1]} ` } const stringifyCodeSelection = ({ fileURI, selectionStr, range }: CodeSelection) => { return `\ ${fileURI.fsPath} (lines ${range.startLineNumber}:${range.endLineNumber}) -\`\`\`${filenameToVscodeLanguage(fileURI.fsPath) ?? ''} +${tripleTick[0]}${filenameToVscodeLanguage(fileURI.fsPath) ?? ''} ${selectionStr} -\`\`\` +${tripleTick[1]} ` } @@ -201,14 +205,14 @@ export const fastApply_userMessage = ({ originalCode, applyStr, uri }: { origina return `\ ORIGINAL_FILE -\`\`\`${language} +${tripleTick[0]}${language} ${originalCode} -\`\`\` +${tripleTick[1]} CHANGE -\`\`\` +${tripleTick[0]} ${applyStr} -\`\`\` +${tripleTick[1]} INSTRUCTIONS Please finish writing the new file by applying the change to the original file. Return ONLY the completion of the file, without any explanation. @@ -309,9 +313,9 @@ export const ctrlKStream_userMessage = ({ selection, prefix, suffix, instruction return `\ CURRENT SELECTION -\`\`\`${language} +${tripleTick[0]}${language} <${midTag}>${selection} -\`\`\` +${tripleTick[1]} INSTRUCTIONS ${instructions} @@ -319,8 +323,8 @@ ${instructions} <${preTag}>${prefix} <${sufTag}>${suffix} -Return only the completion block of code (of the form \`\`\`${language} +Return only the completion block of code (of the form ${tripleTick[0]}${language} <${midTag}>...new code -\`\`\`).` +${tripleTick[1]}).` }; From 2161d740dfd9961ea24ff056b2504160400c848f Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Tue, 11 Feb 2025 16:44:40 -0800 Subject: [PATCH 17/17] minor change --- .../void/browser/autocompleteService.ts | 3 +-- .../void/electron-main/llmMessage/openai.ts | 18 ++---------------- .../llmMessage/sendLLMMessage.ts | 19 +++++++------------ 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/autocompleteService.ts b/src/vs/workbench/contrib/void/browser/autocompleteService.ts index 77ac8807..aa8902f3 100644 --- a/src/vs/workbench/contrib/void/browser/autocompleteService.ts +++ b/src/vs/workbench/contrib/void/browser/autocompleteService.ts @@ -784,8 +784,7 @@ export class AutocompleteService extends Disposable implements IAutocompleteServ _newlineCount: 0, } - console.log('BB') - console.log('type', predictionType) + console.log('starting autocomplete...', predictionType) // set parameters of `newAutocompletion` appropriately newAutocompletion.llmPromise = new Promise((resolve, reject) => { diff --git a/src/vs/workbench/contrib/void/electron-main/llmMessage/openai.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/openai.ts index 1ac2a748..df4d2322 100644 --- a/src/vs/workbench/contrib/void/electron-main/llmMessage/openai.ts +++ b/src/vs/workbench/contrib/void/electron-main/llmMessage/openai.ts @@ -109,23 +109,9 @@ export const openaiCompatibleList: _InternalModelListFnType = async ({ on export const sendOpenAIFIM: _InternalSendLLMFIMMessageFnType = ({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }) => { - const openai: OpenAI = newOpenAI({ providerName, settingsOfProvider }) + // openai.completions has a FIM parameter called `suffix`, but it's deprecated and only works for ~GPT 3 era models - const options: OpenAI.Completions.CompletionCreateParamsStreaming = { - prompt: messages.prefix, - suffix: messages.suffix, - model: modelName, - stream: true, - // max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens) - } - - - openai.completions - .create(options) - .then(async response => { - // TODO!!! - console.log('RESPONSE', response) - }) + onFinalMessage({ fullText: 'TODO' }) } diff --git a/src/vs/workbench/contrib/void/electron-main/llmMessage/sendLLMMessage.ts b/src/vs/workbench/contrib/void/electron-main/llmMessage/sendLLMMessage.ts index ffffc223..1364e251 100644 --- a/src/vs/workbench/contrib/void/electron-main/llmMessage/sendLLMMessage.ts +++ b/src/vs/workbench/contrib/void/electron-main/llmMessage/sendLLMMessage.ts @@ -8,7 +8,7 @@ import { IMetricsService } from '../../common/metricsService.js'; import { sendAnthropicChat } from './anthropic.js'; import { sendOllamaFIM, sendOllamaChat } from './ollama.js'; -import { sendOpenAIChat } from './openai.js'; +import { sendOpenAIChat, sendOpenAIFIM } from './openai.js'; import { sendGeminiChat } from './gemini.js'; import { sendGroqChat } from './groq.js'; import { sendMistralChat } from './mistral.js'; @@ -143,21 +143,16 @@ export const sendLLMMessage = ({ case 'openRouter': case 'deepseek': case 'openAICompatible': - sendOpenAIChat({ messages: messagesArr, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); + if (messagesType === 'FIMMessage') sendOpenAIFIM({ messages: messages_, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); + else /* */ sendOpenAIChat({ messages: messagesArr, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); + break; + case 'ollama': + if (messagesType === 'FIMMessage') sendOllamaFIM({ messages: messages_, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }) + else /* */ sendOllamaChat({ messages: messagesArr, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }) break; case 'gemini': sendGeminiChat({ messages: messagesArr, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); break; - case 'ollama': - if ( // TODO @andrew in future we want to use our own templates instead of using ollamaFIM - messagesType === 'FIMMessage' - && settingsOfProvider['ollama']._didFillInProviderSettings - && settingsOfProvider['ollama'].models.some(m => !m.isHidden) - ) - sendOllamaFIM({ messages: messages_, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }) - else - sendOllamaChat({ messages: messagesArr, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); - break; case 'groq': sendGroqChat({ messages: messagesArr, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); break;