Update crew.py
Browse files
crew.py
CHANGED
@@ -41,7 +41,7 @@ def run_crew(question, file_name):
|
|
41 |
|
42 |
image_analysis_agent = Agent(
|
43 |
role="Image Analysis Agent",
|
44 |
-
goal="Analyze image to help answer question \"{
|
45 |
backstory="As an expert image analysis assistant, you analyze the image to help answer the question.",
|
46 |
allow_delegation=False,
|
47 |
llm=AGENT_MODEL,
|
@@ -52,7 +52,7 @@ def run_crew(question, file_name):
|
|
52 |
|
53 |
python_coding_agent = Agent(
|
54 |
role="Python Coding Agent",
|
55 |
-
goal="Write and/or execute Python code to help answer question \"{
|
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,
|
@@ -63,7 +63,7 @@ def run_crew(question, file_name):
|
|
63 |
|
64 |
web_search_agent = Agent(
|
65 |
role="Web Search Agent",
|
66 |
-
goal="Search the web to help answer question \"{
|
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,
|
@@ -74,7 +74,7 @@ def run_crew(question, file_name):
|
|
74 |
|
75 |
youtube_analysis_agent = Agent(
|
76 |
role="YouTube Analysis Agent",
|
77 |
-
goal="Analyze YouTube video to help answer question \"{
|
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,
|
@@ -87,7 +87,7 @@ def run_crew(question, file_name):
|
|
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: \"{
|
91 |
backstory="As an expert manager assistant, you answer the question.",
|
92 |
allow_delegation=True,
|
93 |
llm=MANAGER_MODEL,
|
@@ -99,7 +99,7 @@ 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, Web Search Agent, or YouTube Analysis Agent for help. Question: \"{
|
103 |
expected_output="The answer to the question."
|
104 |
)
|
105 |
|
@@ -116,12 +116,12 @@ def run_crew(question, file_name):
|
|
116 |
|
117 |
if file_name:
|
118 |
question = f"{question} File name: data/{file_name}."
|
119 |
-
if file_name.endswith(".py")
|
120 |
with open(f"data/{file_name}", "r") as file:
|
121 |
question = f"{question} File data:\n{file.read()}"
|
122 |
|
123 |
print(f"Question: {question}")
|
124 |
-
initial_answer = crew.kickoff(inputs={"
|
125 |
print(f"Initial answer: {initial_answer}")
|
126 |
final_answer = get_final_answer(question, str(initial_answer))
|
127 |
print(f"Final answer: {final_answer}")
|
|
|
41 |
|
42 |
image_analysis_agent = Agent(
|
43 |
role="Image Analysis Agent",
|
44 |
+
goal="Analyze image to help answer question \"{question}\"",
|
45 |
backstory="As an expert image analysis assistant, you analyze the image to help answer the question.",
|
46 |
allow_delegation=False,
|
47 |
llm=AGENT_MODEL,
|
|
|
52 |
|
53 |
python_coding_agent = Agent(
|
54 |
role="Python Coding Agent",
|
55 |
+
goal="Write and/or execute Python code to help answer question \"{question}\"",
|
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,
|
|
|
63 |
|
64 |
web_search_agent = Agent(
|
65 |
role="Web Search Agent",
|
66 |
+
goal="Search the web to help answer question \"{question}\", 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,
|
|
|
74 |
|
75 |
youtube_analysis_agent = Agent(
|
76 |
role="YouTube Analysis Agent",
|
77 |
+
goal="Analyze YouTube video to help answer question \"{question}\"",
|
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,
|
|
|
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: \"{question}\"",
|
91 |
backstory="As an expert manager assistant, you answer the question.",
|
92 |
allow_delegation=True,
|
93 |
llm=MANAGER_MODEL,
|
|
|
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: \"{question}\"",
|
103 |
expected_output="The answer to the question."
|
104 |
)
|
105 |
|
|
|
116 |
|
117 |
if file_name:
|
118 |
question = f"{question} File name: data/{file_name}."
|
119 |
+
if file_name.endswith(".py"):
|
120 |
with open(f"data/{file_name}", "r") as file:
|
121 |
question = f"{question} File data:\n{file.read()}"
|
122 |
|
123 |
print(f"Question: {question}")
|
124 |
+
initial_answer = crew.kickoff(inputs={"question": question})
|
125 |
print(f"Initial answer: {initial_answer}")
|
126 |
final_answer = get_final_answer(question, str(initial_answer))
|
127 |
print(f"Final answer: {final_answer}")
|