| """ | |
| id: registry | |
| title: Tool Registry (unsafe) | |
| author: admin | |
| description: List current tool/function registry from the database. | |
| version: 0.1.0 | |
| license: Proprietary | |
| """ | |
| from typing import List, Dict | |
| class Tools: | |
| def list_tools(self) -> Dict[str, List[Dict[str, str]]]: | |
| """Return list of tools (id, name).""" | |
| try: | |
| from open_webui.models.tools import Tools as DBTools | |
| tools = DBTools.get_tools() | |
| return {"tools": [{"id": t.id, "name": t.name} for t in tools]} | |
| except Exception as e: | |
| return {"error": str(e)} | |
| def list_functions(self) -> Dict[str, List[Dict[str, str]]]: | |
| """Return list of functions (id, name, type).""" | |
| try: | |
| from open_webui.models.functions import Functions as DBFunctions | |
| funcs = DBFunctions.get_functions() | |
| return { | |
| "functions": [ | |
| {"id": f.id, "name": f.name, "type": f.type} for f in funcs | |
| ] | |
| } | |
| except Exception as e: | |
| return {"error": str(e)} | |