Skip to content

Commit

Permalink
chore: improve settings (#1)
Browse files Browse the repository at this point in the history
* refactor: refine `anthropic` and `openai` settings

* refactor: improve configuration

* chore: move to headers config

* fix: ollama baseURL, add description

* chore: change azure deploymentId

* chore: eslint

* chore: update allowed_urls
  • Loading branch information
okxiaoliang4 authored Sep 21, 2024
1 parent 78e10a5 commit 7b31f28
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 281 deletions.
308 changes: 285 additions & 23 deletions extensions/void/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,297 @@
"configuration": {
"title": "API Keys",
"properties": {
"void.whichApi": {
"void.provider": {
"type": "string",
"default": "anthropic",
"description": "Choose a model to use (anthropic | openai | greptile | ollama)"
"description": "Choose a provider (openai | anthropic | azure | greptile | ollama)",
"enum": [
"openai",
"anthropic",
"azure",
"greptile",
"ollama"
]
},
"void.anthropicApiKey": {
"type": "string",
"default": "",
"description": "Anthropic API Key"
"void.anthropic": {
"type": "object",
"properties": {
"model": {
"type": "string",
"default": "claude-3-5-sonnet-20240620",
"description": "Choose a model ('claude-3-5-sonnet-20240620' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307')",
"enum": [
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307"
]
},
"providerSettings": {
"type": "object",
"properties": {
"baseURL": {
"type": "string",
"description": "Use a different URL prefix for API calls, e.g. to use proxy servers."
},
"apiKey": {
"type": "string",
"description": "Anthropic API key."
},
"headers": {
"type": "object",
"description": "Custom headers to include in the requests."
}
}
}
}
},
"void.openAIApiKey": {
"type": "string",
"default": "",
"description": "OpenAI API Key"
"void.openai": {
"type": "object",
"properties": {
"model": {
"type": "string",
"default": "gpt-4o",
"description": "Choose a model ('o1-preview' | 'o1-mini' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106')",
"enum": [
"o1-preview",
"o1-mini",
"gpt-4o",
"gpt-4o-2024-05-13",
"gpt-4o-2024-08-06",
"gpt-4o-mini",
"gpt-4o-mini-2024-07-18",
"gpt-4-turbo",
"gpt-4-turbo-2024-04-09",
"gpt-4-turbo-preview",
"gpt-4-0125-preview",
"gpt-4-1106-preview",
"gpt-4",
"gpt-4-0613",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo",
"gpt-3.5-turbo-1106"
]
},
"providerSettings": {
"type": "object",
"properties": {
"baseURL": {
"type": "string",
"description": "Use a different URL prefix for API calls, e.g. to use proxy servers."
},
"apiKey": {
"type": "string",
"description": "OpenAI API key."
},
"headers": {
"type": "object",
"description": "Custom headers to include in the requests."
},
"organization": {
"type": "string",
"description": "OpenAI Organization."
},
"project": {
"type": "string",
"description": "OpenAI project."
},
"compatibility": {
"type": "string",
"description": "OpenAI compatibility mode. Should be set to `strict` when using the OpenAI API, and `compatible` when using 3rd party providers. In `compatible` mode, newer information such as streamOptions are not being sent. Defaults to 'compatible'.",
"enum": [
"strict",
"compatible"
]
}
}
}
}
},
"void.greptileApiKey": {
"type": "string",
"default": "",
"description": "Greptile API Key"
"void.azure": {
"type": "object",
"properties": {
"deploymentId": {
"type": "string",
"description": "Azure API deployment ID."
},
"providerSettings": {
"type": "object",
"properties": {
"apiKey": {
"type": "string",
"description": "Azure API key."
},
"baseURL": {
"type": "string",
"description": "Azure API base URL."
},
"resourceName": {
"type": "string",
"description": "Name of the Azure OpenAI resource. Either this or `baseURL` can be used. \nThe resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/deployments/{modelId}{path}`"
},
"headers": {
"type": "object",
"description": "Custom headers to include in the requests."
}
}
}
}
},
"void.githubPAT": {
"type": "string",
"default": "",
"description": "Greptile - Github PAT (gives Greptile access to your repo)"
"void.ollama": {
"type": "object",
"properties": {
"model": {
"type": "string",
"description": "Ollama model. 'codegemma' | 'codegemma:2b' | 'codegemma:7b' | 'codellama' | 'codellama:7b' | 'codellama:13b' | 'codellama:34b' | 'codellama:70b' | 'codellama:code' | 'codellama:python' | 'command-r' | 'command-r:35b' | 'command-r-plus' | 'command-r-plus:104b' | 'deepseek-coder-v2' | 'deepseek-coder-v2:16b' | 'deepseek-coder-v2:236b' | 'falcon2' | 'falcon2:11b' | 'firefunction-v2' | 'firefunction-v2:70b' | 'gemma' | 'gemma:2b' | 'gemma:7b' | 'gemma2' | 'gemma2:2b' | 'gemma2:9b' | 'gemma2:27b' | 'llama2' | 'llama2:7b' | 'llama2:13b' | 'llama2:70b' | 'llama3' | 'llama3:8b' | 'llama3:70b' | 'llama3-chatqa' | 'llama3-chatqa:8b' | 'llama3-chatqa:70b' | 'llama3-gradient' | 'llama3-gradient:8b' | 'llama3-gradient:70b' | 'llama3.1' | 'llama3.1:8b' | 'llama3.1:70b' | 'llama3.1:405b' | 'llava' | 'llava:7b' | 'llava:13b' | 'llava:34b' | 'llava-llama3' | 'llava-llama3:8b' | 'llava-phi3' | 'llava-phi3:3.8b' | 'mistral' | 'mistral:7b' | 'mistral-large' | 'mistral-large:123b' | 'mistral-nemo' | 'mistral-nemo:12b' | 'mixtral' | 'mixtral:8x7b' | 'mixtral:8x22b' | 'moondream' | 'moondream:1.8b' | 'openhermes' | 'openhermes:v2.5' | 'phi3' | 'phi3:3.8b' | 'phi3:14b' | 'phi3.5' | 'phi3.5:3.8b' | 'qwen' | 'qwen:7b' | 'qwen:14b' | 'qwen:32b' | 'qwen:72b' | 'qwen:110b' | 'qwen2' | 'qwen2:0.5b' | 'qwen2:1.5b' | 'qwen2:7b' | 'qwen2:72b' | 'smollm' | 'smollm:135m' | 'smollm:360m' | 'smollm:1.7b'",
"default": "llama3.1",
"enum": [
"codegemma",
"codegemma:2b",
"codegemma:7b",
"codellama",
"codellama:7b",
"codellama:13b",
"codellama:34b",
"codellama:70b",
"codellama:code",
"codellama:python",
"command-r",
"command-r:35b",
"command-r-plus",
"command-r-plus:104b",
"deepseek-coder-v2",
"deepseek-coder-v2:16b",
"deepseek-coder-v2:236b",
"falcon2",
"falcon2:11b",
"firefunction-v2",
"firefunction-v2:70b",
"gemma",
"gemma:2b",
"gemma:7b",
"gemma2",
"gemma2:2b",
"gemma2:9b",
"gemma2:27b",
"llama2",
"llama2:7b",
"llama2:13b",
"llama2:70b",
"llama3",
"llama3:8b",
"llama3:70b",
"llama3-chatqa",
"llama3-chatqa:8b",
"llama3-chatqa:70b",
"llama3-gradient",
"llama3-gradient:8b",
"llama3-gradient:70b",
"llama3.1",
"llama3.1:8b",
"llama3.1:70b",
"llama3.1:405b",
"llava",
"llava:7b",
"llava:13b",
"llava:34b",
"llava-llama3",
"llava-llama3:8b",
"llava-phi3",
"llava-phi3:3.8b",
"mistral",
"mistral:7b",
"mistral-large",
"mistral-large:123b",
"mistral-nemo",
"mistral-nemo:12b",
"mixtral",
"mixtral:8x7b",
"mixtral:8x22b",
"moondream",
"moondream:1.8b",
"openhermes",
"openhermes:v2.5",
"phi3",
"phi3:3.8b",
"phi3:14b",
"phi3.5",
"phi3.5:3.8b",
"qwen",
"qwen:7b",
"qwen:14b",
"qwen:32b",
"qwen:72b",
"qwen:110b",
"qwen2",
"qwen2:0.5b",
"qwen2:1.5b",
"qwen2:7b",
"qwen2:72b",
"smollm",
"smollm:135m",
"smollm:360m",
"smollm:1.7b"
]
},
"providerSettings": {
"type": "object",
"properties": {
"baseURL": {
"type": "string",
"description": "Ollama base URL. Local API server can be started with `OLLAMA_ORIGINS=* ollama serve`"
},
"headers": {
"type": "object",
"description": "Custom headers to include in the requests."
}
}
}
}
},
"void.ollamaSettings": {
"type": "string",
"default": "",
"description": "Ollama settings (coming soon...)"
"void.greptile": {
"type": "object",
"properties": {
"providerSettings": {
"type": "object",
"properties": {
"apikey": {
"type": "string",
"description": "Greptile API key."
},
"headers": {
"type": "object",
"description": "Custom headers to include in the requests.",
"properties": {
"X-Github-Token": {
"type": "string",
"description": "GitHub PAT."
}
}
},
"repoinfo": {
"type": "array",
"items": {
"type": "object",
"properties": {
"remote": {
"type": "string",
"description": "GitHub remote."
},
"repository": {
"type": "string",
"description": "GitHub repository."
},
"branch": {
"type": "string",
"description": "GitHub branch."
}
}
}
}
}
}
}
}
}
},
Expand Down Expand Up @@ -145,4 +407,4 @@
"ollama-ai-provider": "^0.15.0",
"openai": "^4.57.0"
}
}
}
18 changes: 15 additions & 3 deletions extensions/void/src/SidebarWebviewProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// renders the code from `src/sidebar`

import { AzureOpenAIProviderSettings } from '@ai-sdk/azure';
import * as vscode from 'vscode';

function getNonce() {
Expand Down Expand Up @@ -55,9 +56,20 @@ export class SidebarWebviewProvider implements vscode.WebviewViewProvider {
const nonce = getNonce(); // only scripts with the nonce are allowed to run, this is a recommended security measure


// Allow Ollama endpoint
const ollamaEndpoint = vscode.workspace.getConfiguration('void').get('ollamaSettings.endpoint') || 'http://localhost:11434'
const allowed_urls = ['https://api.anthropic.com', 'https://api.openai.com', 'https://api.greptile.com', ollamaEndpoint ]
const ollamaBaseURL = new URL('/', vscode.workspace.getConfiguration('void').get('ollama.providerSettings.baseURL') || 'http://127.0.0.1:11434').toString()
const azureProviderSettings = vscode.workspace.getConfiguration('void').get('azure.providerSettings') as AzureOpenAIProviderSettings
const azureBaseURL = new URL('/', vscode.workspace.getConfiguration('void').get('azure.providerSettings.baseURL') || `https://${azureProviderSettings.resourceName}.openai.azure.com/openai/deployments`).toString()
const openaiBaseURL = new URL('/', vscode.workspace.getConfiguration('void').get('openai.providerSettings.baseURL') || 'https://api.openai.com').toString()
const greptileBaseURL = new URL('/', vscode.workspace.getConfiguration('void').get('greptile.providerSettings.baseURL') || 'https://api.mistral.ai').toString()
const anthropicBaseURL = new URL('/', vscode.workspace.getConfiguration('void').get('anthropic.providerSettings.baseURL') || 'https://api.mistral.ai').toString()
const allowed_urls = [
ollamaBaseURL,
azureBaseURL,
openaiBaseURL,
greptileBaseURL,
anthropicBaseURL
]

webview.html = `<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
Loading

0 comments on commit 7b31f28

Please sign in to comment.