From 0fc56e2685445fb7d5229e64818e1086cac9dfb5 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 9 Feb 2026 00:03:11 +0800 Subject: [PATCH] Fix llm vendor update bug --- api/app/routers/llm.py | 2 ++ api/app/schemas.py | 2 ++ api/tests/test_llm.py | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/api/app/routers/llm.py b/api/app/routers/llm.py index 80783b0..0658de4 100644 --- a/api/app/routers/llm.py +++ b/api/app/routers/llm.py @@ -79,6 +79,8 @@ def update_llm_model(id: str, data: LLMModelUpdate, db: Session = Depends(get_db raise HTTPException(status_code=404, detail="LLM Model not found") update_data = data.model_dump(exclude_unset=True) + if "type" in update_data and update_data["type"] is not None and hasattr(update_data["type"], "value"): + update_data["type"] = update_data["type"].value for field, value in update_data.items(): setattr(model, field, value) diff --git a/api/app/schemas.py b/api/app/schemas.py index e8e0f7b..041a8f6 100644 --- a/api/app/schemas.py +++ b/api/app/schemas.py @@ -129,6 +129,8 @@ class LLMModelCreate(LLMModelBase): class LLMModelUpdate(BaseModel): name: Optional[str] = None + vendor: Optional[str] = None + type: Optional[LLMModelType] = None base_url: Optional[str] = None api_key: Optional[str] = None model_name: Optional[str] = None diff --git a/api/tests/test_llm.py b/api/tests/test_llm.py index 42daf34..0108b86 100644 --- a/api/tests/test_llm.py +++ b/api/tests/test_llm.py @@ -66,6 +66,8 @@ class TestLLMModelAPI: # Update update_data = { "name": "Updated LLM Model", + "vendor": "SiliconFlow", + "type": "embedding", "temperature": 0.5, "context_length": 8192 } @@ -73,6 +75,8 @@ class TestLLMModelAPI: assert response.status_code == 200 data = response.json() assert data["name"] == "Updated LLM Model" + assert data["vendor"] == "SiliconFlow" + assert data["type"] == "embedding" assert data["temperature"] == 0.5 assert data["context_length"] == 8192