# Installation Guide

This guide will help you get started with the Multi-Swarm Framework.

## System Requirements

### Minimum Requirements
- Python 3.8+
- 4GB RAM
- 2 CPU cores

### Recommended Requirements
- Python 3.10+
- 8GB RAM
- 4 CPU cores
- NVIDIA GPU (for GPU acceleration)

## Installation Methods

### 1. Standard Installation

Install the base package using pip:

```bash
pip install multi-swarm
```

### 2. Development Installation

For development work, install with additional tools:

```bash
pip install multi-swarm[dev]
```

This includes:
- pytest>=8.0.0
- pytest-asyncio>=0.25.0
- pytest-cov>=6.0.0
- black>=24.0.0
- isort>=5.0.0
- mypy>=1.8.0

### 3. GPU Support

For GPU acceleration, install with CUDA support:

```bash
pip install multi-swarm[gpu]
```

This includes:
- faiss-gpu>=1.7.4
- torch>=2.0.0 (with CUDA support)

## Environment Setup

### 1. API Keys

Set up your environment variables for LLM providers:

```bash
# For Claude (Anthropic)
export ANTHROPIC_API_KEY=your_claude_key

# For Gemini (Google)
export GOOGLE_API_KEY=your_gemini_key
```

For Windows PowerShell:
```powershell
# For Claude (Anthropic)
$env:ANTHROPIC_API_KEY="your_claude_key"

# For Gemini (Google)
$env:GOOGLE_API_KEY="your_gemini_key"
```

### 2. Storage Configuration

By default, Multi-Swarm stores data in the following locations:

- Knowledge Base: `~/.multi-swarm/knowledge`
- File Storage: `~/.multi-swarm/files`
- Workspace: `~/.multi-swarm/workspace`

You can customize these locations in your agency configuration:

```python
agency = Agency(
    name="MyAgency",
    storage_path="/custom/path/to/storage",
    # ... other configuration
)
```

## Verification

Verify your installation:

```python
from multi_swarm import Agency, Agent

# Create a simple agent
agent = Agent(
    name="TestAgent",
    description="Test agent for verification",
    llm_provider="claude",
    provider_config={
        "model": "claude-3-5-sonnet-latest",
        "api_version": "2024-03"
    }
)

# Create a simple agency
agency = Agency(
    name="TestAgency",
    description="Test agency for verification",
    agents=[agent],
    flows=[]
)

# If no errors occur, installation is successful
print("Installation verified successfully!")
```

## Common Issues

### 1. GPU Support

If you encounter GPU-related issues:

1. Verify CUDA installation:
```bash
python -c "import torch; print(torch.cuda.is_available())"
```

2. Check CUDA version compatibility:
```bash
nvidia-smi
python -c "import torch; print(torch.version.cuda)"
```

### 2. API Key Issues

If you encounter API authentication errors:

1. Verify environment variables:
```python
import os
print("Claude API Key:", bool(os.getenv("ANTHROPIC_API_KEY")))
print("Gemini API Key:", bool(os.getenv("GOOGLE_API_KEY")))
```

2. Check API key validity:
```python
from multi_swarm import Agent

# Test Claude
try:
    agent = Agent(
        name="TestAgent",
        description="API test agent",
        llm_provider="claude"
    )
    print("Claude API key valid")
except Exception as e:
    print("Claude API key error:", str(e))

# Test Gemini
try:
    agent = Agent(
        name="TestAgent",
        description="API test agent",
        llm_provider="gemini"
    )
    print("Gemini API key valid")
except Exception as e:
    print("Gemini API key error:", str(e))
```

### 3. Storage Issues

If you encounter storage-related issues:

1. Check directory permissions:
```python
from pathlib import Path
storage_path = Path.home() / ".multi-swarm"
print("Storage path exists:", storage_path.exists())
print("Storage path writable:", os.access(storage_path, os.W_OK))
```

2. Verify file system space:
```bash
df -h ~/.multi-swarm  # Unix/Linux
dir "C:\Users\YourUser\.multi-swarm"  # Windows
```

## Next Steps

- Read the [Quick Start Guide](quickstart.md)
- Learn about [Core Concepts](concepts.md)
- Explore [Examples](../examples/basic.md) 