mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-05 06:42:22 +02:00
fix: UserValves contamination between multiple tools
Co-Authored-By: Daniel Pots <3932988+podden@users.noreply.github.com>
This commit is contained in:
@@ -237,14 +237,16 @@ async def get_tools(
|
||||
module, _ = load_tool_module_by_id(tool_id)
|
||||
request.app.state.TOOLS[tool_id] = module
|
||||
|
||||
extra_params["__id__"] = tool_id
|
||||
__user__ = {
|
||||
**extra_params["__user__"],
|
||||
}
|
||||
|
||||
# Set valves for the tool
|
||||
if hasattr(module, "valves") and hasattr(module, "Valves"):
|
||||
valves = Tools.get_tool_valves_by_id(tool_id) or {}
|
||||
module.valves = module.Valves(**valves)
|
||||
if hasattr(module, "UserValves"):
|
||||
extra_params["__user__"]["valves"] = module.UserValves( # type: ignore
|
||||
__user__["valves"] = module.UserValves( # type: ignore
|
||||
**Tools.get_user_valves_by_id_and_user_id(tool_id, user.id)
|
||||
)
|
||||
|
||||
@@ -266,7 +268,12 @@ async def get_tools(
|
||||
function_name = spec["name"]
|
||||
tool_function = getattr(module, function_name)
|
||||
callable = get_async_tool_function_and_apply_extra_params(
|
||||
tool_function, extra_params
|
||||
tool_function,
|
||||
{
|
||||
**extra_params,
|
||||
"__id__": tool_id,
|
||||
"__user__": __user__,
|
||||
},
|
||||
)
|
||||
|
||||
# TODO: Support Pydantic models as parameters
|
||||
|
||||
Reference in New Issue
Block a user