File size: 1,080 Bytes
fbf3c28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
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)}