crewAI Multi-Agent Systems Framework

repository·main·Indexed 41 days ago

https://github.com/akj2018/multi-ai-agent-systems-with-crewai

A framework for building multi-agent AI systems to automate complex business workflows through autonomous, role-playing agents. It supports sequential, hierarchical, and parallel collaboration processes, and includes features for agent memory, custom tool creation via BaseTool, and integration with LLMs like OpenAI.

Tokens
10.7K
Snippets
41
Records
43
Agent score
50%

What's inside crewAI

  1. Personalized Outreach Strategy for Tech Startups

    main

    When configuring agents for tech startup outreach, the outreach strategy must focus on three core pillars to align with startup priorities:

    1. Innovation: Emphasize that products or services are at the forefront of technology.
    2. Scalability: Explicitly discuss how solutions can grow alongside the startup's business.
    3. Support: Highlight the specific resources and support provided, as startups require high levels of reliability and assistance during growth phases.

    Use these pillars to guide the persona and task descriptions of your CrewAI agents to ensure the generated content resonates with the target audience's unique challenges.

  2. Apply the Strategy and Innovation Framework for Enterprise Outreach

    main

    When designing AI agents or manual outreach workflows for enterprise-level clients, use the Strategy and Innovation Framework. The framework shifts the focus from simple product sales to strategic partnership and seamless integration.

    When configuring agent prompts or message templates for enterprise targets, ensure the following three pillars are addressed:

    1. Strategic Partnership: Emphasize long-term value rather than transactional benefits.
    2. Integration: Highlight how the solution fits into existing enterprise infrastructure.
    3. Innovation: Demonstrate how the solution drives organizational progress.
  3. Configure Hierarchical Collaboration

    main

    In hierarchical collaboration, crewAI automatically creates a manager agent to oversee the crew.

    Requirements:

    • Set process=Process.hierarchical in the Crew object.
    • You must provide a manager_llm (e.g., using ChatOpenAI) to the Crew object.

    The manager agent allocates tasks based on roles and tools, evaluates outcomes, and ensures standards are met. This approach helps prevent the 'fading context' problem seen in sequential processes.

    from crewai import Crew
    from crewai.process import Process
    from langchain_openai import ChatOpenAI
    
    crew = Crew(
        agents=my_agents,
        tasks=my_tasks,
        process=Process.hierarchical,
        manager_llm=ChatOpenAI(model="gpt-4")
    )
  4. Draft customer engagement messages for small businesses

    main

    When conducting outreach to small businesses, focus on personalization, operational efficiency, and community support. Use the following template to structure your messages, ensuring you replace the bracketed placeholders with specific details about the target business and your own offerings.

    Hello [Name],
    
    As a local business owner, your dedication to [specific aspect of their business, e.g., providing excellent customer service, offering high-quality products] truly stands out. At [Your Company], we offer solutions that can help businesses like [Business Name] become even more efficient and effective.
    
    [Describe a specific feature of your product/service and how it solves a problem they face].
    
    We would love to discuss how we can be part of your success story.
    
    Warm regards,
    [Your Name]
  5. How Hierarchical Process works in crewAI

    main

    In a hierarchical process, the Crew does not just run tasks sequentially; instead, it creates a manager to oversee the workflow and delegate tasks to the appropriate agents.

    To implement this:

    1. Set process=Process.hierarchical in the Crew definition.
    2. Provide a manager_llm (using a LangChain chat model like ChatOpenAI) to act as the manager that coordinates the agents.
    from crewai import Crew, Process
    from langchain_openai import ChatOpenAI
    
    financial_trading_crew = Crew (
        agents=[data_analyst_agent, trading_strategy_agent, execution_agent, risk_management_agent],
        tasks=[data_analysis_task, strategy_development_task, execution_planning_task, risk_assessment_task],
        verbose=True,
        process=Process.hierarchical,
        manager_llm=ChatOpenAI(model="gpt-3.5-turbo", temperature=0.7)
    )
  6. Enable Memory in a Crew

    main

    To allow agents to remember, reason, and learn from past interactions (including short-term, long-term, and entity memory), enable memory by setting memory=True when initializing the Crew object.

    from crewai import Crew, Agent, Task, Process
    
    my_crew = Crew(
        agents=[...],
        tasks=[...],
        process=Process.sequential,
        memory=True,
        verbose=True
    )
  7. Define Tasks and use Task Context

    main

    Tasks define the specific work an agent must perform. Key parameters include:

    • description: Detailed instructions for the task.
    • expected_output: What the agent should produce.
    • agent: The agent assigned to the task.
    • context: (Optional) A list of previously completed Task objects. The current task will wait for these tasks to finish and use their outputs as input.
    • output_file: (Optional) The filename where the task result should be saved.
    • async_execution: (Optional) If True, the task runs asynchronously.

    Example of a task using context:

    resume_strategy_task = Task(
        description="Tailor the resume using previous research and profiles.",
        expected_output="An updated resume.",
        agent=resume_strategist,
        context=[research_task, profile_task],
        output_file="tailored_resume.md"
    )
    resume_strategy_task = Task(
        description=(
            "Using the profile and job requirements obtained from "
            "previous tasks, tailor the resume to highlight the most "
            "relevant areas. Employ tools to adjust and enhance the "
            "resume content. Make sure this is the best resume even but "
            "don't make up any information. Update every section, "
            "inlcuding the initial summary, work experience, skills, "
            "and education. All to better reflect the candidates "
            "abilities and how it matches the job posting."
        ),
        expected_output=(
            "An updated resume that effectively highlights the candidate's "
            "qualifications and experiences relevant to the job."
        ),
        output_file="tailored_resume.md",
        context=[research_task, profile_task],
        agent=resume_strategist
    )
  8. Assign Tools to Agents or Tasks

    main

    Tools can be assigned at two levels:

    1. Agent Level: The agent can use the tool for any task it performs.
    2. Task Level: The agent will only use the tool for that specific task.

    Note: Task-level tools override Agent-level tools.

    from crewai import Task
    
    inquiry_resolution = Task(
        description="...",
        expected_output="...",
        agent=customer_support_agent,
        tools=[docs_scrape_tool] # Task-level tool assignment
    )
  9. Configure CrewAI Environment Variables

    main

    Before initializing Agents, you must set the necessary environment variables for your LLM provider and search tools. At a minimum, you need OPENAI_API_KEY and OPENAI_MODEL_NAME. If using SerperDevTool, you also need SERPER_API_KEY.

    import os
    os.environ['OPENAI_API_KEY'] = 'Your OPENAI API KEY'
    os.environ['OPENAI_MODEL_NAME'] = 'gpt-4-turbo'
    os.environ['SERPER_API_KEY'] = 'Your SERPER API KEY'