Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@ import requests
|
|
| 12 |
from io import BytesIO
|
| 13 |
from PIL import Image
|
| 14 |
|
|
|
|
|
|
|
| 15 |
@tool
|
| 16 |
def generate_image(imageprompt: str) -> Image.Image:
|
| 17 |
"""A tool that generates an image based on a given prompt.
|
|
@@ -30,6 +32,23 @@ def generate_image(imageprompt: str) -> Image.Image:
|
|
| 30 |
else:
|
| 31 |
raise Exception("Failed to generate image.")
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 35 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -67,7 +86,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 67 |
|
| 68 |
agent = CodeAgent(
|
| 69 |
model=model,
|
| 70 |
-
tools=[final_answer, generate_image], ## add your tools here (don't remove final answer)
|
| 71 |
max_steps=6,
|
| 72 |
verbosity_level=1,
|
| 73 |
grammar=None,
|
|
|
|
| 12 |
from io import BytesIO
|
| 13 |
from PIL import Image
|
| 14 |
|
| 15 |
+
web_serach_tool = DuckDuckGoSearchTool()
|
| 16 |
+
|
| 17 |
@tool
|
| 18 |
def generate_image(imageprompt: str) -> Image.Image:
|
| 19 |
"""A tool that generates an image based on a given prompt.
|
|
|
|
| 32 |
else:
|
| 33 |
raise Exception("Failed to generate image.")
|
| 34 |
|
| 35 |
+
|
| 36 |
+
@tool
|
| 37 |
+
def get_news(topic:str) -> str:
|
| 38 |
+
"""A tool that scraps the web to find latest news article related to a specific topic
|
| 39 |
+
|
| 40 |
+
Args:
|
| 41 |
+
A detailed topic that will act as the search query
|
| 42 |
+
|
| 43 |
+
Returns:
|
| 44 |
+
A latest news article from the web based on the provided topic
|
| 45 |
+
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
search_result = web_serach_tool.run(topic)
|
| 49 |
+
|
| 50 |
+
return search_result
|
| 51 |
+
|
| 52 |
@tool
|
| 53 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 54 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 86 |
|
| 87 |
agent = CodeAgent(
|
| 88 |
model=model,
|
| 89 |
+
tools=[final_answer, get_news, generate_image], ## add your tools here (don't remove final answer)
|
| 90 |
max_steps=6,
|
| 91 |
verbosity_level=1,
|
| 92 |
grammar=None,
|