giangireds commited on
Commit
b994aee
·
verified ·
1 Parent(s): 09e5773

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -2
app.py CHANGED
@@ -8,8 +8,37 @@ from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
-
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  final_answer = FinalAnswerTool()
15
 
@@ -32,7 +61,7 @@ with open("prompts.yaml", 'r') as stream:
32
 
33
  agent = CodeAgent(
34
  model=model,
35
- tools=[final_answer], [tool_ricerca_panini], ## add your tools here (don't remove final answer)
36
  max_steps=6,
37
  verbosity_level=1,
38
  grammar=None,
 
8
  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 tool_ricerca_panini(city: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 searches for the best sandwiches in Italian cities.
15
+ Args:
16
+ city: A string representing a city in Italy (e.g., 'Milan/Turin')
17
+ """
18
+ try:
19
+ # Costruisce la query di ricerca
20
+ query = f"miglior panino {city} Italia"
21
+ # Esegui la ricerca con DuckDuckGo
22
+ results = DuckDuckGoSearchTool.search(query=query)
23
+ top_result = results[0]
24
+ return f"Il miglior panino a {city.title()} sembra essere {top_result['title']}."
25
+ except Exception as e:
26
+ return f"Errore nel trovare il tuo panino a {city}: {str(e)} :("
27
 
28
+ @tool
29
+ def get_current_time_in_timezone(timezone: str) -> str:
30
+ """A tool that fetches the current local time in a specified timezone.
31
+ Args:
32
+ timezone: A string representing a valid timezone (e.g., 'America/New_York').
33
+ """
34
+ try:
35
+ # Create timezone object
36
+ tz = pytz.timezone(timezone)
37
+ # Get current time in that timezone
38
+ local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
39
+ return f"The current local time in {timezone} is: {local_time}"
40
+ except Exception as e:
41
+ return f"Error fetching time for timezone '{timezone}': {str(e)}"
42
 
43
  final_answer = FinalAnswerTool()
44
 
 
61
 
62
  agent = CodeAgent(
63
  model=model,
64
+ tools=[final_answer, tool_ricerca_panini], ## add your tools here (don't remove final answer)
65
  max_steps=6,
66
  verbosity_level=1,
67
  grammar=None,