Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,9 +6,7 @@ import yaml
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
-
|
| 10 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 11 |
-
@tool
|
| 12 |
def my_custom_tool(query: str, max_results: int = 3) -> list[str]:
|
| 13 |
"""
|
| 14 |
Search DuckDuckGo and return up to max_results hits.
|
|
@@ -21,6 +19,8 @@ def my_custom_tool(query: str, max_results: int = 3) -> list[str]:
|
|
| 21 |
search = DuckDuckGoSearchTool()
|
| 22 |
return search.run(query, max_results=max_results)
|
| 23 |
|
|
|
|
|
|
|
| 24 |
@tool
|
| 25 |
def generate_images(prompt: str, n: int = 3) -> list[str]:
|
| 26 |
"""
|
|
@@ -34,8 +34,21 @@ def generate_images(prompt: str, n: int = 3) -> list[str]:
|
|
| 34 |
#image_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 35 |
#return image_tool.run(prompt, max_results=n)
|
| 36 |
return image_generation_tool.run(prompt, max_results=n)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
@tool
|
| 41 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -74,7 +87,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 74 |
|
| 75 |
agent = CodeAgent(
|
| 76 |
model=model,
|
| 77 |
-
tools=[final_answer,my_custom_tool,generate_images,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 78 |
max_steps=6,
|
| 79 |
verbosity_level=1,
|
| 80 |
grammar=None,
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
|
|
|
| 9 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
|
|
| 10 |
def my_custom_tool(query: str, max_results: int = 3) -> list[str]:
|
| 11 |
"""
|
| 12 |
Search DuckDuckGo and return up to max_results hits.
|
|
|
|
| 19 |
search = DuckDuckGoSearchTool()
|
| 20 |
return search.run(query, max_results=max_results)
|
| 21 |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
@tool
|
| 25 |
def generate_images(prompt: str, n: int = 3) -> list[str]:
|
| 26 |
"""
|
|
|
|
| 34 |
#image_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 35 |
#return image_tool.run(prompt, max_results=n)
|
| 36 |
return image_generation_tool.run(prompt, max_results=n)
|
| 37 |
+
@tool
|
| 38 |
+
def ss(prompt: str) -> str:
|
| 39 |
+
"""
|
| 40 |
+
Generate up to n images matching the prompt.
|
| 41 |
+
Args:
|
| 42 |
+
prompt: the text description for the image
|
| 43 |
+
n: number of images to generate
|
| 44 |
+
Returns:
|
| 45 |
+
A list of image asset IDs.
|
| 46 |
+
"""
|
| 47 |
+
#image_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 48 |
+
#return image_tool.run(prompt, max_results=n)
|
| 49 |
|
| 50 |
+
search=DuckDuckGoSearchTool()
|
| 51 |
+
return search.run(prompt)
|
| 52 |
|
| 53 |
@tool
|
| 54 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 87 |
|
| 88 |
agent = CodeAgent(
|
| 89 |
model=model,
|
| 90 |
+
tools=[final_answer,my_custom_tool,generate_images,get_current_time_in_timezone,ss], ## add your tools here (don't remove final answer)
|
| 91 |
max_steps=6,
|
| 92 |
verbosity_level=1,
|
| 93 |
grammar=None,
|