Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,15 +8,44 @@ 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 |
@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:
|
|
@@ -55,7 +84,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,
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
+
import random
|
| 12 |
+
|
| 13 |
@tool
|
| 14 |
+
def daily_fortune(name: str) -> str:
|
| 15 |
+
"""Generates a personalized daily fortune based on current events and random inspiration.
|
|
|
|
| 16 |
Args:
|
| 17 |
+
name: The name of the person receiving the fortune.
|
|
|
|
| 18 |
"""
|
| 19 |
+
try:
|
| 20 |
+
# Fetch top news
|
| 21 |
+
search_results = DuckDuckGoSearchTool().search("top news today", max_results=1)
|
| 22 |
+
headline = search_results[0]['title'] if search_results else "No news found today."
|
| 23 |
+
|
| 24 |
+
# Random fortunes
|
| 25 |
+
fortunes = [
|
| 26 |
+
"Luck is on your side today! 🍀",
|
| 27 |
+
"Expect the unexpected. Surprises are coming your way. 🎉",
|
| 28 |
+
"A challenge will lead to new opportunities. 💪",
|
| 29 |
+
"Today is a perfect day for creativity and adventure. 🎨🚀",
|
| 30 |
+
"Someone from your past may reach out. Stay open. 💌"
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
# Pick a random fortune
|
| 34 |
+
fortune = random.choice(fortunes)
|
| 35 |
+
|
| 36 |
+
# Generate image for the vibe of the fortune
|
| 37 |
+
image_prompt = f"A digital painting representing '{fortune}' with a whimsical style"
|
| 38 |
+
image = image_generation_tool.generate(prompt=image_prompt)
|
| 39 |
+
|
| 40 |
+
return (
|
| 41 |
+
f"🌞 Hello {name}!\n"
|
| 42 |
+
f"📰 Top News Today: {headline}\n"
|
| 43 |
+
f"🔮 Your Fortune: {fortune}\n"
|
| 44 |
+
f"🖼️ Fortune Vibes Image: {image['url']}\n"
|
| 45 |
+
)
|
| 46 |
+
except Exception as e:
|
| 47 |
+
return f"Error generating your fortune: {str(e)}"
|
| 48 |
+
|
| 49 |
|
| 50 |
@tool
|
| 51 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 84 |
|
| 85 |
agent = CodeAgent(
|
| 86 |
model=model,
|
| 87 |
+
tools=[final_answer,daily_fortune], ## add your tools here (don't remove final answer)
|
| 88 |
max_steps=6,
|
| 89 |
verbosity_level=1,
|
| 90 |
grammar=None,
|