Update app.py
#49
by
blmk29
- opened
app.py
CHANGED
@@ -3,20 +3,28 @@ 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 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
def
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""A tool that
|
15 |
-
|
16 |
-
arg1: the first argument
|
17 |
-
arg2: the second argument
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
+
import random
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
+
def get_historical_fact()-> str: #it's import to specify the return type
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
+
"""A tool that
|
16 |
+
Provides a random historical fact.
|
|
|
|
|
17 |
"""
|
18 |
+
facts = [
|
19 |
+
"The Great Fire of London in 1666 destroyed most of the city but only six people were officially recorded as dying.",
|
20 |
+
"Julius Caesar was assassinated on the Ides of March (March 15) in 44 BC.",
|
21 |
+
"The Berlin Wall fell on November 9, 1989, marking the end of the Cold War.",
|
22 |
+
"Leonardo da Vinci could write with one hand while drawing with the other.",
|
23 |
+
"The first Olympic Games were held in 776 BC in Olympia, Greece.",
|
24 |
+
"The Titanic sank on April 15, 1912, after hitting an iceberg in the North Atlantic Ocean.",
|
25 |
+
"Napoleon Bonaparte once escaped from exile on the island of Elba and returned to power for 100 days."
|
26 |
+
]
|
27 |
+
return random.choice[facts]
|
28 |
|
29 |
@tool
|
30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
63 |
|
64 |
agent = CodeAgent(
|
65 |
model=model,
|
66 |
+
tools=[final_answer, get_current_time_in_timezone, get_historical_fact], ## add your tools here (don't remove final answer)
|
67 |
max_steps=6,
|
68 |
verbosity_level=1,
|
69 |
grammar=None,
|