Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,19 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
# Below is an example of a tool
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -33,6 +36,18 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +70,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,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
# Below is an example of a tool. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def wiki_of_person(name_of_person:str) -> str:
|
| 13 |
+
"""Look up for the person in wikipedia using websearch tool, and then provide detailed description about that person
|
|
|
|
| 14 |
Args:
|
| 15 |
+
name_of_person: The name of the person to look up for in wikipedia
|
|
|
|
| 16 |
"""
|
| 17 |
+
# Use DuckDuckGoSearchTool to search for the wikipedia url of the person and then visit the url
|
| 18 |
+
query = f"{name_of_person} wikipedia"
|
| 19 |
+
wikipedia_url = web_search(query)
|
| 20 |
+
# Use the wikipedia url to get the person's description, location, and interesting facts
|
| 21 |
+
wikipedia_results = visit_url(url=wikipedia_url)
|
| 22 |
+
return f"Detailes description: {wikipedia_results['description']}, Location: {wikipedia_results['location']}, Interesting facts: {wikipedia_results['interesting facts']}"
|
| 23 |
|
| 24 |
@tool
|
| 25 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 38 |
|
| 39 |
+
@tool
|
| 40 |
+
def random_quote_tool()-> str:
|
| 41 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 42 |
+
"""A tool that fetches a random quote
|
| 43 |
+
No arguments are taken
|
| 44 |
+
"""
|
| 45 |
+
response = requests.get("https://zenquotes.io/api/quotes")
|
| 46 |
+
if response.status_code == 200:
|
| 47 |
+
quote_data = response.json()
|
| 48 |
+
return random.choice(quote_data).get('q')
|
| 49 |
+
else:
|
| 50 |
+
return "Failed to fetch a quote"
|
| 51 |
|
| 52 |
final_answer = FinalAnswerTool()
|
| 53 |
|
|
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
+
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, wiki_of_person], ## add your tools here (don't remove final answer)
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|