Example - CLI

Example: AI-Driven Market Research (Using the the CLI)

To better understand how to run a workflow using Peeps AI, let's walk through a practical example. This example demonstrates how to set up a simple multi-agent system to automate a market research task.

Project Setup

Start by creating a new Peeps AI project:

peepsai create group market_research

This command generates the basic folder structure with necessary configuration files.

Defining Agents and Tasks

agents.yaml

Define two agents: a Researcher and a Data Analyst.

# src/market_research/config/agents.yaml
researcher:
  role: "Market Research Specialist"
  goal: "Identify key trends in the AI industry."
  backstory: "An expert with years of experience analyzing industry trends and market data."

data_analyst:
  role: "Data Analyst"
  goal: "Analyze collected data and generate actionable insights."
  backstory: "Proficient in data interpretation and presenting findings clearly."

tasks.yaml

Outline the tasks for each agent.

# src/market_research/config/tasks.yaml
collect_data:
  description: "Research the latest AI trends for 2024."
  expected_output: "A list of key trends and emerging technologies."
  agent: researcher

analyze_data:
  description: "Analyze the research findings to identify actionable insights."
  expected_output: "A detailed report summarizing key trends with recommendations."
  agent: data_analyst
  output_file: insights_report.md

Customizing the Group Logic

Modify group.py to define the workflow process:

# src/market_research/group.py
from peepsai import Agent, Peeps, Process, Task
from peepsai.project import PeepsBase, agent, group, task

@PeepsBase
class MarketResearchGroup:
    @agent
    def researcher(self) -> Agent:
        return Agent(config=self.agents_config['researcher'])

    @agent
    def data_analyst(self) -> Agent:
        return Agent(config=self.agents_config['data_analyst'])

    @task
    def collect_data(self) -> Task:
        return Task(config=self.tasks_config['collect_data'])

    @task
    def analyze_data(self) -> Task:
        return Task(config=self.tasks_config['analyze_data'])

    @group
    def group(self) -> Peeps:
        return Peeps(
            agents=self.agents,
            tasks=self.tasks,
            process=Process.sequential
        )

Running the Workflow

Navigate to the project directory:

cd market_research

Execute the workflow:

peepsai run

Alternatively, run it directly with Python:

python src/market_research/main.py

Reviewing the Output

After successful execution:

  • Check the console output for real-time logs of each task's progress.

  • Locate the final report in insights_report.md generated by the Data Analyst.

Advanced Example - Adding Dynamic Inputs

You can pass custom inputs to make the workflow dynamic:

peepsai run --inputs '{"industry": "Healthcare AI"}'

Update agents.yaml and tasks.yaml to utilize the {industry} variable dynamically in descriptions and goals.

Troubleshooting Tips

  • If the workflow doesn't start:

    peepsai run --verbose

    This will display detailed logs for debugging.

  • Missing dependencies:

    pip install 'peepsai[tools]'

C

Last updated