Code
I have a crew of 3 agents with 3 tasks and 1 tool as follows:
# crews.py
from utils.agents import XxxxxAgents
from utils.tasks import XxxxxTasks
from utils.tools import XxxxxTools
from crewai import Crew, Process
import streamlit as st
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
api_key=st.secrets["OPENAI_API_KEY"],
)
class XxxxxCrew:
def __init__(self, input_a: str, input_b: str):
agents = XxxxxAgents()
tasks = XxxxxTasks()
self.agent_1 = agents.agent_1()
self.agent_2 = agents.agent_2()
self.agent_3 = agents.agent_3()
self.task_1 = tasks.task_1(self.agent_1, input_a)
self.task_2 = tasks.task_2(self.agent_2)
self.task_3 = tasks.task_3(self.agent_3, input_b)
self.crew = Crew(
agents=[
self.agent_1,
self.agent_2,
self.agent_3,
],
tasks=[
self.task_1,
self.task_2,
self.task_3,
],
manager_llm=llm,
process=Process.sequential,
verbose=True,
)
def kickoff(self):
return self.crew.kickoff()
# agents.py
from crewai import Agent
from utils.tools import XxxxxTools
class XxxxxAgents:
def agent_1(self):
return Agent(
role="xxxxx",
goal="xxxxx",
backstory="xxxxx",
allow_delegation=True,
verbose=True,
)
def agent_2(self):
return Agent(
role="xxxxx",
goal="xxxxx",
backstory="xxxxx",
allow_delegation=True,
verbose=True,
)
def agent_3(self):
return Agent(
role="xxxxx",
goal="xxxxx",
backstory="xxxxx",
tools=xxxxxTools.tools(),
allow_delegation=False,
verbose=True,
)
# tasks.py
from crewai import Task
class XxxxxTasks:
def task_1(self, agent, input_a):
return Task(
description="xxxxx",
expected_output="xxxxx",
agent=agent,
)
def task_2(self, agent):
return Task(
description="xxxxx",
expected_output="xxxxx",
agent=agent,
)
def task_3(self, agent, topic):
return Task(
description="xxxxx",
expected_output="xxxxx",
agent=agent,
)
# tools.py
from crewai_tools import tool
from exa_py import Exa
import streamlit as st
class XxxxxTools:
def _exa():
return Exa(api_key=st.secrets["EXA_API_KEY"])
@tool
def exa_search_and_get_contents(input_b, input_c):
return XxxxxTools._exa().search_and_contents(
query=input_b,
type="neural",
include_domains=input_c,
use_autoprompt=False,
num_results=3,
text=True,
summary=True,
)
def tools():
return [XxxxxTools.exa_search_and_get_contents]
Problem
The problem is that Iâm not able to deterministically get the input_c
from the agent_2 and pass it to the tool exa_search_and_get_contents
. Both input_a
and input_b
are given by a user before the crew is kicked off. But the input_c
is an answer that the agent_2 should give. So, I get input_c
correctly, but I donât know how to pass it to the tool exa_search_and_get_contents
.
Currently, Iâm getting the following error:
I encountered an error while trying to use the tool. This was the error: XxxxxTools.exa_search_and_get_contents() missing 2 required positional arguments: âinput_bâ and âinput_câ.