Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Query] Multi-agent with human in loop at every step #853

Open
arunbaby0 opened this issue Jul 2, 2024 · 4 comments
Open

[Query] Multi-agent with human in loop at every step #853

arunbaby0 opened this issue Jul 2, 2024 · 4 comments

Comments

@arunbaby0
Copy link

arunbaby0 commented Jul 2, 2024

I am trying to create a hierarchical crew with 3 agents for chatbot, the main agent should route the interaction of the human to the other 2 agents based on the human inputs (chat messages).
Also, the other 2 agents should take human input at each step of the process to find out what the human wants.

front = Agent(
    role='Front Agent',
    goal='...',
    verbose=True,
    memory=True,
    backstory=(
        "..."
    ),
    tools=[]
)


second = Agent(
    role='Second Agent',
    goal='...',
    verbose=True,
    memory=True,
    backstory=(
        "..."
    ),
    tools=[]
)


third = Agent(
    role='Third Agent',
    goal='...',
    verbose=True,
    memory=True,
    backstory=(
        "..."
    ),
    tools=[]
)


front_task = Task(
    description=(
        "Interact with the customer to determine if their request"
    ),
    expected_output=(
        "A decision on whether the customer's request is for first agent or second,"
        "and delegation to the respective agent."
    ),
    agent=front,
    human_input_required=True,
    human_input_instructions="..."
)


second_task = Task(
    description=(
        "Ask the customer relevant questions to understand their"
    ),
    expected_output=(
        "A detailed list of the customer's requirements and preferences"
    ),
    agent=second,
    human_input_required=True,
    human_input_instructions="..."
)

third_task = Task(
    description=(
        "Ask the customer relevant questions to understand"
    ),
    expected_output=(
        "A detailed list of the customer's service requirements"
    ),
    agent=third,
    human_input_required=True,
    human_input_instructions="..."
)

# Create Crew
my_crew = Crew(
    agents=[front, second, third],
    tasks=[front_task, second_task, third_task],
    process=Process.sequential,
    human_input=True
)

# Kick off the crew with a sample input
result = my_crew.kickoff()
print(result)

In this, the agent is not stopping to get any inputs from the user. What I am missing here?

@theCyberTech
Copy link
Collaborator

3 immediate issues Im seeing.

  1. You say you are trying to create a hierarchical crew but you have configured the crew process as sequential
  2. You are using the following parameters in your tasks:
    human_input_required
    human_input_instructions

These are not valid parameters for the task class, you need human_input= True
3. You are defining human_input=True on your crew instance, this is not correct and should only be on your tasks, see the docs - https://docs.crewai.com/how-to/Human-Input-on-Execution/

@arunbaby0
Copy link
Author

Thanks for the quick response, @theCyberTech.
However, I am still facing issues. PFB the changed code. I want the front agent to ask the human to select either second or third agent. And for second and third agent also, I want human interaction to finally decide what the human wants.
And at every step I am expecting the human input.

front = Agent(
    role='Front Agent',
    goal='...',
    verbose=True,
    memory=True,
    backstory=(
        "..."
    ),
    tools=[]
)


second = Agent(
    role='Second Agent',
    goal='...',
    verbose=True,
    memory=True,
    backstory=(
        "..."
    ),
    tools=[]
)


third = Agent(
    role='Third Agent',
    goal='...',
    verbose=True,
    memory=True,
    backstory=(
        "..."
    ),
    tools=[]
)


front_task = Task(
    description=(
        "Interact with the customer to determine if their request"
    ),
    expected_output=(
        "A decision on whether the customer's request is for first agent or second,"
        "and delegation to the respective agent."
    ),
    agent=front,
    human_input=True
)


second_task = Task(
    description=(
        "Ask the customer relevant questions to understand their"
    ),
    expected_output=(
        "A detailed list of the customer's requirements and preferences"
    ),
    agent=second,
    human_input=True
)

third_task = Task(
    description=(
        "Ask the customer relevant questions to understand"
    ),
    expected_output=(
        "A detailed list of the customer's service requirements"
    ),
    agent=third,
    human_input=True
)

# Create Crew
my_crew = Crew(
    agents=[front_desk_agent, sales_agent, service_agent],
    tasks=[front_desk_task, sales_task, service_task],
    manager_llm=ChatOpenAI(temperature=0, model="gpt-4"),  # Mandatory if manager_agent is not set
    process=Process.hierarchical,  # Specifies the hierarchical management approach
    memory=True,  # Enable memory usage for enhanced task execution
    manager_agent=None,  # Optional: explicitly set a specific agent as manager instead of the manager_llm

)

# Kick off the crew with a sample input
result = my_crew.kickoff()
print(result)

@theCyberTech
Copy link
Collaborator

Ok, I have some suggestions but we are better off taking this to discord if that's ok?

IF you could raise a support post I can respond there in detail

@arunbaby0
Copy link
Author

Sure. I will post it there.
Thanks, @theCyberTech

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants