Update crew.py
Browse files
crew.py
CHANGED
|
@@ -35,7 +35,7 @@ def run_crew(question, file_name):
|
|
| 35 |
python_coding_tool = CodeInterpreterTool()
|
| 36 |
web_search_tool = SerperDevTool()
|
| 37 |
web_rag_tool = WebsiteSearchTool()
|
| 38 |
-
|
| 39 |
|
| 40 |
# Agents
|
| 41 |
|
|
@@ -56,37 +56,37 @@ def run_crew(question, file_name):
|
|
| 56 |
backstory="As an expert Python coding assistant, you write and/or execute Python code to help answer the question. ",
|
| 57 |
allow_delegation=False,
|
| 58 |
llm=AGENT_MODEL,
|
| 59 |
-
max_iter=
|
| 60 |
tools=[python_coding_tool],
|
| 61 |
verbose=False
|
| 62 |
)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
role="
|
| 66 |
-
goal="
|
| 67 |
-
backstory="As an expert
|
| 68 |
allow_delegation=False,
|
| 69 |
llm=AGENT_MODEL,
|
| 70 |
max_iter=3,
|
| 71 |
-
tools=[
|
| 72 |
verbose=False
|
| 73 |
)
|
| 74 |
|
| 75 |
-
|
| 76 |
-
role="
|
| 77 |
-
goal="
|
| 78 |
-
backstory="As an expert
|
| 79 |
allow_delegation=False,
|
| 80 |
llm=AGENT_MODEL,
|
| 81 |
max_iter=3,
|
| 82 |
-
tools=[
|
| 83 |
verbose=False
|
| 84 |
)
|
| 85 |
|
| 86 |
manager_agent = Agent(
|
| 87 |
role="Manager Agent",
|
| 88 |
-
goal="Try to answer the following question. If needed, delegate to **one** of your coworkers,
|
| 89 |
-
"If there is no good coworker, delegate to the
|
| 90 |
"Question: \"{topic}\" ",
|
| 91 |
backstory="As an expert manager assistant, you answer the question. ",
|
| 92 |
allow_delegation=True,
|
|
@@ -99,14 +99,14 @@ def run_crew(question, file_name):
|
|
| 99 |
|
| 100 |
manager_task = Task(
|
| 101 |
agent=manager_agent,
|
| 102 |
-
description="Try to answer the following question. If needed, delegate to **one** of your coworkers, Image Analysis Agent, Python Coding Agent,
|
| 103 |
expected_output="The answer to the question. "
|
| 104 |
)
|
| 105 |
|
| 106 |
# Crew
|
| 107 |
|
| 108 |
crew = Crew(
|
| 109 |
-
agents=[image_analysis_agent, python_coding_agent,
|
| 110 |
manager_agent=manager_agent,
|
| 111 |
tasks=[manager_task],
|
| 112 |
verbose=True
|
|
@@ -114,16 +114,11 @@ def run_crew(question, file_name):
|
|
| 114 |
|
| 115 |
print(crew.agents)
|
| 116 |
|
| 117 |
-
###
|
| 118 |
-
#if file_name:
|
| 119 |
-
# question = f"{question} File name: data/{file_name}."
|
| 120 |
-
###
|
| 121 |
-
|
| 122 |
if file_name.endswith(".py"):
|
| 123 |
with open(f"data/{file_name}", "r") as file:
|
| 124 |
-
|
| 125 |
|
| 126 |
-
question = f"{question} File
|
| 127 |
else:
|
| 128 |
question = f"{question} File name: data/{file_name}."
|
| 129 |
|
|
|
|
| 35 |
python_coding_tool = CodeInterpreterTool()
|
| 36 |
web_search_tool = SerperDevTool()
|
| 37 |
web_rag_tool = WebsiteSearchTool()
|
| 38 |
+
youtube_analysis_tool = YoutubeVideoSearchTool()
|
| 39 |
|
| 40 |
# Agents
|
| 41 |
|
|
|
|
| 56 |
backstory="As an expert Python coding assistant, you write and/or execute Python code to help answer the question. ",
|
| 57 |
allow_delegation=False,
|
| 58 |
llm=AGENT_MODEL,
|
| 59 |
+
max_iter=5,
|
| 60 |
tools=[python_coding_tool],
|
| 61 |
verbose=False
|
| 62 |
)
|
| 63 |
|
| 64 |
+
web_search_agent = Agent(
|
| 65 |
+
role="Web Search Agent",
|
| 66 |
+
goal="Search the web to help answer question \"{topic}\", then scrape the most relevant web page. ",
|
| 67 |
+
backstory="As an expert web search assistant, you search the web to help answer the question. ",
|
| 68 |
allow_delegation=False,
|
| 69 |
llm=AGENT_MODEL,
|
| 70 |
max_iter=3,
|
| 71 |
+
tools=[web_search_tool, web_rag_tool],
|
| 72 |
verbose=False
|
| 73 |
)
|
| 74 |
|
| 75 |
+
youtube_analysis_agent = Agent(
|
| 76 |
+
role="YouTube Analysis Agent",
|
| 77 |
+
goal="Analyze YouTube video to help answer question \"{topic}\". ",
|
| 78 |
+
backstory="As an expert YouTube video analysis assistant, you analyze the video to help answer the question. ",
|
| 79 |
allow_delegation=False,
|
| 80 |
llm=AGENT_MODEL,
|
| 81 |
max_iter=3,
|
| 82 |
+
tools=[youtube_analysis_tool],
|
| 83 |
verbose=False
|
| 84 |
)
|
| 85 |
|
| 86 |
manager_agent = Agent(
|
| 87 |
role="Manager Agent",
|
| 88 |
+
goal="Try to answer the following question. If needed, delegate to **one** of your coworkers, Image Analysis Agent, Python Coding Agent, Web Search Agent, or YouTube Analysis Agent for help. "
|
| 89 |
+
"If there is no good coworker, delegate to the Python Coding Agent to implement a tool for the task. "
|
| 90 |
"Question: \"{topic}\" ",
|
| 91 |
backstory="As an expert manager assistant, you answer the question. ",
|
| 92 |
allow_delegation=True,
|
|
|
|
| 99 |
|
| 100 |
manager_task = Task(
|
| 101 |
agent=manager_agent,
|
| 102 |
+
description="Try to answer the following question. If needed, delegate to **one** of your coworkers, Image Analysis Agent, Python Coding Agent, Web Search Agent, or YouTube Analysis Agent for help. Question: \"{topic}\" ",
|
| 103 |
expected_output="The answer to the question. "
|
| 104 |
)
|
| 105 |
|
| 106 |
# Crew
|
| 107 |
|
| 108 |
crew = Crew(
|
| 109 |
+
agents=[image_analysis_agent, python_coding_agent, web_search_agent, youtube_analysis_agent],
|
| 110 |
manager_agent=manager_agent,
|
| 111 |
tasks=[manager_task],
|
| 112 |
verbose=True
|
|
|
|
| 114 |
|
| 115 |
print(crew.agents)
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
if file_name.endswith(".py"):
|
| 118 |
with open(f"data/{file_name}", "r") as file:
|
| 119 |
+
file_data = file.read()
|
| 120 |
|
| 121 |
+
question = f"{question} File data:\n{file_data}"
|
| 122 |
else:
|
| 123 |
question = f"{question} File name: data/{file_name}."
|
| 124 |
|