Skip to content

Commit

Permalink
chore: Update environment variable names for OpenAI Like integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ZerxZ committed Oct 23, 2024
1 parent 30dfa4f commit 9f2db7b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/lib/.server/llm/api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}
Expand All @@ -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 "";
}
Expand Down
4 changes: 2 additions & 2 deletions app/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
};
});

Expand Down
4 changes: 2 additions & 2 deletions worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 9f2db7b

Please sign in to comment.