JoseferEins commited on
Commit
c314129
·
verified ·
1 Parent(s): b59103c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -11
app.py CHANGED
@@ -1,14 +1,33 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
 
8
  from Gradio_UI import GradioUI
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
 
11
 
 
 
 
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
@@ -21,14 +40,6 @@ def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
21
  """
22
  return "What magic will you build ?"
23
 
24
- @tool
25
- def web_search(query:str)-> str:
26
- #Keep this format for the description / args / args description but feel free to modify the tool
27
- """Performs a duckduckgo web search based on the query, then returns the top search results
28
- Args:
29
- query: the search query to perform
30
- """
31
- return DuckDuckGoSearchTool(query)
32
 
33
  @tool
34
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -63,7 +74,7 @@ with open("prompts.yaml", 'r') as stream:
63
 
64
  agent = CodeAgent(
65
  model=model,
66
- tools=[final_answer, web_search], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, GoogleSearchTool, VisitWebpageTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import matplolib.pyplot as plt
8
+ import numpy as np
9
  from Gradio_UI import GradioUI
10
 
11
+ @tool
12
+ def plot_omocentric_circles(seed: float, n: int)-> None:
13
+ """
14
+ A tool that plots n omocentric circles with a given seed distance, each in a different color.
15
+
16
+ Args:
17
+ seed (float): Distance between consecutive circles.
18
+ n (int): Number of circles to plot.
19
+ """
20
+ fig, ax = plt.subplots()
21
+ ax.set_aspect('equal')
22
+
23
+ colors = plt.cm.viridis(np.linspace(0, 1, n)) # Generate n distinct colors
24
 
25
+ for i in range(n):
26
+ ax.add_patch(plt.Circle((0, 0), (i + 1) * seed, fill=False, color=colors[i]))
27
 
28
+ plt.xlim(-n * seed, n * seed)
29
+ plt.ylim(-n * seed, n * seed)
30
+ plt.show()
31
 
32
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
33
  @tool
 
40
  """
41
  return "What magic will you build ?"
42
 
 
 
 
 
 
 
 
 
43
 
44
  @tool
45
  def get_current_time_in_timezone(timezone: str) -> str:
 
74
 
75
  agent = CodeAgent(
76
  model=model,
77
+ tools=[final_answer, DuckDuckGoSearchTool, image_generation_tool, plot_omocentric_circles], ## add your tools here (don't remove final answer)
78
  max_steps=6,
79
  verbosity_level=1,
80
  grammar=None,