Skip to content

Commit

Permalink
chore(backend): support unset value when update chat engine
Browse files Browse the repository at this point in the history
  • Loading branch information
wd0517 committed Aug 8, 2024
1 parent 437c177 commit 6fc7af1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions backend/app/repositories/chat_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ def update(
chat_engine: ChatEngine,
chat_engine_in: ChatEngineUpdate,
) -> ChatEngine:
update_data = chat_engine_in.model_dump()
set_default = update_data.pop("is_default", False)
for field, value in chat_engine_in.model_dump().items():
if value is not None:
setattr(chat_engine, field, value)
flag_modified(chat_engine, field)
set_default = chat_engine_in.is_default
for field, value in chat_engine_in.model_dump(exclude_unset=True).items():
setattr(chat_engine, field, value)
flag_modified(chat_engine, field)

if set_default:
session.exec(
Expand Down

0 comments on commit 6fc7af1

Please sign in to comment.