babylon.config
Configuration package for Babylon/Babylon.
The configuration hierarchy: 1. Environment variables (.env file) 2. Default values (defined in each config class)
All configs are immutable after initialization.
- class babylon.config.BaseConfig[source]
Bases:
objectBase configuration singleton.
All values are class attributes for direct access without instantiation. This mirrors the material reality: configuration exists whether you acknowledge it or not.
- class babylon.config.ChromaDBConfig[source]
Bases:
objectConfiguration for ChromaDB vector database.
The Archive persists embeddings locally using DuckDB+Parquet. No external servers required - fully embedded, fully materialist.
- class babylon.config.GameDefines(**data)[source]
Bases:
BaseModelCentralized game coefficients extracted from hardcoded values.
GameDefines collects numerical constants that were previously scattered across system implementations. By centralizing them here, we can: - Document their purpose and valid ranges - Override them per-scenario for calibration - Test the sensitivity of outcomes to coefficient changes
The model is frozen (immutable) to ensure defines remain constant throughout a simulation run.
Structure follows the YAML file organization: - economy: Imperial rent extraction and value flow - survival: P(S|A) and P(S|R) survival calculus - solidarity: Consciousness transmission - behavioral: Behavioral economics (loss aversion) - tension: Tension dynamics - consciousness: Consciousness drift - territory: Territory dynamics - topology: Phase transition thresholds (gaseous/liquid/solid) - metabolism: Metabolic rift (ecological limits) - struggle: Struggle dynamics (Agency Layer) - initial: Initial conditions
- Parameters:
economy (EconomyDefines)
survival (SurvivalDefines)
solidarity (SolidarityDefines)
behavioral (BehavioralDefines)
tension (TensionDefines)
consciousness (ConsciousnessDefines)
territory (TerritoryDefines)
topology (TopologyDefines)
metabolism (MetabolismDefines)
struggle (StruggleDefines)
initial (InitialDefines)
- classmethod default_yaml_path()[source]
Return the default path to defines.yaml.
- Return type:
- Returns:
Path to src/babylon/data/defines.yaml
- classmethod load_default()[source]
Load GameDefines from the default YAML location.
Falls back to default values if file doesn’t exist.
- Return type:
- Returns:
GameDefines instance
- classmethod load_from_yaml(path)[source]
Load GameDefines from a YAML file.
- Parameters:
path (
str|Path) – Path to the YAML file (absolute or relative)- Return type:
- Returns:
GameDefines instance populated from YAML
- Raises:
FileNotFoundError – If the YAML file doesn’t exist
yaml.YAMLError – If the YAML is malformed
pydantic.ValidationError – If values fail validation
- model_config: ClassVar[ConfigDict] = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- economy: EconomyDefines
- survival: SurvivalDefines
- solidarity: SolidarityDefines
- behavioral: BehavioralDefines
- tension: TensionDefines
- consciousness: ConsciousnessDefines
- territory: TerritoryDefines
- topology: TopologyDefines
- metabolism: MetabolismDefines
- struggle: StruggleDefines
- initial: InitialDefines
- class babylon.config.LLMConfig[source]
Bases:
objectConfiguration for LLM API integration.
Supports hybrid setup: - Chat: DeepSeek (primary) / OpenAI (fallback) - Embeddings: Ollama (local, default) / OpenAI (cloud)
The bourgeois cloud API is a transitional tool until local compute infrastructure is fully established.
- classmethod get_embedding_headers()[source]
Get HTTP headers for Embedding API requests.
Ollama doesn’t need auth headers; OpenAI does.
- classmethod get_model_dimensions()[source]
Get the embedding dimensions for the configured model.
- Return type:
- Returns:
Number of dimensions for the embedding model
- classmethod is_ollama_embeddings()[source]
Check if using Ollama for embeddings (local, no API key needed).
- Return type:
- classmethod validate()[source]
Validate the Chat LLM configuration.
- Raises:
ValueError – If required configuration is missing
- Return type:
- classmethod validate_embeddings()[source]
Validate embedding configuration.
For Ollama: Just check the base URL is set. For OpenAI: Check API key is available.
- Raises:
ValueError – If required configuration is missing
- Return type:
- class babylon.config.TestingConfig[source]
Bases:
objectConfiguration for test environments.
Uses in-memory SQLite and temporary directories to ensure test isolation and reproducibility.
- babylon.config.setup_logging(config_path=None, default_level=None, pyproject_path=None)[source]
Initialize the logging system.
- Parameters:
- Return type:
Configuration is loaded in this order (highest precedence first): 1. LOG_LEVEL environment variable 2. default_level parameter 3. pyproject.toml [tool.babylon.logging] section 4. logging.yaml file (if config_path provided) 5. Default values
The logging system is deterministic - given the same inputs, it produces the same outputs. No probabilistic behavior.
Handler hierarchy: - Console: Human-readable, INFO level (or configured level) - Main file (RotatingFileHandler): JSON Lines, DEBUG level, 10MB rotation - Error file (RotatingFileHandler): JSON Lines, ERROR only, 5MB rotation
Modules
Base configuration for the Babylon/Babylon engine. |
|
ChromaDB configuration for the Archive layer. |
|
Game defines for centralized coefficient configuration. |
|
LLM API configuration for text generation and embeddings. |
|
Logging configuration for Babylon/Babylon. |
|
Testing configuration for Babylon/Babylon. |