pf_crew.py
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from tools.custom_tool import generate_mermaid_flowchart
class ProductionFlowCrew:
def init(self):
self.customer_service_agent = Agent(
role=“Customer Service Agent”,
goal=f"“”
Your goal is to accomplish the assigned task by interacting with customers.
“”",
backstory=“An AI assistant knowledgeable in production processes, aiming to document detailed workflows.”,
human_input=True,
verbose=True
)
self.diagram_creator_agent = Agent(
role="Diagram Creator Agent",
goal="Generate a Mermaid.js workflow diagram from the provided production flow steps.",
backstory="An AI assistant specialized in creating visual workflow diagrams using Mermaid.js.",
verbose=True
)
def run(self, sku_data: dict):
gather_production_flow_task = Task(
description=f"""
Collect complete details of their production process/flow.\
""",
expected_output="A python list, listing all the steps of the production process/flow.",
agent=self.customer_service_agent,
human_input=True
)
generate_mermaid_diagram_task = Task(
description="Generate a Mermaid.js workflow diagram from the provided production flow steps.",
expected_output="A Mermaid.js diagram representing the production flow.",
agent=self.diagram_creator_agent,
tool=[generate_mermaid_flowchart],
human_input=False
)
crew = Crew(
agents=[self.customer_service_agent, self.diagram_creator_agent],
tasks=[gather_production_flow_task, generate_mermaid_diagram_task],
process=Process.sequential,
memory=True,
verbose=True
)
result = crew.kickoff()
print(result)
here is the output I get:
│ Crew Execution Started │
│ Name: crew │
│ ID: 49bfbf45-a01c-436d-8e9d-6ee38c8ef0cc
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Agent: Customer Service Agent
Task:
Collect complete details of their production process/flow.
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Error parsing LLM output, agent will retry: I did it wrong. Invalid Format: I missed the ‘Action:’ after ‘Thought:’. I will do right next, and don’t use a tool I have already used.
If you don’t need to use any more tools, you must give your best complete final answer, make sure it satisfies the expected criteria, use the EXACT format below:
Thought: I now can give a great answer
Final Answer: my best complete final answer to the task.
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Error parsing LLM output, agent will retry: I did it wrong. Invalid Format: I missed the ‘Action Input:’ after ‘Action:’. I will do right next, and don’t use a tool I have already used.
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Using Request more clarification (1)
Action ‘Request more clarification’ don’t exist, these are the only available Actions:
Agent: Customer Service Agent
Using tool: Request more clarification
Tool Input:
“Could you please detail the complete steps of your production process? Things we need include all the steps from sourcing raw materials to delivery of the final product.”
Tool Output:
I encountered an error: Action ‘Request more clarification’ don’t exist, these are the only available Actions:
Moving on then. I MUST either use a tool (use one at time) OR give my best final answer not both at the same time. When responding, I must use the following format:
Thought: you should always think about what to do
Action: the action to take, should be one of []
Action Input: the input to the action, dictionary enclosed in curly braces
Observation: the result of the action
This Thought/Action/Action Input/Result can repeat N times. Once I know the final answer, I must return the following format:
Thought: I now can give a great answer
Final Answer: Your final answer must be the great and the most complete as possible, it must be outcome described
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
├── Using Request more clarification (1)
└── Thinking…
Crew: crew
└── Task: 99fe5e84-3eb1-418a-97f7-4112f1e2c941
Status: Executing Task…
└── Agent: Customer Service Agent
Status: In Progress
└── Using Request more clarification (1)
Agent: Customer Service Agent
Final Answer:
I failed to gather any information regarding the production process as there has been no valid interaction with a customer detailing their production steps. Hence, I am unable to provide a complete detailed workflow of their production process.
Final Result: I failed to gather any information regarding the production process as there has been no valid interaction with a customer detailing their production steps. Hence, I am unable to provide a complete detailed workflow of their production process.
What do you think is going wrong?