From b8a05d380281c2adba797781e530bb16785eaef7 Mon Sep 17 00:00:00 2001 From: Chris Van Pelt Date: Fri, 20 Sep 2024 16:33:39 -0400 Subject: [PATCH] skip caching typescript only, fix error message, format code --- backend/openui/litellm.py | 20 ++++++++++++-------- backend/openui/server.py | 2 +- frontend/vite.config.ts | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/backend/openui/litellm.py b/backend/openui/litellm.py index b72adb5..9486a01 100644 --- a/backend/openui/litellm.py +++ b/backend/openui/litellm.py @@ -2,6 +2,7 @@ import os import tempfile import openai +from .logs import logger def generate_config(): @@ -104,17 +105,20 @@ def generate_config(): try: for model in client.models.list().data: models.append( - { - "model_name": model.id, - "litellm_params": { - "model": f"openai/{model.id}", - "api_key": os.getenv("OPENAI_COMPATIBLE_API_KEY"), - "base_url": os.getenv("OPENAI_COMPATIBLE_ENDPOINT"), - }, + { + "model_name": model.id, + "litellm_params": { + "model": f"openai/{model.id}", + "api_key": os.getenv("OPENAI_COMPATIBLE_API_KEY"), + "base_url": os.getenv("OPENAI_COMPATIBLE_ENDPOINT"), + }, } ) except Exception as e: - print(f"Error listing models for {os.getenv('OPENAI_COMPATIBLE_ENDPOINT')}: {e}") + logger.exception( + f"Error listing models for {os.getenv('OPENAI_COMPATIBLE_ENDPOINT')}: %s", + e, + ) yaml_structure = {"model_list": models} with tempfile.NamedTemporaryFile( diff --git a/backend/openui/server.py b/backend/openui/server.py index 39fcb8c..0f321a9 100644 --- a/backend/openui/server.py +++ b/backend/openui/server.py @@ -415,7 +415,7 @@ async def get_groq_models(): d for d in (await groq.models.list()).data if not d.id.startswith("whisper") ] except Exception: - logger.warning("Couldn't connect to Ollama at %s", config.GROQ_BASE_URL) + logger.warning("Couldn't connect to Groq at %s", config.GROQ_BASE_URL) return [] diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 88de783..705ea38 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -62,7 +62,7 @@ export default defineConfig(({ mode }) => ({ registerType: 'autoUpdate', workbox: { maximumFileSizeToCacheInBytes: 4000000, - globIgnores: ['**/annotator/**', '**/monacoeditorwork/**'], + globIgnores: ['**/annotator/**', '**/ts.worker.bundle.js'], navigateFallbackDenylist: [/\/openui\/.*/, /\/v1\/.*/] }, manifest: {