(config)
| 25 | self.locals = {} |
| 26 | |
| 27 | def build_tool(config) -> Tool: |
| 28 | tool = Tool( |
| 29 | "Python Code Interpreter Tool", |
| 30 | "Execute Python Codes", |
| 31 | name_for_model="code_interpreter", |
| 32 | description_for_model="Plugin for executing python codes", |
| 33 | logo_url=None, |
| 34 | contact_email=None, |
| 35 | legal_info_url=None |
| 36 | ) |
| 37 | |
| 38 | # Usage example |
| 39 | interpreter = CodeInterpreter() |
| 40 | |
| 41 | @tool.get("/execute_code") |
| 42 | def execute_python_code(code: str): |
| 43 | '''execute Python expressions with Python Interpreter, can be used as a simple calculator e.g., "(123 + 234) / 23 * 19" |
| 44 | ''' |
| 45 | return interpreter.execute_code(code) |
| 46 | |
| 47 | return tool |
nothing calls this directly
no test coverage detected