Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
42742d03
Commit
42742d03
authored
Jul 08, 2024
by
Timothy J. Baek
Browse files
fix: model update
parent
87f656b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
backend/apps/webui/models/models.py
backend/apps/webui/models/models.py
+7
-3
No files found.
backend/apps/webui/models/models.py
View file @
42742d03
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment