Update crew.py
Browse files
crew.py
CHANGED
|
@@ -22,45 +22,52 @@ def get_crew():
|
|
| 22 |
search_tool = SerperDevTool()
|
| 23 |
web_rag_tool = WebsiteSearchTool()
|
| 24 |
|
| 25 |
-
|
| 26 |
role="Web Research Agent",
|
| 27 |
-
goal="Search the web for topic {topic} and scrape the most relevant web page.",
|
| 28 |
-
backstory="As an expert web research assistant, you are
|
| 29 |
tools=[search_tool, web_rag_tool],
|
| 30 |
verbose=True
|
| 31 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
research = Task(
|
| 34 |
-
agent=
|
| 35 |
-
description="Search the web for topic {topic} and scrape the most relevant web page.",
|
| 36 |
-
expected_output="Content on topic {topic}."
|
| 37 |
)
|
| 38 |
|
| 39 |
-
|
| 40 |
-
agent=
|
| 41 |
-
description="Given topic {topic} and an initial answer, get the final answer.",
|
| 42 |
-
expected_output="The final answer to topic {topic}."
|
| 43 |
)
|
| 44 |
|
| 45 |
return Crew(
|
| 46 |
-
agents=[
|
| 47 |
-
tasks=[research,
|
| 48 |
planning=True,
|
| 49 |
-
process = Process.sequential,
|
| 50 |
verbose=True
|
| 51 |
)
|
| 52 |
|
| 53 |
-
@tool("Final answer
|
| 54 |
-
def
|
| 55 |
-
"""Given a question and initial answer,
|
| 56 |
prompt_template = """
|
| 57 |
-
You are given a question and
|
| 58 |
**Question:** """ + question + """
|
| 59 |
-
**
|
| 60 |
**Example 1:** What is the capital of France? Paris
|
| 61 |
**Example 2:** What is the superlative of good? Best
|
| 62 |
**Example 3:** What is the opposite of left? Right
|
| 63 |
-
**
|
| 64 |
"""
|
| 65 |
|
| 66 |
client = OpenAI()
|
|
|
|
| 22 |
search_tool = SerperDevTool()
|
| 23 |
web_rag_tool = WebsiteSearchTool()
|
| 24 |
|
| 25 |
+
research_agent = Agent(
|
| 26 |
role="Web Research Agent",
|
| 27 |
+
goal="Search the web for topic \"{topic}\" and scrape the most relevant web page.",
|
| 28 |
+
backstory="As an expert web research assistant, you are searching the web for topic \"{topic}\" and scraping the most relevant web page.",
|
| 29 |
tools=[search_tool, web_rag_tool],
|
| 30 |
verbose=True
|
| 31 |
)
|
| 32 |
+
|
| 33 |
+
answer_agent = Agent(
|
| 34 |
+
role="Final Answer Agent",
|
| 35 |
+
goal="Provide the final answer on topic \"{topic}\".",
|
| 36 |
+
backstory="As an expert answer assistant, you are providing the final answer on topic \"{topic}\".",
|
| 37 |
+
tools=[final_answer_tool],
|
| 38 |
+
verbose=True
|
| 39 |
+
)
|
| 40 |
|
| 41 |
research = Task(
|
| 42 |
+
agent=research_agent,
|
| 43 |
+
description="Search the web for topic \"{topic}\" and scrape the most relevant web page.",
|
| 44 |
+
expected_output="Content on topic \"{topic}\"."
|
| 45 |
)
|
| 46 |
|
| 47 |
+
answer = Task(
|
| 48 |
+
agent=answer_agent,
|
| 49 |
+
description="Given topic \"{topic}\" and an initial answer, get the final answer.",
|
| 50 |
+
expected_output="The final answer to topic \"{topic}\"."
|
| 51 |
)
|
| 52 |
|
| 53 |
return Crew(
|
| 54 |
+
agents=[research_agent, answer_agent],
|
| 55 |
+
tasks=[research, answer],
|
| 56 |
planning=True,
|
|
|
|
| 57 |
verbose=True
|
| 58 |
)
|
| 59 |
|
| 60 |
+
@tool("Final answer")
|
| 61 |
+
def final_answer(question: str, answer: str) -> str:
|
| 62 |
+
"""Given a question and initial answer, provide the final answer."""
|
| 63 |
prompt_template = """
|
| 64 |
+
You are given a question and initial answer. You must **precisely** answer the question based on the initial answer. Do not include explanations, steps, reasoning, or additional text.
|
| 65 |
**Question:** """ + question + """
|
| 66 |
+
**Initial answer:** """ + answer + """
|
| 67 |
**Example 1:** What is the capital of France? Paris
|
| 68 |
**Example 2:** What is the superlative of good? Best
|
| 69 |
**Example 3:** What is the opposite of left? Right
|
| 70 |
+
**Final answer:**:
|
| 71 |
"""
|
| 72 |
|
| 73 |
client = OpenAI()
|