haive.games.core.config.base ============================ .. py:module:: haive.games.core.config.base .. autoapi-nested-parse:: Base configuration classes for configurable games. from typing import Any This module provides the foundation for creating flexible game configurations that support multiple LLM providers and configuration modes. Classes ------- .. autoapisummary:: haive.games.core.config.base.BaseGameConfig haive.games.core.config.base.ConfigMode haive.games.core.config.base.GamePlayerRole Functions --------- .. autoapisummary:: haive.games.core.config.base.create_advanced_config haive.games.core.config.base.create_example_config haive.games.core.config.base.create_llm_config haive.games.core.config.base.create_simple_config Module Contents --------------- .. py:class:: BaseGameConfig Bases: :py:obj:`haive.core.engine.agent.agent.AgentConfig`, :py:obj:`abc.ABC` Base configuration for all configurable games. This class provides a unified configuration system that supports: - Legacy hardcoded engines (backward compatibility) - Simple model string configuration - Example-based configuration - Advanced PlayerAgentConfig configuration Games should extend this class and implement the required abstract methods. .. py:method:: build_legacy_engines() :abstractmethod: Build legacy hardcoded engines for backward compatibility. :returns: List of game engines using hardcoded LLM configurations .. py:method:: configure_engines() Configure engines based on the determined mode. .. py:method:: create_engines_from_player_configs(player_configs) :abstractmethod: Create engines from detailed player configurations. :param player_configs: Dictionary mapping role names to PlayerAgentConfig :returns: List of configured game engines .. py:method:: create_example_player_configs(example_name) Create player configs from example configuration. .. py:method:: create_simple_player_configs() Create player configs from simple model strings. This method should be overridden by games that use different field names (e.g., white_model/black_model instead of player1_model/player2_model). .. py:method:: determine_config_mode() Automatically determine configuration mode based on provided fields. .. py:method:: get_example_configs() :abstractmethod: Define available example configurations. :returns: Dictionary mapping example names to configuration parameters .. rubric:: Examples { "gpt_vs_claude": { "player1_model": "gpt-4", "player2_model": "claude-3-opus", "temperature": 0.7 }, "budget": { "player1_model": "gpt-3.5-turbo", "player2_model": "gpt-3.5-turbo", "temperature": 0.5 } } .. py:method:: get_player_names() Get display names for all players. .. py:method:: get_role_definitions() :abstractmethod: Define the player roles for this game. :returns: Dictionary mapping role names to GamePlayerRole definitions .. rubric:: Examples { "white_player": GamePlayerRole(name="white_player", display_name="White"), "black_player": GamePlayerRole(name="black_player", display_name="Black"), "white_analyzer": GamePlayerRole(name="white_analyzer", display_name="White Analyst", is_analyzer=True), "black_analyzer": GamePlayerRole(name="black_analyzer", display_name="Black Analyst", is_analyzer=True), } .. py:class:: ConfigMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` Configuration mode for game setup. Initialize self. See help(type(self)) for accurate signature. .. py:class:: GamePlayerRole(/, **data) Bases: :py:obj:`pydantic.BaseModel` Definition of a player role in a game. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:function:: create_advanced_config(config_class, player_configs, **kwargs) Create a game configuration with detailed player configs. :param config_class: The game's configuration class :param player_configs: Dictionary mapping role names to PlayerAgentConfig :param \*\*kwargs: Additional configuration parameters :returns: Configured game instance .. py:function:: create_example_config(config_class, example_name, **kwargs) Create a game configuration from a predefined example. :param config_class: The game's configuration class :param example_name: Name of the example configuration :param \*\*kwargs: Additional configuration parameters to override :returns: Configured game instance .. py:function:: create_llm_config(model, **kwargs) Placeholder function until core factory is available. .. py:function:: create_simple_config(config_class, player1_model, player2_model, **kwargs) Create a simple game configuration with model strings. :param config_class: The game's configuration class :param player1_model: Model for player 1 :param player2_model: Model for player 2 :param \*\*kwargs: Additional configuration parameters :returns: Configured game instance