From a47a958eddd3e34c2cf571c37221aee691ba6856 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 10 Apr 2025 19:43:26 -0700 Subject: [PATCH] refac: rename functions --- backend/open_webui/utils/tools.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 9b2c562c4..c7af4a16c 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -12,7 +12,9 @@ from functools import update_wrapper, partial from fastapi import Request from pydantic import BaseModel, Field, create_model -from langchain_core.utils.function_calling import convert_to_openai_function +from langchain_core.utils.function_calling import ( + convert_to_openai_function as convert_pydantic_model_to_openai_function_spec, +) from open_webui.models.tools import Tools @@ -240,7 +242,7 @@ def parse_docstring(docstring): return param_descriptions -def function_to_pydantic_model(func: Callable) -> type[BaseModel]: +def convert_function_to_pydantic_model(func: Callable) -> type[BaseModel]: """ Converts a Python function's type hints and docstring to a Pydantic model, including support for nested types, default values, and descriptions. @@ -295,11 +297,12 @@ def get_functions_from_tool(tool: object) -> list[Callable]: def get_tool_specs(tool_module: object) -> list[dict]: function_models = map( - function_to_pydantic_model, get_functions_from_tool(tool_module) + convert_function_to_pydantic_model, get_functions_from_tool(tool_module) ) return [ - convert_to_openai_function(function_model) for function_model in function_models + convert_pydantic_model_to_openai_function_spec(function_model) + for function_model in function_models ]