Spaces:
Sleeping
Sleeping
Update app.py
Browse filesremoved the image generation tool
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
@@ -6,6 +6,12 @@ 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
|
@@ -52,45 +58,8 @@ def my_custom_tool(arg1: str, arg2: int) -> str:
|
|
52 |
|
53 |
return "\n".join(messages)
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
"""
|
58 |
-
A tool that promotes tourism and investment in Chakwal by fetching live information
|
59 |
-
and generating a visual representation of the city's attractions.
|
60 |
-
|
61 |
-
Args:
|
62 |
-
arg1: A custom note or call-to-action message.
|
63 |
-
arg2: The number of search results to include from DuckDuckGo regarding tourism/investment.
|
64 |
-
"""
|
65 |
-
output_lines = []
|
66 |
-
|
67 |
-
# Use DuckDuckGoSearchTool to fetch current news or information on Chakwal tourism and investment
|
68 |
-
duck_tool = DuckDuckGoSearchTool()
|
69 |
-
search_query = "Chakwal tourism investment latest news attractions"
|
70 |
-
search_results = duck_tool.run(search_query)
|
71 |
-
|
72 |
-
# Process and include search results (assuming a list of result dictionaries)
|
73 |
-
if isinstance(search_results, list):
|
74 |
-
output_lines.append("Latest Information on Chakwal:")
|
75 |
-
for idx, result in enumerate(search_results[:arg2]):
|
76 |
-
title = result.get("title", "No Title")
|
77 |
-
snippet = result.get("snippet", "No snippet available.")
|
78 |
-
output_lines.append(f"{idx+1}. {title} - {snippet}")
|
79 |
-
else:
|
80 |
-
output_lines.append(f"Search Results: {search_results}")
|
81 |
-
|
82 |
-
# Use the text-to-image generation tool to create an attractive image prompt for Chakwal
|
83 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
84 |
-
image_prompt = "A stunning view of Chakwal with lush landscapes, historic landmarks, and vibrant local culture"
|
85 |
-
generated_image = image_generation_tool.run(image_prompt)
|
86 |
-
output_lines.append("\nVisual Promotion:")
|
87 |
-
output_lines.append(f"Generated Image URL/Result: {generated_image}")
|
88 |
-
|
89 |
-
# Append any additional note from arg1
|
90 |
-
if arg1:
|
91 |
-
output_lines.append(f"\nAdditional Note: {arg1}")
|
92 |
-
|
93 |
-
return "\n".join(output_lines)
|
94 |
|
95 |
@tool
|
96 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
|
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
+
image_generation_tool = tool.from_space(
|
10 |
+
"black-forest-labs/FLUX.1-schnell",
|
11 |
+
name="image_generator",
|
12 |
+
description="Generate an image from a prompt"
|
13 |
+
)
|
14 |
+
|
15 |
|
16 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
17 |
@tool
|
|
|
58 |
|
59 |
return "\n".join(messages)
|
60 |
|
61 |
+
|
62 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
@tool
|
65 |
def get_current_time_in_timezone(timezone: str) -> str:
|