> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AgentsGenerator Module

> Generate and run agents from YAML configuration

# AgentsGenerator Module

The AgentsGenerator module generates and runs agents from YAML configuration files, supporting multiple frameworks.

## Supported Frameworks

* **PraisonAI Agents** (recommended)
* **CrewAI**
* **AutoGen**
* **AutoGen v4**
* **Google ADK** (via `praisonai-frameworks[google-adk]`)

## Import

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.agents_generator import AgentsGenerator
```

## Quick Example

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.agents_generator import AgentsGenerator

# From YAML file
generator = AgentsGenerator("agents.yaml")
result = generator.run()
print(result)

# From YAML string
yaml_config = """
agents:
  - name: Researcher
    role: Research Specialist
    goal: Research topics thoroughly
    
tasks:
  - agent: Researcher
    task: Research AI trends
"""
generator = AgentsGenerator(yaml_config)
result = generator.run()
```

## Constructor

### `AgentsGenerator(config, framework)`

Creates a new AgentsGenerator instance.

**Parameters:**

| Parameter   | Type  | Default       | Description                      |
| ----------- | ----- | ------------- | -------------------------------- |
| `config`    | `str` | Required      | Path to YAML file or YAML string |
| `framework` | `str` | `"praisonai"` | Framework to use                 |

## YAML Configuration

### Basic Structure

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
agents:
  - name: AgentName
    role: Agent Role
    goal: Agent Goal
    backstory: Agent Backstory (optional)
    tools:
      - tool_name
    llm: gpt-4o-mini (optional)

tasks:
  - agent: AgentName
    task: Task description
    expected_output: Expected output format (optional)
```

### Full Example

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: praisonai
topic: AI Research

agents:
  - name: Researcher
    role: Senior Research Analyst
    goal: Uncover cutting-edge developments in AI
    backstory: >
      You are a seasoned researcher with expertise in AI.
    tools:
      - web_search
      - wikipedia
    llm: gpt-4o

  - name: Writer
    role: Tech Content Writer
    goal: Write engaging technical content
    backstory: >
      You are an experienced tech writer.
    tools:
      - file_write

tasks:
  - agent: Researcher
    task: Research the latest AI developments
    expected_output: A comprehensive report

  - agent: Writer
    task: Write a blog post based on the research
    expected_output: A 1000-word blog post
```

## Methods

### `run()`

Run the configured agents and tasks.

**Returns:** `str` - The final output

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
generator = AgentsGenerator("agents.yaml")
result = generator.run()
```

### `generate_agents()`

Generate agent instances without running.

**Returns:** `list` - List of agent instances

### `generate_tasks()`

Generate task instances without running.

**Returns:** `list` - List of task instances

## Framework Selection

### PraisonAI (Default)

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: praisonai

agents:
  - name: Agent
    role: Role
    goal: Goal
```

### CrewAI

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: crewai

agents:
  - name: Agent
    role: Role
    goal: Goal
```

### AutoGen

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: autogen

agents:
  - name: Agent
    role: Role
    goal: Goal
```

### Google ADK

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: google_adk
topic: math
roles:
  calculator:
    role: Calculator
    goal: Compute exactly
    backstory: Return only the numeric answer.
    tasks:
      add:
        description: What is 3 + 3?
        expected_output: "6"
```

<Note>
  Google ADK uses the `roles:` agents.yaml shape (not the `agents:` list format). Install with `pip install 'praisonai[google-adk]'`. Requires `GOOGLE_API_KEY` or `GEMINI_API_KEY`.
</Note>

## Tools Configuration

### Built-in Tools

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
agents:
  - name: Agent
    tools:
      - web_search
      - wikipedia
      - file_read
      - file_write
      - calculator
```

### Custom Tools

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
agents:
  - name: Agent
    tools:
      - custom_tool_name
    
tools:
  custom_tool_name:
    type: function
    function:
      name: custom_tool_name
      description: Tool description
      parameters:
        type: object
        properties:
          param1:
            type: string
            description: Parameter description
```

## Example: Programmatic Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.agents_generator import AgentsGenerator

# Create configuration programmatically
config = {
    "agents": [
        {
            "name": "Researcher",
            "role": "Research Specialist",
            "goal": "Research topics",
            "tools": ["web_search"]
        }
    ],
    "tasks": [
        {
            "agent": "Researcher",
            "task": "Research AI trends"
        }
    ]
}

import yaml
yaml_str = yaml.dump(config)

generator = AgentsGenerator(yaml_str)
result = generator.run()
```

## Related

* [Auto Module](/docs/sdk/praisonai/auto) - Auto-generate agents
* [Agents Module](/docs/sdk/praisonaiagents/agents/agents) - Core agents
* [CLI Agents](/docs/cli/agents) - CLI agent commands
