From d3547f0f545179cb366cec8ca33d6e3ed8bb8329 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 31 Jul 2025 16:17:33 +0400 Subject: [PATCH] refac: error handling --- backend/open_webui/main.py | 2 +- backend/open_webui/routers/openai.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 0cd79aa5ab..322a7f72ad 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1296,7 +1296,7 @@ async def get_models( models = get_filtered_models(models, user) log.debug( - f"/api/models returned filtered models accessible to the user: {json.dumps([model['id'] for model in models])}" + f"/api/models returned filtered models accessible to the user: {json.dumps([model.get('id') for model in models])}" ) return {"data": models} diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index 5b54796a70..e26ef24d0b 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -362,7 +362,9 @@ async def get_all_models_responses(request: Request, user: UserModel) -> list: response if isinstance(response, list) else response.get("data", []) ): if prefix_id: - model["id"] = f"{prefix_id}.{model['id']}" + model["id"] = ( + f"{prefix_id}.{model.get('id', model.get('name', ''))}" + ) if tags: model["tags"] = tags