YAML Configuration Filentitled
YAML Configuration File
Introduction
The SynaptiQ Systems 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:
The purpose of the configuration file.
How to modify the settings.
Best practices for secure key management using environment variables.
Structure of config.yaml
config.yamlHere’s an example config.yaml file with explanations for each section:
yamlCopy code# Environment settings
environment: development  # Options: development, staging, production
# AI Agent configuration
synaptiq:
  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/synaptiq.log"
  rotate_logs: true              # Rotate log files to prevent large sizesEditing the Configuration File
Open the
config.yamlfile:Located in the root directory of the project.
Update Settings:
Modify values according to your environment (e.g., development or production).
Example:
yamlCopy codeenvironment: production
swarm:
  redis:
    host: "prod-redis.example.com"
    password: "securepassword123"Add Environment-Specific Settings:
Use separate YAML files for development, staging, and production environments.
Load the appropriate file dynamically based on the environment:
pythonCopy codeimport os
env = os.getenv("SYNAPTIQ_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:
Add environment variables to a
.envfile during development:
bashCopy codeSYNAPTIQ_LLM_PROVIDER=anthropic
SYNAPTIQ_SWARM_REDIS_PASSWORD=securepassword123
ETH_RPC_KEY=your_infura_project_keyUse these variables in the YAML file:
yamlCopy codeblockchain:
  ethereum:
    rpc_url: "https://mainnet.infura.io/v3/${ETH_RPC_KEY}"Load environment variables dynamically in code:
pythonCopy codeimport 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, andconfig.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:
Set the Environment:
bashCopy codeSYNAPTIQ_ENVIRONMENT=productionEdit the YAML File: Update paths, hostnames, or thresholds based on your needs.
Run the Framework:
bashCopy codepython main.py --config=config.production.yamlCommon Issues
Missing Configuration File:
Error:
FileNotFoundError: config.yaml not found.Solution: Ensure the
config.yamlfile is in the correct directory or specify the path explicitly.
Missing Environment Variables:
Error:
API key for openai not found.Solution: Add the required environment variables or use a
.envfile.
Invalid YAML Syntax:
Error:
yaml.scanner.ScannerErrorSolution: Validate your YAML file using an online YAML linter.
Last updated