(config)
| 29 | return output |
| 30 | |
| 31 | def 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 |
nothing calls this directly
no test coverage detected