crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
18.69k stars 2.58k forks source link

Can Crew AI agents execute a task based on instructions written in a document? #717

Closed mintomohan closed 1 week ago

mintomohan commented 3 months ago

Here is my use case:

I have a text file outlining the steps for completing tasks:

Task A: Create Report
1. Find today's date.
2. Read data from the "my_info.csv" file where the "plan_date" is today.
3. Display the results.

Task B: Copy File to FTP
1. Export data from the report_table to an Excel file.
2. Copy the file to the FTP path "/report".

I have developed tools to handle each individual step:

Crew Definition

My full source code:

from crewai_tools import tool
import datetime
from crewai import Agent, Task, Crew, Process
from langchain_openai import ChatOpenAI
from dotenv import load_dotenv
from crewai_tools import TXTSearchTool
from crewai_tools import CSVSearchTool

llm = ChatOpenAI(model='gpt-3.5-turbo-0125', temperature=0.1)

@tool("CurrentDateTool")
def current_date_tool() -> str:
    """Tool to get the current date."""
    return 'Today is ' + datetime.date.today().strftime("%Y-%m-%d (%A)")

steps_search_tool = TXTSearchTool(txt='task_steps.txt')

csv_search_tool = CSVSearchTool()

class MyCrew:

    def __init__(self, task_description, expected_output, verbose=False):
        self.verbose = verbose
        # Define agents with specific roles and tools
        worker_agent = Agent(
            role='Worker',
            goal=f'Perform the tasks requested step by step.',
            backstory="""Perform the assigned tasks """,
            tools=[current_date_tool, 
                   csv_search_tool], 
            verbose=self.verbose,
            llm=llm
        )

        supervisor_agent = Agent (
            role = 'Supervisor',
            goal = 'Split the list of steps to individual tasks, and invoke appropriate agents for each step.',
            backstory = 'good at work breakdown and task allocation',
            verbose=self.verbose,
            llm=llm
        )

        manager_agent = Agent(
            role='Manager',
            goal=f'Delegate the steps to other agents.',
            backstory="""PMP certified project manager""",
            verbose=self.verbose,
            llm=llm
        )

        # Create tasks for the agents
        main_task = Task(
            description = task_description, 
            expected_output = expected_output,
            tools=[current_date_tool, 
                   steps_search_tool,
                   csv_search_tool], 
            agent=manager_agent
        )

        # Assemble the crew with a sequential process
        self.search_crew = Crew(
            agents=[worker_agent,supervisor_agent],
            manager_agent=manager_agent,
            tasks=[main_task],
            process=Process.hierarchical,
            verbose=self.verbose,
        )

    def kickoff(self):
        return self.search_crew.kickoff()

if __name__ == '__main__':
    my_crew = MyCrew(task_description='List delayed Tasks',
                     expected_output='Display the delayed task names.',
                     verbose=True) 
    print(my_crew.kickoff())

Expected output: Agents will identify the steps from the "task_steps.txt" file and execute them.

Actual output: Agents identify the steps from the "task_steps.txt" file and just display them.

gadgethome commented 3 months ago

You could try something like

goal = f'Perform the {mytask} requested step by step.'

Where {mytask} is read from your csv file and stored in this variable.

cbruyndoncx commented 2 months ago

The v0.30 has an input format for tasks, you could write a custom parser if you really want to stick to your format

cbruyndoncx commented 2 months ago

Fyi general reminder

Use the Discord server for help and share your code, this might be related to a known issue, or completely specific to your setup. share as much details as you can in the support channel over there and perhaps go through some of the resources first to improve your understanding of crewai.

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 week ago

This issue was closed because it has been stalled for 5 days with no activity.