From c03bfd141e3a34e636f834f8ef2f8aa6c2f5f591 Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Thu, 21 Nov 2024 17:41:35 +0000 Subject: [PATCH] fix optional args not present --- backend/open_webui/main.py | 1 - backend/open_webui/utils/tools.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 6a7cbb7eb..6c6b82289 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1313,7 +1313,6 @@ async def generate_chat_completions( @app.post("/api/chat/completed") async def chat_completed(form_data: dict, user=Depends(get_verified_user)): - model_list = await get_all_models() models = {model["id"]: model for model in model_list} diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index bbce8341f..2c6d53e3b 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -16,6 +16,8 @@ log = logging.getLogger(__name__) def apply_extra_params_to_tool_function( function: Callable, extra_params: dict ) -> Callable[..., Awaitable]: + sig = inspect.signature(function) + extra_params = {k: v for k, v in extra_params.items() if k in sig.parameters} partial_func = partial(function, **extra_params) if inspect.iscoroutinefunction(function): update_wrapper(partial_func, function)