refac
This commit is contained in:
@@ -34,7 +34,6 @@ from open_webui.utils.plugin import (
|
|||||||
load_function_module_by_id,
|
load_function_module_by_id,
|
||||||
get_function_module_from_cache,
|
get_function_module_from_cache,
|
||||||
)
|
)
|
||||||
from open_webui.utils.tools import get_tools
|
|
||||||
|
|
||||||
from open_webui.env import GLOBAL_LOG_LEVEL
|
from open_webui.env import GLOBAL_LOG_LEVEL
|
||||||
|
|
||||||
@@ -255,17 +254,7 @@ async def generate_function_chat_completion(request, form_data, user, models: di
|
|||||||
'__oauth_token__': oauth_token,
|
'__oauth_token__': oauth_token,
|
||||||
'__request__': request,
|
'__request__': request,
|
||||||
}
|
}
|
||||||
extra_params['__tools__'] = await get_tools(
|
extra_params['__tools__'] = metadata.get('tools', {})
|
||||||
request,
|
|
||||||
tool_ids,
|
|
||||||
user,
|
|
||||||
{
|
|
||||||
**extra_params,
|
|
||||||
'__model__': models.get(form_data['model'], None),
|
|
||||||
'__messages__': form_data['messages'],
|
|
||||||
'__files__': files,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
if model_info:
|
if model_info:
|
||||||
if model_info.base_model_id:
|
if model_info.base_model_id:
|
||||||
|
|||||||
@@ -2680,9 +2680,12 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||||||
tools_dict[name] = tool_dict
|
tools_dict[name] = tool_dict
|
||||||
|
|
||||||
if tools_dict:
|
if tools_dict:
|
||||||
|
# Always store resolved tools in metadata so downstream consumers
|
||||||
|
# (e.g. pipe functions) can access all tools including MCP and builtins.
|
||||||
|
metadata['tools'] = tools_dict
|
||||||
|
|
||||||
if metadata.get('params', {}).get('function_calling') == 'native':
|
if metadata.get('params', {}).get('function_calling') == 'native':
|
||||||
# If the function calling is native, then call the tools function calling handler
|
# If the function calling is native, then call the tools function calling handler
|
||||||
metadata['tools'] = tools_dict
|
|
||||||
form_data['tools'] = [
|
form_data['tools'] = [
|
||||||
{'type': 'function', 'function': tool.get('spec', {})} for tool in tools_dict.values()
|
{'type': 'function', 'function': tool.get('spec', {})} for tool in tools_dict.values()
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user