From dc25f44d312d60020b354ab8ddc268e5d5e6441a Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 23 Jun 2024 19:05:56 -0700 Subject: [PATCH] fix: handle default --- backend/apps/webui/routers/functions.py | 2 ++ backend/apps/webui/routers/tools.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/backend/apps/webui/routers/functions.py b/backend/apps/webui/routers/functions.py index 4da68a052..4a0e7c564 100644 --- a/backend/apps/webui/routers/functions.py +++ b/backend/apps/webui/routers/functions.py @@ -191,6 +191,7 @@ async def update_function_valves_by_id( Valves = function_module.Valves try: + form_data = {k: v for k, v in form_data.items() if v is not None} valves = Valves(**form_data) Functions.update_function_valves_by_id(id, valves.model_dump()) return valves.model_dump() @@ -277,6 +278,7 @@ async def update_function_user_valves_by_id( UserValves = function_module.UserValves try: + form_data = {k: v for k, v in form_data.items() if v is not None} user_valves = UserValves(**form_data) Functions.update_user_valves_by_id_and_user_id( id, user.id, user_valves.model_dump() diff --git a/backend/apps/webui/routers/tools.py b/backend/apps/webui/routers/tools.py index 7ddcf3ed9..900e17999 100644 --- a/backend/apps/webui/routers/tools.py +++ b/backend/apps/webui/routers/tools.py @@ -196,6 +196,7 @@ async def update_toolkit_valves_by_id( Valves = toolkit_module.Valves try: + form_data = {k: v for k, v in form_data.items() if v is not None} valves = Valves(**form_data) Tools.update_tool_valves_by_id(id, valves.model_dump()) return valves.model_dump() @@ -282,6 +283,7 @@ async def update_toolkit_user_valves_by_id( UserValves = toolkit_module.UserValves try: + form_data = {k: v for k, v in form_data.items() if v is not None} user_valves = UserValves(**form_data) Tools.update_user_valves_by_id_and_user_id( id, user.id, user_valves.model_dump()