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

Function _bind_tool_server

bmtools/tools/serve.py:12–61  ·  view source on GitHub ↗

Add property API to ToolServer. t.api is a FastAPI object

(t : "ToolServer")

Source from the content-addressed store, hash-verified

10 topk: int = 3
11
12def _bind_tool_server(t : "ToolServer"):
13 """ Add property API to ToolServer.
14 t.api is a FastAPI object
15 """
16
17 @t.api.get("/")
18 def health():
19 return {
20 "status": "ok",
21 }
22
23 @t.api.get("/list")
24 def get_tools_list():
25 return {
26 "tools": t.list_tools(),
27 }
28
29 @t.api.get("/loaded")
30 def get_loaded_tools():
31 return {
32 "tools": list(t.loaded_tools),
33 }
34
35 @t.api.get("/.well-known/ai-plugin.json", include_in_schema=False)
36 def get_api_info():
37 return {
38 "schema_version": "v1",
39 "name_for_human": "BMTools",
40 "name_for_model": "BMTools",
41 "description_for_human": "tools to big models",
42 "description_for_model": "tools to big models",
43 "auth": {
44 "type": "none",
45 },
46 "api": {
47 "type": "openapi",
48 "url": "/openapi.json",
49 "is_user_authenticated": False,
50 },
51 "logo_url": None,
52 "contact_email": "",
53 "legal_info_url": "",
54 }
55
56 @t.api.post("/retrieve")
57 def retrieve(request: RetrieveRequest):
58 tool_list = t.retrieve(request.query, request.topk)
59 return {
60 "tools": tool_list
61 }
62
63class ToolServer:
64 """ This class host your own API backend.

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected