chore: Update environment variable names for OpenAI Like integration

This commit is contained in:
Gaoyao Massimo Hu 2024-10-23 16:43:27 +01:00
parent 30dfa4fda4
commit 9f2db7b683
No known key found for this signature in database
GPG Key ID: E3A9EE580E0CB24C
5 changed files with 11 additions and 13 deletions

View File

@ -29,13 +29,11 @@ GOOGLE_GENERATIVE_AI_API_KEY=
# EXAMPLE http://localhost:11434
OLLAMA_API_BASE_URL=
# You only need this environment variable set if you want to use OpenAI API Like models
# EXAMPLE https://xxx.xxxx.com/v1
OPENAI_API_LIKE_BASE_URL=
# You only need this environment variable set if you want to use OpenAI Like models
OPENAI_LIKE_API_BASE_URL=
# Get your OpenAI API Like Key by following these instructions -
# https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key
OPENAI_API_LIKE_KEY=
# Get your OpenAI Like API Key
OPENAI_LIKE_API_KEY=
# Include this environment variable if you want more logging for debugging locally
VITE_LOG_LEVEL=debug

View File

@ -20,7 +20,7 @@ export function getAPIKey(cloudflareEnv: Env, provider: string) {
case 'OpenRouter':
return env.OPEN_ROUTER_API_KEY || cloudflareEnv.OPEN_ROUTER_API_KEY;
case "OpenAILike":
return env.OPENAI_API_LIKE_KEY || cloudflareEnv.OPENAI_API_LIKE_KEY;
return env.OPENAI_LIKE_API_KEY || cloudflareEnv.OPENAI_LIKE_API_KEY;
default:
return "";
}
@ -29,7 +29,7 @@ export function getAPIKey(cloudflareEnv: Env, provider: string) {
export function getBaseURL(cloudflareEnv: Env, provider: string) {
switch (provider) {
case 'OpenAILike':
return env.OPENAI_API_LIKE_BASE_URL || cloudflareEnv.OPENAI_API_LIKE_BASE_URL;
return env.OPENAI_LIKE_API_BASE_URL || cloudflareEnv.OPENAI_LIKE_API_BASE_URL;
default:
return "";
}

View File

@ -54,12 +54,12 @@ async function getOllamaModels(): Promise<ModelInfo[]> {
async function getOpenAILikeModels(): Promise<ModelInfo[]> {
try {
const base_url =import.meta.env.OPENAI_API_LIKE_BASE_URL || "";
const base_url =import.meta.env.OPENAI_LIKE_API_BASE_URL || "";
if (!base_url) {
return [];
}
const url = new URL(base_url).toString();
const api_key = import.meta.env.OPENAI_API_LIKE_KEY ?? "";
const api_key = import.meta.env.OPENAI_LIKE_API_KEY ?? "";
const response = await fetch(`${url}/models`, {
headers: {
Authorization: `Bearer ${api_key}`,

View File

@ -27,7 +27,7 @@ export default defineConfig((config) => {
chrome129IssuePlugin(),
config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
],
envPrefix:["VITE_","OPENAI_API_LIKE_","OLLAMA_API_BASE_URL"],
envPrefix:["VITE_","OPENAI_LIKE_API_","OLLAMA_API_BASE_URL"],
};
});

View File

@ -4,6 +4,6 @@ interface Env {
GROQ_API_KEY: string;
OPEN_ROUTER_API_KEY: string;
OLLAMA_API_BASE_URL: string;
OPENAI_API_LIKE_KEY: string;
OPENAI_API_LIKE_BASE_URL: string;
OPENAI_LIKE_API_KEY: string;
OPENAI_LIKE_API_BASE_URL: string;
}