Fix handling unset openai_base_url to run eval with openai chat models

The github run_eval workflow sets OPENAI_BASE_URL to empty string.

The ai model api created during initialization for openai models gets
set to empty string rather than None or the actual openai base url

This tries to call llm at to empty string base url instead of the
default openai api base url, which obviously fails.

Fix is to map empty base url's to the actual openai api base url.
This commit is contained in:
Debanjum
2025-05-18 18:43:40 -07:00
parent cf55582852
commit 22cd638add
2 changed files with 4 additions and 4 deletions

View File

@@ -58,7 +58,7 @@ on:
openai_base_url: openai_base_url:
description: 'Base URL of OpenAI compatible API' description: 'Base URL of OpenAI compatible API'
required: false required: false
default: '' default: 'https://api.openai.com/v1'
type: string type: string
auto_read_webpage: auto_read_webpage:
description: 'Auto read webpage on online search' description: 'Auto read webpage on online search'
@@ -150,7 +150,7 @@ jobs:
KHOJ_RESEARCH_ITERATIONS: ${{ github.event_name == 'workflow_dispatch' && inputs.max_research_iterations || 10 }} KHOJ_RESEARCH_ITERATIONS: ${{ github.event_name == 'workflow_dispatch' && inputs.max_research_iterations || 10 }}
KHOJ_AUTO_READ_WEBPAGE: ${{ github.event_name == 'workflow_dispatch' && inputs.auto_read_webpage || 'false' }} KHOJ_AUTO_READ_WEBPAGE: ${{ github.event_name == 'workflow_dispatch' && inputs.auto_read_webpage || 'false' }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
OPENAI_BASE_URL: ${{ github.event_name == 'workflow_dispatch' && inputs.openai_base_url || '' }} OPENAI_BASE_URL: ${{ github.event_name == 'workflow_dispatch' && inputs.openai_base_url || 'https://api.openai.com/v1' }}
SERPER_DEV_API_KEY: ${{ matrix.dataset != 'math500' && secrets.SERPER_DEV_API_KEY || '' }} SERPER_DEV_API_KEY: ${{ matrix.dataset != 'math500' && secrets.SERPER_DEV_API_KEY || '' }}
OLOSTEP_API_KEY: ${{ matrix.dataset != 'math500' && secrets.OLOSTEP_API_KEY || ''}} OLOSTEP_API_KEY: ${{ matrix.dataset != 'math500' && secrets.OLOSTEP_API_KEY || ''}}
FIRECRAWL_API_KEY: ${{ matrix.dataset != 'math500' && secrets.FIRECRAWL_API_KEY || '' }} FIRECRAWL_API_KEY: ${{ matrix.dataset != 'math500' && secrets.FIRECRAWL_API_KEY || '' }}

View File

@@ -43,7 +43,7 @@ def initialization(interactive: bool = True):
"🗣️ Configure chat models available to your server. You can always update these at /server/admin using your admin account" "🗣️ Configure chat models available to your server. You can always update these at /server/admin using your admin account"
) )
openai_base_url = os.getenv("OPENAI_BASE_URL") openai_base_url = os.getenv("OPENAI_BASE_URL") or None
provider = "Ollama" if openai_base_url and openai_base_url.endswith(":11434/v1/") else "OpenAI" provider = "Ollama" if openai_base_url and openai_base_url.endswith(":11434/v1/") else "OpenAI"
openai_api_key = os.getenv("OPENAI_API_KEY", "placeholder" if openai_base_url else None) openai_api_key = os.getenv("OPENAI_API_KEY", "placeholder" if openai_base_url else None)
default_chat_models = default_openai_chat_models default_chat_models = default_openai_chat_models
@@ -329,4 +329,4 @@ def initialization(interactive: bool = True):
) )
return return
ConversationAdapters.set_default_chat_model(chat_model) ConversationAdapters.set_default_chat_model(chat_model)
logger.info(f"🗣️ Default chat model set to {chat_model.name}") logger.info(f"🗣️ Default chat model set to {chat_model.name} served by {chat_model.ai_model_api}")