mirror of
https://github.com/open-webui/open-webui
synced 2025-05-29 17:52:48 +00:00
refac: rename functions
This commit is contained in:
parent
53df5d3946
commit
a47a958edd
@ -12,7 +12,9 @@ from functools import update_wrapper, partial
|
|||||||
|
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from pydantic import BaseModel, Field, create_model
|
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
|
from open_webui.models.tools import Tools
|
||||||
@ -240,7 +242,7 @@ def parse_docstring(docstring):
|
|||||||
return param_descriptions
|
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,
|
Converts a Python function's type hints and docstring to a Pydantic model,
|
||||||
including support for nested types, default values, and descriptions.
|
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]:
|
def get_tool_specs(tool_module: object) -> list[dict]:
|
||||||
function_models = map(
|
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 [
|
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
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user