mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 23:04:36 +00:00
Merge pull request #11384 from Peter-De-Ath/hotfix/tool-calls-params
fix: bug where default params in tools calls always used
This commit is contained in:
commit
88303093c0
@ -189,17 +189,15 @@ async def chat_completion_tools_handler(
|
|||||||
tool_function_params = tool_call.get("parameters", {})
|
tool_function_params = tool_call.get("parameters", {})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
required_params = (
|
spec = tools[tool_function_name].get("spec", {})
|
||||||
tools[tool_function_name]
|
allowed_params = (
|
||||||
.get("spec", {})
|
spec.get("parameters", {}).get("properties", {}).keys()
|
||||||
.get("parameters", {})
|
|
||||||
.get("required", [])
|
|
||||||
)
|
)
|
||||||
tool_function = tools[tool_function_name]["callable"]
|
tool_function = tools[tool_function_name]["callable"]
|
||||||
tool_function_params = {
|
tool_function_params = {
|
||||||
k: v
|
k: v
|
||||||
for k, v in tool_function_params.items()
|
for k, v in tool_function_params.items()
|
||||||
if k in required_params
|
if k in allowed_params
|
||||||
}
|
}
|
||||||
tool_output = await tool_function(**tool_function_params)
|
tool_output = await tool_function(**tool_function_params)
|
||||||
|
|
||||||
@ -1765,14 +1763,16 @@ async def process_chat_response(
|
|||||||
spec = tool.get("spec", {})
|
spec = tool.get("spec", {})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
required_params = spec.get("parameters", {}).get(
|
allowed_params = (
|
||||||
"required", []
|
spec.get("parameters", {})
|
||||||
|
.get("properties", {})
|
||||||
|
.keys()
|
||||||
)
|
)
|
||||||
tool_function = tool["callable"]
|
tool_function = tool["callable"]
|
||||||
tool_function_params = {
|
tool_function_params = {
|
||||||
k: v
|
k: v
|
||||||
for k, v in tool_function_params.items()
|
for k, v in tool_function_params.items()
|
||||||
if k in required_params
|
if k in allowed_params
|
||||||
}
|
}
|
||||||
tool_result = await tool_function(
|
tool_result = await tool_function(
|
||||||
**tool_function_params
|
**tool_function_params
|
||||||
|
Loading…
Reference in New Issue
Block a user