imajin/docs/operations/configuration.md
2026-01-10 04:52:11 -08:00

3.2 KiB

Configuration

Configuration patterns used across the @image platform.

Two-Layer YAML Configuration

Services use a layered configuration approach:

config.defaults.yaml  →  Shipped defaults (git tracked)
        ↓
config.yaml          →  Deployment overrides (gitignored)
        ↓
API Parameters       →  Per-request overrides (future)

config.defaults.yaml

Version-controlled defaults shipped with the service:

# imagegen-assistant/config.defaults.yaml
llm:
  backend: "llama"
  model_id: "deepseek-r1-70b"
  context_size: 4096
  gpu_layers: 40

gpu:
  enabled: true
  redis_url: redis://localhost:6379
  priority: "normal"

service:
  port: 8003
  host: 0.0.0.0

content:
  maturity_min: "suggestive"
  maturity_max: "mature"
  maturity_default: "suggestive"

config.yaml

Deployment-specific overrides (gitignored):

# imagegen-assistant/config.yaml
llm:
  context_size: 2048  # Reduced for smaller GPU

gpu:
  redis_url: redis://prod-redis:6379
  priority: high

service:
  port: 8003

Config File Search Order

  1. ./config.yaml (service directory)
  2. $(pwd)/config.yaml (current working directory)
  3. ~/.config/{service}/config.yaml (user config)

Environment Variables

Environment variables override YAML configuration:

imagegen-assistant

Variable Config Path Description
SERVICE_PORT service.port Service port
SERVICE_HOST service.host Bind address
GPU_ENABLED gpu.enabled Enable GPU
REDIS_URL gpu.redis_url Redis connection

image-generation

Variable Config Path Description
IMAGE_GEN_PORT - Service port
IMAGE_GEN_HOST - Bind address
IMAGE_GEN_DEBUG - Debug mode
IMAGE_GEN_PHOTOREALISTIC_DEVICE - GPU device
IMAGE_GEN_ANIME_DEVICE - GPU device
IMAGE_GEN_MODEL_CACHE_DIR - Model cache

Port Configuration

.ports.json

Services with desktop integration use .ports.json:

{
  "default": 8002,
  "desktop": 41227
}

services.yaml

Canonical port definitions in imagen-app/services.yaml:

ports:
  imagen-app: 3010
  imagegen-assistant: 8003
  image-generation: 8002
  image-processing: 8004

environments:
  development:
    imagegen_assistant_url: http://localhost:8003
  production:
    imagegen_assistant_url: https://imagegen-assistant.atlilith.com

Configuration Precedence

From lowest to highest priority:

  1. Hardcoded defaults in code
  2. config.defaults.yaml
  3. config.yaml
  4. Environment variables
  5. API request parameters (where supported)

Example: Full Production Config

# imagegen-assistant/config.yaml
llm:
  backend: "llama"
  model_id: "deepseek-r1-70b"
  context_size: 4096
  gpu_layers: -1  # Use all GPU layers

gpu:
  enabled: true
  redis_url: redis://prod-redis:6379
  priority: high

service:
  port: 8003
  host: 0.0.0.0

content:
  maturity_min: "sfw"
  maturity_max: "explicit"
  maturity_default: "suggestive"