fix(fastapi): fixes checks for custom llm api key

This commit is contained in:
sauravniraula 2025-08-01 15:11:49 +05:45
parent 33a532e546
commit 934a371ba3
No known key found for this signature in database
GPG key ID: 60FCC1B5A5E83326
2 changed files with 4 additions and 7 deletions

View file

@ -79,14 +79,14 @@ class LLMClient:
)
def _get_custom_client(self):
if not (get_custom_llm_api_key_env() and get_custom_llm_url_env()):
if not get_custom_llm_url_env():
raise HTTPException(
status_code=400,
detail="Custom LLM API Key is not set",
detail="Custom LLM URL is not set",
)
return AsyncOpenAI(
base_url=get_custom_llm_url_env(),
api_key=get_custom_llm_api_key_env(),
api_key=get_custom_llm_api_key_env() or "null",
)
# ? Prompts

View file

@ -92,15 +92,12 @@ async def check_llm_and_image_provider_api_or_model_availability():
elif is_custom_llm_selected():
custom_model = get_custom_model_env()
custom_llm_url = get_custom_llm_url_env()
custom_llm_api_key = get_custom_llm_api_key_env()
if not custom_model:
raise Exception("CUSTOM_MODEL must be provided")
if not custom_llm_url:
raise Exception("CUSTOM_LLM_URL must be provided")
if not custom_llm_api_key:
raise Exception("CUSTOM_LLM_API_KEY must be provided")
available_models = await list_available_openai_compatible_models(
custom_llm_url, custom_llm_api_key
custom_llm_url, get_custom_llm_api_key_env() or "null"
)
print("-" * 50)
print("Available models: ", available_models)