refac
This commit is contained in:
1 parent
a0c2ec3d2c
commit
91762ed807
8 files changed
+77
-78
No files matched your search
@@ -95,7 +95,7 @@ from open_webui.tools.builtin import (
|
||||
from open_webui.utils.access_control import has_access, has_connection_access, has_permission
|
||||
from open_webui.utils.headers import get_custom_headers, include_user_info_headers
|
||||
from open_webui.utils.misc import is_string_allowed
|
||||
from open_webui.utils.plugin import load_tool_module_by_id
|
||||
from open_webui.utils.plugin import get_tool_contents_cache, get_tools_cache, load_tool_module_by_id
|
||||
from pydantic import BaseModel, Field, create_model
|
||||
from pydantic.fields import FieldInfo
|
||||
|
||||
@@ -250,11 +250,13 @@ async def get_tools(request: Request, tool_ids: list[str], user: UserModel, extr
|
||||
log.warning(f'Access denied to tool {tool_id} for user {user.id}')
|
||||
continue
|
||||
|
||||
module = request.app.state.TOOLS.get(tool_id)
|
||||
if module is None or request.app.state.TOOL_CONTENTS.get(tool_id) != tool.content:
|
||||
tools_cache = get_tools_cache(request)
|
||||
tool_contents_cache = get_tool_contents_cache(request)
|
||||
module = tools_cache.get(tool_id)
|
||||
if module is None or tool_contents_cache.get(tool_id) != tool.content:
|
||||
module, _ = await load_tool_module_by_id(tool_id, content=tool.content)
|
||||
request.app.state.TOOLS[tool_id] = module
|
||||
request.app.state.TOOL_CONTENTS[tool_id] = tool.content
|
||||
tools_cache[tool_id] = module
|
||||
tool_contents_cache[tool_id] = tool.content
|
||||
|
||||
__user__ = {
|
||||
**extra_params['__user__'],
|
||||
|
||||
Reference in new issue
Block a user