Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,13 +19,10 @@ def daily_fortune(name: str) -> str:
|
|
19 |
import random
|
20 |
|
21 |
try:
|
22 |
-
#
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
)
|
27 |
-
|
28 |
-
headline = search_result.get('results', [{}])[0].get('snippet', 'No news found today.')
|
29 |
|
30 |
# Random fortunes
|
31 |
fortunes = [
|
@@ -35,16 +32,10 @@ def daily_fortune(name: str) -> str:
|
|
35 |
"Today is a perfect day for creativity and adventure. 🎨🚀",
|
36 |
"Someone from your past may reach out. Stay open. 💌"
|
37 |
]
|
38 |
-
|
39 |
-
# Pick a random fortune
|
40 |
fortune = random.choice(fortunes)
|
41 |
|
42 |
-
#
|
43 |
-
image =
|
44 |
-
"agents-course/text-to-image",
|
45 |
-
{"prompt": f"A digital painting representing '{fortune}' with a whimsical style"}
|
46 |
-
)
|
47 |
-
|
48 |
image_url = image.get('url', 'No image generated.')
|
49 |
|
50 |
return (
|
@@ -53,12 +44,10 @@ def daily_fortune(name: str) -> str:
|
|
53 |
f"🔮 Your Fortune: {fortune}\n"
|
54 |
f"🖼️ Fortune Vibes Image: {image_url}\n"
|
55 |
)
|
56 |
-
|
57 |
except Exception as e:
|
58 |
return f"Error generating your fortune: {str(e)}"
|
59 |
-
|
60 |
-
|
61 |
|
|
|
62 |
|
63 |
@tool
|
64 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -97,7 +86,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
97 |
|
98 |
agent = CodeAgent(
|
99 |
model=model,
|
100 |
-
tools=[final_answer,
|
101 |
max_steps=6,
|
102 |
verbosity_level=1,
|
103 |
grammar=None,
|
|
|
19 |
import random
|
20 |
|
21 |
try:
|
22 |
+
# Use DuckDuckGoSearchTool directly
|
23 |
+
search_tool = DuckDuckGoSearchTool()
|
24 |
+
search_results = search_tool(query="top news today", max_results=1)
|
25 |
+
headline = search_results.get('results', [{}])[0].get('snippet', 'No news found today.')
|
|
|
|
|
|
|
26 |
|
27 |
# Random fortunes
|
28 |
fortunes = [
|
|
|
32 |
"Today is a perfect day for creativity and adventure. 🎨🚀",
|
33 |
"Someone from your past may reach out. Stay open. 💌"
|
34 |
]
|
|
|
|
|
35 |
fortune = random.choice(fortunes)
|
36 |
|
37 |
+
# Use image generation tool directly
|
38 |
+
image = image_generation_tool(prompt=f"A digital painting representing '{fortune}' in a mystical style")
|
|
|
|
|
|
|
|
|
39 |
image_url = image.get('url', 'No image generated.')
|
40 |
|
41 |
return (
|
|
|
44 |
f"🔮 Your Fortune: {fortune}\n"
|
45 |
f"🖼️ Fortune Vibes Image: {image_url}\n"
|
46 |
)
|
|
|
47 |
except Exception as e:
|
48 |
return f"Error generating your fortune: {str(e)}"
|
|
|
|
|
49 |
|
50 |
+
|
51 |
|
52 |
@tool
|
53 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
86 |
|
87 |
agent = CodeAgent(
|
88 |
model=model,
|
89 |
+
tools=[final_answer,image_generation_tool], ## add your tools here (don't remove final answer)
|
90 |
max_steps=6,
|
91 |
verbosity_level=1,
|
92 |
grammar=None,
|