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

Function build_tool

bmtools/tools/python/api.py:31–60  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

29 return output
30
31def build_tool(config) -> Tool:
32 tool = Tool(
33 "Python REPL",
34 "Run python code",
35 name_for_model="Python REPL",
36 description_for_model=(
37 "A Python shell. Use this to execute python commands. "
38 "Input should be a valid python command. "
39 "If you want to see the output of a value, you should print it out "
40 "with `print(...)`."
41 ),
42 logo_url="https://your-app-url.com/.well-known/logo.png",
43 contact_email="hello@contact.com",
44 legal_info_url="hello@legal.com"
45 )
46
47 python_repl = PythonREPL()
48 sanitize_input: bool = True
49
50
51 @tool.get("/run_python")
52 def run_python(query : str):
53 '''Run python code in a REPL.
54 '''
55 if sanitize_input:
56 query = query.strip().strip("```")
57 return python_repl.run(query)
58
59
60 return tool

Callers

nothing calls this directly

Calls 2

PythonREPLClass · 0.85
ToolClass · 0.50

Tested by

no test coverage detected