Merge pull request #42 from DaveHogan/main

Minor improvement to whichapi & anthropic configuration
This commit is contained in:
Andrew Pareles 2024-09-30 00:54:11 -07:00 committed by GitHub
commit 3fd9b572fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 5 deletions

View file

@ -19,7 +19,7 @@
"void.whichApi": {
"type": "string",
"default": "anthropic",
"description": "Choose a model to use",
"description": "Choose an API provider",
"enum": [
"anthropic",
"openai",
@ -32,6 +32,14 @@
"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.openAIApiKey": {
"type": "string",
"default": "",

View file

@ -6,6 +6,8 @@ import OpenAI from 'openai';
export type ApiConfig = {
anthropic: {
apikey: string,
model: string,
maxTokens: string
},
openai: {
apikey: string
@ -60,12 +62,11 @@ type SendLLMMessageFnTypeExternal = (params: {
// Claude
const sendClaudeMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinalMessage, apiConfig }) => {
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: parseInt(apiConfig.anthropic.maxTokens),
messages: messages,
});

View file

@ -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') ?? '',
},
openai: { apikey: vscode.workspace.getConfiguration('void').get('openAIApiKey') ?? '' },
greptile: {
apikey: vscode.workspace.getConfiguration('void').get('greptileApiKey') ?? '',

1
void Submodule

@ -0,0 +1 @@
Subproject commit 6d513a1e602c8dea3f89f85cc5a04d840a0abfa9