YAML Configuration File

Introduction

The Aether Framework uses a YAML configuration file (config.yaml) to manage its settings. This file centralizes all configuration options, making it easy to customize the behavior of the framework.

This section explains:

  1. The purpose of the configuration file.

  2. How to modify the settings.

  3. Best practices for secure key management using environment variables.


Structure of config.yaml

Here’s an example config.yaml file with explanations for each section:

# Environment settings
environment: development  # Options: development, staging, production

# AI Agent configuration
aether:
  agent:
    id: 1                        # Unique ID for the agent
    role: "manager"              # Role of the agent (e.g., worker, explorer, coordinator)
    max_tasks: 10                # Maximum tasks the agent can handle at once

# LLM integration
llm:
  provider: "openai"             # Supported: openai, anthropic, ollama
  base_url: "https://api.openai.com"
  model: "gpt-4"
  api_timeout: 10                # Timeout for API calls in seconds
  retry_attempts: 3              # Retry attempts for failed requests

# Swarm Intelligence
swarm:
  redis:
    host: "localhost"            # Redis server hostname
    port: 6379                   # Redis server port
  consensus_threshold: 3         # Minimum votes needed to reach consensus

# Blockchain integration
blockchain:
  solana:
    rpc_url: "https://api.mainnet-beta.solana.com"
    wallet_path: "/path/to/solana-wallet.json"
  ethereum:
    rpc_url: "https://mainnet.infura.io/v3/${ETH_RPC_KEY}"  # Use environment variable for secure API key management

# Logging and Debugging
logging:
  level: "INFO"                  # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
  file: "logs/aether.log"
  rotate_logs: true              # Rotate log files to prevent large sizes

Editing the Configuration File

  1. Open the config.yaml file:

    • Located in the root directory of the project.

  2. Update Settings:

    • Modify values as per your environment (e.g., development or production).

    • Example:

      environment: production
      swarm:
        redis:
          host: "prod-redis.example.com"
          password: "securepassword123"
  3. Add Environment-Specific Settings:

    • Use development, staging, and production YAML files.

    • Load the appropriate file dynamically based on the environment:

      import os
      env = os.getenv("AETHER_ENVIRONMENT", "development")
      config_file = f"config.{env}.yaml"

Using Environment Variables

For sensitive data (e.g., API keys, Redis passwords), use environment variables instead of hardcoding them in the YAML file.

Steps:

  1. Add environment variables to a .env file during development:

    AETHER_LLM_PROVIDER=anthropic
    AETHER_SWARM_REDIS_PASSWORD=securepassword123
    ETH_RPC_KEY=your_infura_project_key
  2. Use these variables in the YAML file:

    blockchain:
      ethereum:
        rpc_url: "https://mainnet.infura.io/v3/${ETH_RPC_KEY}"
  3. Load environment variables dynamically in code:

    import os
    ethereum_rpc = os.getenv("ETH_RPC_KEY")

Best Practices

  • Don’t Hardcode Sensitive Data:

    • Always use environment variables for API keys, passwords, and other secrets.

  • Use Separate YAML Files for Environments:

    • Create config.development.yaml, config.staging.yaml, and config.production.yaml.

  • Document Your Changes:

    • If you add new configuration options, ensure they are documented in this section.


Example Workflow

Here’s an example workflow to set up your configuration:

  1. Set the Environment:

    AETHER_ENVIRONMENT=production
  2. Edit the YAML File: Update paths, hostnames, or thresholds based on your needs.

  3. Run the Framework:

    python main.py --config=config.production.yaml

Common Issues

  1. Missing Configuration File:

    • Error: FileNotFoundError: config.yaml not found.

    • Solution: Ensure the config.yaml file is in the correct directory or specify the path explicitly.

  2. Missing Environment Variables:

    • Error: API key for openai not found.

    • Solution: Add the required environment variables or use a .env file.

  3. Invalid YAML Syntax:

    • Error: yaml.scanner.ScannerError

    • Solution: Validate your YAML file using an online YAML linter.


Last updated