MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / Tool

Class Tool

bmtools/tools/tool.py:5–92  ·  view source on GitHub ↗

r""" Tool is inherited from FastAPI class, thus: - It can act as a server - It has get method, you can use Tool.get method to bind a function to an url - It can be easily mounted to another server - It has a list of sub-routes, each route is a function Args:

Source from the content-addressed store, hash-verified

3import copy
4
5class Tool(fastapi.FastAPI):
6 r""" Tool is inherited from FastAPI class, thus:
7 - It can act as a server
8 - It has get method, you can use Tool.get method to bind a function to an url
9 - It can be easily mounted to another server
10 - It has a list of sub-routes, each route is a function
11
12 Args:
13 - tool_name (str): The name of the tool.
14 - description (str): The description of the tool.
15 - name_for_human (str, optional): The name of the tool for humans. Defaults to None.
16 - name_for_model (str, optional): The name of the tool for models. Defaults to None.
17 - description_for_human (str, optional): The description of the tool for humans. Defaults to None.
18 - description_for_model (str, optional): The description of the tool for models. Defaults to None.
19 - logo_url (str, optional): The URL of the tool's logo. Defaults to None.
20 - author_github (str, optional): The GitHub URL of the author. Defaults to None.
21 - contact_email (str, optional): The contact email for the tool. Defaults to "".
22 - legal_info_url (str, optional): The URL for legal information. Defaults to "".
23 - version (str, optional): The version of the tool. Defaults to "0.1.0".
24 """
25
26 def __init__(
27 self,
28 tool_name : str,
29 description : str,
30 name_for_human : Optional[str] = None,
31 name_for_model : Optional[str] = None,
32 description_for_human : Optional[str] = None,
33 description_for_model : Optional[str] = None,
34 logo_url : Optional[str] = None,
35 author_github : Optional[str] = None,
36 contact_email : str = "",
37 legal_info_url : str = "",
38 version : str = "0.1.0",
39 ):
40 """
41 Diagram:
42 Root API server (ToolServer object)
43
44 ├───── "./weather": Tool object
45 │ ├── "./get_weather_today": function_get_weather(location: str) -> str
46 │ ├── "./get_weather_forecast": function_get_weather_forcast(location: str, day_offset: int) -> str
47 │ └── "...more routes"
48 ├───── "./wikidata": Tool object
49 │ ├── "... more routes"
50 └───── "... more routes"
51 """
52 super().__init__(
53 title=tool_name,
54 description=description,
55 version=version,
56 )
57
58 if name_for_human is None:
59 name_for_human = tool_name
60 if name_for_model is None:
61 name_for_model = name_for_human
62 if description_for_human is None:

Callers 15

build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_database_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50
build_toolFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected