Spaces:
Sleeping
Sleeping
Added search image online tool
Browse files
app.py
CHANGED
@@ -4,7 +4,9 @@ import requests
|
|
4 |
import pytz
|
5 |
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 !
|
@@ -34,8 +36,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
|
37 |
-
final_answer = FinalAnswerTool()
|
38 |
-
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
41 |
|
@@ -58,12 +58,32 @@ image_generation_tool = Tool.from_space(
|
|
58 |
description="Generate an image from a text prompt. The prompt should be detailed to create high-quality images."
|
59 |
)
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
with open("prompts.yaml", 'r') as stream:
|
62 |
prompt_templates = yaml.safe_load(stream)
|
63 |
|
64 |
agent = CodeAgent(
|
65 |
model=model,
|
66 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
max_steps=6,
|
68 |
verbosity_level=1,
|
69 |
grammar=None,
|
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
+
from tools.web_search import DuckDuckGoSearchTool
|
8 |
+
from tools.visit_webpage import VisitWebpageTool
|
9 |
+
from tools.find_image_online import FindImageOnlineTool
|
10 |
from Gradio_UI import GradioUI
|
11 |
|
12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
36 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
37 |
|
38 |
|
|
|
|
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
41 |
|
|
|
58 |
description="Generate an image from a text prompt. The prompt should be detailed to create high-quality images."
|
59 |
)
|
60 |
|
61 |
+
# Create web search and visit webpage tools
|
62 |
+
web_search_tool = DuckDuckGoSearchTool(max_results=5)
|
63 |
+
visit_webpage_tool = VisitWebpageTool()
|
64 |
+
|
65 |
+
# Create the find image online tool with dependencies
|
66 |
+
find_image_tool = FindImageOnlineTool(
|
67 |
+
web_search_tool=web_search_tool,
|
68 |
+
visit_webpage_tool=visit_webpage_tool
|
69 |
+
)
|
70 |
+
|
71 |
+
# Final answer tool
|
72 |
+
final_answer = FinalAnswerTool()
|
73 |
+
|
74 |
with open("prompts.yaml", 'r') as stream:
|
75 |
prompt_templates = yaml.safe_load(stream)
|
76 |
|
77 |
agent = CodeAgent(
|
78 |
model=model,
|
79 |
+
tools=[
|
80 |
+
final_answer,
|
81 |
+
image_generation_tool,
|
82 |
+
web_search_tool,
|
83 |
+
visit_webpage_tool,
|
84 |
+
find_image_tool,
|
85 |
+
get_current_time_in_timezone
|
86 |
+
],
|
87 |
max_steps=6,
|
88 |
verbosity_level=1,
|
89 |
grammar=None,
|