mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
fix: model update
This commit is contained in:
parent
87f656b029
commit
42742d03d7
1 changed files with 7 additions and 3 deletions
|
|
@ -159,11 +159,15 @@ class ModelsTable:
|
|||
def update_model_by_id(self, id: str, model: ModelForm) -> Optional[ModelModel]:
|
||||
try:
|
||||
with get_db() as db:
|
||||
|
||||
# update only the fields that are present in the model
|
||||
model = db.query(Model).get(id)
|
||||
model.update(**model.model_dump())
|
||||
result = (
|
||||
db.query(Model)
|
||||
.filter_by(id=id)
|
||||
.update(model.model_dump(exclude={"id"}, exclude_none=True))
|
||||
)
|
||||
db.commit()
|
||||
|
||||
model = db.get(Model, id)
|
||||
db.refresh(model)
|
||||
return ModelModel.model_validate(model)
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Reference in a new issue