From df49e4e1cc819ca45591e975ecf1492cac9f3408 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 6 Mar 2024 20:25:24 -0800 Subject: [PATCH] fix: default openai api value --- .dockerignore | 1 - backend/apps/openai/main.py | 3 +-- backend/config.py | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 58cf1f0..e28863b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,7 +7,6 @@ node_modules /package .env .env.* -!.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* __pycache__ diff --git a/backend/apps/openai/main.py b/backend/apps/openai/main.py index 3ff0d68..6b9c542 100644 --- a/backend/apps/openai/main.py +++ b/backend/apps/openai/main.py @@ -175,8 +175,7 @@ async def get_all_models(): for idx, url in enumerate(app.state.OPENAI_API_BASE_URLS) ] responses = await asyncio.gather(*tasks) - responses = list(filter(lambda x: x is not None, responses)) - + responses = list(filter(lambda x: x is not None and "error" not in x, responses)) models = { "data": merge_models_lists( list(map(lambda response: response["data"], responses)) diff --git a/backend/config.py b/backend/config.py index 1db4d98..2cd0165 100644 --- a/backend/config.py +++ b/backend/config.py @@ -234,6 +234,9 @@ OLLAMA_BASE_URLS = [url.strip() for url in OLLAMA_BASE_URLS.split(";")] OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY", "") OPENAI_API_BASE_URL = os.environ.get("OPENAI_API_BASE_URL", "") +if OPENAI_API_KEY == "": + OPENAI_API_KEY = "none" + if OPENAI_API_BASE_URL == "": OPENAI_API_BASE_URL = "https://api.openai.com/v1"