Spaces:
Sleeping
Sleeping
fix
Browse files- theagent.py +5 -4
theagent.py
CHANGED
|
@@ -39,24 +39,25 @@ cache = {
|
|
| 39 |
}
|
| 40 |
|
| 41 |
|
| 42 |
-
class ExecutePythonTool(
|
| 43 |
name = "python_executor"
|
| 44 |
description = "This is a tool that executes a python file."
|
| 45 |
output_type = "string"
|
| 46 |
|
| 47 |
def __init__(self, *args, authorized_imports=None, **kwargs):
|
| 48 |
-
|
| 49 |
self.inputs = {
|
| 50 |
"file_path": {
|
| 51 |
"type": "string",
|
| 52 |
-
"description": "The python file path to
|
| 53 |
}
|
| 54 |
}
|
|
|
|
| 55 |
|
| 56 |
def forward(self, file_path: str) -> str:
|
| 57 |
with open(file_path) as f:
|
| 58 |
code = f.read()
|
| 59 |
-
return
|
| 60 |
|
| 61 |
|
| 62 |
class BasicAgent:
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
|
| 42 |
+
class ExecutePythonTool(Tool):
|
| 43 |
name = "python_executor"
|
| 44 |
description = "This is a tool that executes a python file."
|
| 45 |
output_type = "string"
|
| 46 |
|
| 47 |
def __init__(self, *args, authorized_imports=None, **kwargs):
|
| 48 |
+
self.python_interpreter = PythonInterpreterTool()
|
| 49 |
self.inputs = {
|
| 50 |
"file_path": {
|
| 51 |
"type": "string",
|
| 52 |
+
"description": "The python file path to be executed",
|
| 53 |
}
|
| 54 |
}
|
| 55 |
+
super().__init__(*args, **kwargs)
|
| 56 |
|
| 57 |
def forward(self, file_path: str) -> str:
|
| 58 |
with open(file_path) as f:
|
| 59 |
code = f.read()
|
| 60 |
+
return self.python_interpreter.forward(code)
|
| 61 |
|
| 62 |
|
| 63 |
class BasicAgent:
|