Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,18 +9,18 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def run_python_code_tool(
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
"""A tool that runs a small Python code.
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
|
| 18 |
Returns: result of the successfully executed code.
|
| 19 |
"""
|
| 20 |
try:
|
| 21 |
-
return eval(
|
| 22 |
except Exception as e:
|
| 23 |
-
return f"Error running '{}' code."
|
| 24 |
|
| 25 |
|
| 26 |
@tool
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def run_python_code_tool(python_code_as_str:str)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
"""A tool that runs a small Python code.
|
| 15 |
Args:
|
| 16 |
+
python_code_as_str: the Python code as a string.
|
| 17 |
|
| 18 |
Returns: result of the successfully executed code.
|
| 19 |
"""
|
| 20 |
try:
|
| 21 |
+
return eval(python_code_as_str)
|
| 22 |
except Exception as e:
|
| 23 |
+
return f"Error running '{python_code_as_str}' code."
|
| 24 |
|
| 25 |
|
| 26 |
@tool
|