Update crew.py
Browse files
crew.py
CHANGED
@@ -5,6 +5,7 @@ from crewai.tools import tool
|
|
5 |
from crewai_tools import (
|
6 |
CodeInterpreterTool,
|
7 |
SerperDevTool,
|
|
|
8 |
WebsiteSearchTool,
|
9 |
YoutubeVideoSearchTool
|
10 |
)
|
@@ -29,13 +30,34 @@ CrewAIInstrumentor().instrument(tracer_provider=tracer_provider)
|
|
29 |
def run_crew(question):
|
30 |
# Tools
|
31 |
|
32 |
-
|
|
|
33 |
web_search_tool = SerperDevTool()
|
34 |
web_rag_tool = WebsiteSearchTool()
|
35 |
youtube_search_tool = YoutubeVideoSearchTool()
|
36 |
|
37 |
# Agents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
web_search_agent = Agent(
|
40 |
role="Web Search Agent",
|
41 |
goal="Search the web for question \"{topic}\" and scrape the most relevant web page.",
|
@@ -56,44 +78,40 @@ def run_crew(question):
|
|
56 |
verbose=True
|
57 |
)
|
58 |
|
59 |
-
python_coding_agent = Agent(
|
60 |
-
role="Python Coding Agent",
|
61 |
-
goal="Write and execute Python code to solve question \"{topic}\".",
|
62 |
-
backstory="As an expert Python coding assistant, you write and execute Python for the question.",
|
63 |
-
allow_delegation=False,
|
64 |
-
max_iter=1,
|
65 |
-
tools=[code_interpreter_tool],
|
66 |
-
verbose=True,
|
67 |
-
)
|
68 |
-
|
69 |
# Tasks
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
agent=web_search_agent,
|
73 |
description="Search the web for question \"{topic}\" and scrape the most relevant web page.",
|
74 |
expected_output="Content to help answer the web related question."
|
75 |
)
|
76 |
-
|
77 |
-
|
78 |
agent=youtube_search_agent,
|
79 |
description="Search a YouTube video for question \"{topic}\"",
|
80 |
expected_output="Content to help answer the YouTube related question."
|
81 |
)
|
82 |
|
83 |
-
coding_task = Task(
|
84 |
-
agent=python_coding_agent,
|
85 |
-
description="Write and execute Python code to solve question \"{topic}\".",
|
86 |
-
expected_output="Content to help answer the Phyton coding related question."
|
87 |
-
)
|
88 |
-
|
89 |
# Crew
|
90 |
|
91 |
crew = Crew(
|
92 |
-
agents=[python_coding_agent, web_search_agent, youtube_search_agent],
|
93 |
#planning=True,
|
94 |
#planning_llm=PLANNING_MODEL,
|
95 |
process=Process.sequential,
|
96 |
-
tasks=[
|
97 |
verbose=True
|
98 |
)
|
99 |
|
|
|
5 |
from crewai_tools import (
|
6 |
CodeInterpreterTool,
|
7 |
SerperDevTool,
|
8 |
+
VisionTool,
|
9 |
WebsiteSearchTool,
|
10 |
YoutubeVideoSearchTool
|
11 |
)
|
|
|
30 |
def run_crew(question):
|
31 |
# Tools
|
32 |
|
33 |
+
python_coding_tool = CodeInterpreterTool()
|
34 |
+
image_search_tool = VisionTool()
|
35 |
web_search_tool = SerperDevTool()
|
36 |
web_rag_tool = WebsiteSearchTool()
|
37 |
youtube_search_tool = YoutubeVideoSearchTool()
|
38 |
|
39 |
# Agents
|
40 |
+
|
41 |
+
image_search_agent = Agent(
|
42 |
+
role="Image Search Agent",
|
43 |
+
goal="Search an image for question \"{topic}\".",
|
44 |
+
backstory="As an expert image search assistant, you search an image for the question.",
|
45 |
+
allow_delegation=False,
|
46 |
+
max_iter=1,
|
47 |
+
tools=[image_search_tool],
|
48 |
+
verbose=True
|
49 |
+
)
|
50 |
|
51 |
+
python_coding_agent = Agent(
|
52 |
+
role="Python Coding Agent",
|
53 |
+
goal="Write and execute Python code to solve question \"{topic}\".",
|
54 |
+
backstory="As an expert Python coding assistant, you write and execute Python for the question.",
|
55 |
+
allow_delegation=False,
|
56 |
+
max_iter=1,
|
57 |
+
tools=[python_coding],
|
58 |
+
verbose=True,
|
59 |
+
)
|
60 |
+
|
61 |
web_search_agent = Agent(
|
62 |
role="Web Search Agent",
|
63 |
goal="Search the web for question \"{topic}\" and scrape the most relevant web page.",
|
|
|
78 |
verbose=True
|
79 |
)
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
# Tasks
|
82 |
+
|
83 |
+
image_search_task = Task(
|
84 |
+
agent=image_search_agent,
|
85 |
+
description="Search an image for question \"{topic}\"",
|
86 |
+
expected_output="Content to help answer the image related question."
|
87 |
+
)
|
88 |
|
89 |
+
python_coding_task = Task(
|
90 |
+
agent=python_coding_agent,
|
91 |
+
description="Write and execute Python code to solve question \"{topic}\".",
|
92 |
+
expected_output="Content to help answer the Phyton coding related question."
|
93 |
+
)
|
94 |
+
|
95 |
+
web_search_task = Task(
|
96 |
agent=web_search_agent,
|
97 |
description="Search the web for question \"{topic}\" and scrape the most relevant web page.",
|
98 |
expected_output="Content to help answer the web related question."
|
99 |
)
|
100 |
+
|
101 |
+
youtube_search_task = Task(
|
102 |
agent=youtube_search_agent,
|
103 |
description="Search a YouTube video for question \"{topic}\"",
|
104 |
expected_output="Content to help answer the YouTube related question."
|
105 |
)
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
# Crew
|
108 |
|
109 |
crew = Crew(
|
110 |
+
agents=[image_search_agent, python_coding_agent, web_search_agent, youtube_search_agent],
|
111 |
#planning=True,
|
112 |
#planning_llm=PLANNING_MODEL,
|
113 |
process=Process.sequential,
|
114 |
+
tasks=[image_search_task, python_coding_task, web_search_task, youtube_search_task],
|
115 |
verbose=True
|
116 |
)
|
117 |
|