Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import pytz
|
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
|
|
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
@@ -19,6 +20,28 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
"""
|
| 20 |
return "What magic will you build ?"
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 24 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -57,7 +80,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 57 |
|
| 58 |
agent = CodeAgent(
|
| 59 |
model=model,
|
| 60 |
-
tools=[final_answer,image_generation_tool], ## add your tools here (don't remove final answer)
|
| 61 |
max_steps=6,
|
| 62 |
verbosity_level=1,
|
| 63 |
grammar=None,
|
|
|
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
+
import matplotlib.pyplot as plt
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
|
|
| 20 |
"""
|
| 21 |
return "What magic will you build ?"
|
| 22 |
|
| 23 |
+
|
| 24 |
+
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 25 |
+
@tool
|
| 26 |
+
def plot_tool(x:list, y:list)-> matplotlib.figure.Figure: #it's import to specify the return type
|
| 27 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 28 |
+
"""A tool that creates a simple scatter plot
|
| 29 |
+
Args:
|
| 30 |
+
x: list of integers for the x-values
|
| 31 |
+
y: list of integers for the y-values
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
fig, ax = plt.subplots() # Create a figure and axis
|
| 35 |
+
ax.scatter(x, y, color='blue', label='Data Points')
|
| 36 |
+
|
| 37 |
+
# Labels and title
|
| 38 |
+
ax.set_xlabel('X-axis')
|
| 39 |
+
ax.set_ylabel('Y-axis')
|
| 40 |
+
ax.set_title('Simple Scatter Plot')
|
| 41 |
+
ax.legend()
|
| 42 |
+
|
| 43 |
+
return fig # Return the figure object
|
| 44 |
+
|
| 45 |
@tool
|
| 46 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 47 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 80 |
|
| 81 |
agent = CodeAgent(
|
| 82 |
model=model,
|
| 83 |
+
tools=[final_answer,image_generation_tool, plot_tool], ## add your tools here (don't remove final answer)
|
| 84 |
max_steps=6,
|
| 85 |
verbosity_level=1,
|
| 86 |
grammar=None,
|