Fix llm vendor update bug

This commit is contained in:
Xin Wang
2026-02-09 00:03:11 +08:00
parent be68e335f1
commit 0fc56e2685
3 changed files with 8 additions and 0 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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