mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
Makes anthropic model and max_tokens configurable
Makes whichApi an enum for less error prone configuration
This commit is contained in:
parent
939aa008b3
commit
1843cd0878
3 changed files with 23 additions and 5 deletions
|
|
@ -18,13 +18,25 @@
|
|||
"void.whichApi": {
|
||||
"type": "string",
|
||||
"default": "anthropic",
|
||||
"description": "Choose a model to use (anthropic | openai | greptile | ollama)"
|
||||
"description": "Choose an API provider",
|
||||
"enum": ["anthropic", "openai", "greptile", "ollama"]
|
||||
},
|
||||
"void.anthropicApiKey": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Anthropic API Key"
|
||||
},
|
||||
"void.anthropicModel":{
|
||||
"type": "string",
|
||||
"default": "claude-3-5-sonnet-20240620",
|
||||
"description": "Anthropic Model to use",
|
||||
"enum": ["claude-3-5-sonnet-20240620"]
|
||||
},
|
||||
"void.anthropicMaxTokens":{
|
||||
"type": "number",
|
||||
"default": 1024,
|
||||
"description": "Max Token to use when using Anthropic API"
|
||||
},
|
||||
"void.openAIApiKey": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import OpenAI from 'openai';
|
|||
export type ApiConfig = {
|
||||
anthropic: {
|
||||
apikey: string,
|
||||
model: string,
|
||||
maxTokens: number
|
||||
},
|
||||
openai: {
|
||||
apikey: string
|
||||
|
|
@ -64,8 +66,8 @@ const sendClaudeMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinal
|
|||
const anthropic = new Anthropic({ apiKey: apiConfig.anthropic.apikey, dangerouslyAllowBrowser: true }); // defaults to process.env["ANTHROPIC_API_KEY"]
|
||||
|
||||
const stream = anthropic.messages.stream({
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
max_tokens: 1024,
|
||||
model: apiConfig.anthropic.model,
|
||||
max_tokens: apiConfig.anthropic.maxTokens,
|
||||
messages: messages,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ const readFileContentOfUri = async (uri: vscode.Uri) => {
|
|||
|
||||
const getApiConfig = () => {
|
||||
const apiConfig: ApiConfig = {
|
||||
anthropic: { apikey: vscode.workspace.getConfiguration('void').get('anthropicApiKey') ?? '' },
|
||||
anthropic: {
|
||||
apikey: vscode.workspace.getConfiguration('void').get('anthropicApiKey') ?? '',
|
||||
model: vscode.workspace.getConfiguration('void').get('anthropicModel') ?? '',
|
||||
maxTokens: vscode.workspace.getConfiguration('void').get('anthropicMaxToken') ?? 1024,
|
||||
},
|
||||
openai: { apikey: vscode.workspace.getConfiguration('void').get('openAIApiKey') ?? '' },
|
||||
greptile: {
|
||||
apikey: vscode.workspace.getConfiguration('void').get('greptileApiKey') ?? '',
|
||||
|
|
@ -27,7 +31,7 @@ const getApiConfig = () => {
|
|||
ollama: {
|
||||
// apikey: vscode.workspace.getConfiguration('void').get('ollamaSettings') ?? '',
|
||||
},
|
||||
whichApi: vscode.workspace.getConfiguration('void').get('whichApi') ?? ''
|
||||
whichApi: vscode.workspace.getConfiguration('void').get('whichApi') ?? 'anthropic'
|
||||
}
|
||||
return apiConfig
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue