diff --git a/src/vs/platform/void/electron-main/llmMessageChannel.ts b/src/vs/platform/void/electron-main/llmMessageChannel.ts index 9fb7224a..dd437286 100644 --- a/src/vs/platform/void/electron-main/llmMessageChannel.ts +++ b/src/vs/platform/void/electron-main/llmMessageChannel.ts @@ -10,7 +10,7 @@ import { IServerChannel } from '../../../base/parts/ipc/common/ipc.js'; import { Emitter, Event } from '../../../base/common/event.js'; -import { sendLLMMessage } from '../../../workbench/contrib/void/browser/react/out/util/sendLLMMessage.js'; +import { sendLLMMessage } from '../../../workbench/contrib/void/browser/react/out/sendLLMMessage/sendLLMMessage.js'; import { listenerNames, ProxyOnTextPayload, ProxyOnErrorPayload, ProxyOnFinalMessagePayload, ProxyLLMMessageParams, AbortRef, SendLLMMMessageParams, ProxyLLMMessageAbortParams } from '../common/llmMessageTypes.js'; // NODE IMPLEMENTATION OF SENDLLMMESSAGE - calls sendLLMMessage() and returns listeners diff --git a/src/vs/workbench/contrib/void/browser/react/build.js b/src/vs/workbench/contrib/void/browser/react/build.js index 5383c4a4..481591da 100755 --- a/src/vs/workbench/contrib/void/browser/react/build.js +++ b/src/vs/workbench/contrib/void/browser/react/build.js @@ -10,4 +10,4 @@ execSync('npx scope-tailwind ./src -o src2/ -s void-scope -c styles.css -p "pref execSync('npx tsup') -console.log('✅ Done building! Press Cmd+Shift+B again.') +console.log('✅ Done building! Kill your build script(s) (Ctrl+D in them), then press Cmd+Shift+B again.') diff --git a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/anthropic.tsx b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/anthropic.tsx index 4879d2c9..36fa78ac 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/anthropic.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/anthropic.tsx @@ -9,7 +9,9 @@ type LLMMessageAnthropic = { } export const sendAnthropicMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinalMessage, onError, voidConfig, _setAborter }) => { - const anthropic = new Anthropic({ apiKey: voidConfig.anthropic.apikey, dangerouslyAllowBrowser: true }); // defaults to process.env["ANTHROPIC_API_KEY"] + const thisConfig = voidConfig.anthropic + + const anthropic = new Anthropic({ apiKey: thisConfig.apikey, dangerouslyAllowBrowser: true }); // defaults to process.env["ANTHROPIC_API_KEY"] // find system messages and concatenate them const systemMessage = messages @@ -23,7 +25,7 @@ export const sendAnthropicMsg: SendLLMMessageFnTypeInternal = ({ messages, onTex const stream = anthropic.messages.stream({ system: systemMessage, messages: anthropicMessages, - model: voidConfig.anthropic.model, + model: thisConfig.model, max_tokens: parseMaxTokensStr(voidConfig.default.maxTokens)!, // this might be undefined, but it will just throw an error for the user }); diff --git a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/gemini.tsx b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/gemini.tsx index 3f350fee..5a883177 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/gemini.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/gemini.tsx @@ -6,8 +6,10 @@ export const sendGeminiMsg: SendLLMMessageFnTypeInternal = async ({ messages, on let fullText = '' - const genAI = new GoogleGenerativeAI(voidConfig.gemini.apikey); - const model = genAI.getGenerativeModel({ model: voidConfig.gemini.model }); + const thisConfig = voidConfig.gemini + + const genAI = new GoogleGenerativeAI(thisConfig.apikey); + const model = genAI.getGenerativeModel({ model: thisConfig.model }); // remove system messages that get sent to Gemini // str of all system messages diff --git a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/greptile.tsx b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/greptile.tsx index 81daada3..eb7b4596 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/greptile.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/greptile.tsx @@ -9,17 +9,19 @@ export const sendGreptileMsg: SendLLMMessageFnTypeInternal = ({ messages, onText let fullText = '' + const thisConfig = voidConfig.greptile + fetch('https://api.greptile.com/v2/query', { method: 'POST', headers: { - 'Authorization': `Bearer ${voidConfig.greptile.apikey}`, - 'X-Github-Token': `${voidConfig.greptile.githubPAT}`, + 'Authorization': `Bearer ${thisConfig.apikey}`, + 'X-Github-Token': `${thisConfig.githubPAT}`, 'Content-Type': `application/json`, }, body: JSON.stringify({ messages, stream: true, - repositories: [voidConfig.greptile.repoinfo], + repositories: [thisConfig.repoinfo], }), }) // this is {message}\n{message}\n{message}...\n diff --git a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/ollama.tsx b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/ollama.tsx index 95f10a2e..44b7ff1e 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/ollama.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/ollama.tsx @@ -5,12 +5,14 @@ import { SendLLMMessageFnTypeInternal } from './_types.js'; // Ollama export const sendOllamaMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinalMessage, onError, voidConfig, _setAborter }) => { + const thisConfig = voidConfig.ollama + let fullText = '' - const ollama = new Ollama({ host: voidConfig.ollama.endpoint }) + const ollama = new Ollama({ host: thisConfig.endpoint }) ollama.chat({ - model: voidConfig.ollama.model, + model: thisConfig.model, messages: messages, stream: true, options: { num_predict: parseMaxTokensStr(voidConfig.default.maxTokens) } // this is max_tokens diff --git a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/openai.tsx b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/openai.tsx index 545787d1..78d6671a 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/openai.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sendLLMMessage/openai.tsx @@ -14,22 +14,25 @@ export const sendOpenAIMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, const maxTokens = parseMaxTokensStr(voidConfig.default.maxTokens) if (voidConfig.default.whichApi === 'openAI') { - openai = new OpenAI({ apiKey: voidConfig.openAI.apikey, dangerouslyAllowBrowser: true }); - options = { model: voidConfig.openAI.model, messages: messages, stream: true, max_completion_tokens: maxTokens } + const thisConfig = voidConfig.openAI + openai = new OpenAI({ apiKey: thisConfig.apikey, dangerouslyAllowBrowser: true }); + options = { model: thisConfig.model, messages: messages, stream: true, max_completion_tokens: maxTokens } } else if (voidConfig.default.whichApi === 'openRouter') { + const thisConfig = voidConfig.openRouter openai = new OpenAI({ - baseURL: 'https://openrouter.ai/api/v1', apiKey: voidConfig.openRouter.apikey, dangerouslyAllowBrowser: true, + baseURL: 'https://openrouter.ai/api/v1', apiKey: thisConfig.apikey, dangerouslyAllowBrowser: true, defaultHeaders: { 'HTTP-Referer': 'https://voideditor.com', // Optional, for including your app on openrouter.ai rankings. 'X-Title': 'Void Editor', // Optional. Shows in rankings on openrouter.ai. }, }); - options = { model: voidConfig.openRouter.model, messages: messages, stream: true, max_completion_tokens: maxTokens } + options = { model: thisConfig.model, messages: messages, stream: true, max_completion_tokens: maxTokens } } else if (voidConfig.default.whichApi === 'openAICompatible') { - openai = new OpenAI({ baseURL: voidConfig.openAICompatible.endpoint, apiKey: voidConfig.openAICompatible.apikey, dangerouslyAllowBrowser: true }) - options = { model: voidConfig.openAICompatible.model, messages: messages, stream: true, max_completion_tokens: maxTokens } + const thisConfig = voidConfig.openAICompatible + openai = new OpenAI({ baseURL: thisConfig.endpoint, apiKey: thisConfig.apikey, dangerouslyAllowBrowser: true }) + options = { model: thisConfig.model, messages: messages, stream: true, max_completion_tokens: maxTokens } } else { console.error(`sendOpenAIMsg: invalid whichApi: ${voidConfig.default.whichApi}`) diff --git a/src/vs/workbench/contrib/void/browser/react/tsup.config.js b/src/vs/workbench/contrib/void/browser/react/tsup.config.js index a3432000..45039566 100644 --- a/src/vs/workbench/contrib/void/browser/react/tsup.config.js +++ b/src/vs/workbench/contrib/void/browser/react/tsup.config.js @@ -3,7 +3,7 @@ import { defineConfig } from 'tsup' export default defineConfig({ entry: [ './src2/sidebar-tsx/Sidebar.tsx', - './src2/util/sendLLMMessage.tsx', + './src2/sendLLMMessage/sendLLMMessage.tsx', './src2/util/posthog.tsx', './src2/util/diffLines.tsx', ],