bstraehle commited on
Commit
7f78cfc
·
verified ·
1 Parent(s): fe1fabb

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +26 -19
crew.py CHANGED
@@ -22,45 +22,52 @@ def get_crew():
22
  search_tool = SerperDevTool()
23
  web_rag_tool = WebsiteSearchTool()
24
 
25
- researcher = 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 search 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
  research = Task(
34
- agent=researcher,
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
- final_answer = Task(
40
- agent=researcher,
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=[researcher],
47
- tasks=[research, final_answer],
48
  planning=True,
49
- process = Process.sequential,
50
  verbose=True
51
  )
52
 
53
- @tool("Final answer tool")
54
- def final_answer_tool(question: str, answer: str) -> str:
55
- """Given a question and initial answer, get the final answer."""
56
  prompt_template = """
57
- You are given a question and context. You must **precisely** answer the question based on the context. Do not include explanations, steps, reasoning, or additional text.
58
  **Question:** """ + question + """
59
- **Context:** """ + answer + """
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
- **Answer:**:
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()