haive.games.chess.generic_engines ================================= .. py:module:: haive.games.chess.generic_engines .. autoapi-nested-parse:: Generic chess engines using the new generic player agent system. This module demonstrates how to use the generic player agent system for chess, providing a clean, type-safe implementation that eliminates hardcoded LLM configurations. Classes ------- .. autoapisummary:: haive.games.chess.generic_engines.ChessPromptGenerator Functions --------- .. autoapisummary:: haive.games.chess.generic_engines.create_generic_chess_config_from_example haive.games.chess.generic_engines.create_generic_chess_engines haive.games.chess.generic_engines.create_generic_chess_engines_simple haive.games.chess.generic_engines.create_role_specific_chess_engines haive.games.chess.generic_engines.create_typed_chess_engines haive.games.chess.generic_engines.demonstrate_generic_pattern Module Contents --------------- .. py:class:: ChessPromptGenerator(players) Bases: :py:obj:`haive.games.core.agent.generic_player_agent.GenericPromptGenerator`\ [\ :py:obj:`str`\ , :py:obj:`str`\ ] Chess-specific prompt generator using the generic system. Init . :param players: [TODO: Add description] .. py:method:: create_analysis_prompt(player) Create a chess analysis prompt for the specified player. :param player: Player color ("white" or "black") :returns: Prompt template for position analysis :rtype: ChatPromptTemplate .. py:method:: create_move_prompt(player) Create a chess move prompt for the specified player. :param player: Player color ("white" or "black") :returns: Prompt template for move generation :rtype: ChatPromptTemplate .. py:method:: get_analysis_output_model() Get the structured output model for chess analysis. .. py:method:: get_move_output_model() Get the structured output model for chess moves. .. py:function:: create_generic_chess_config_from_example(example_name, temperature = 0.7) Create chess engines from predefined examples using generics. :param example_name: Name of the example configuration :param temperature: Temperature for all engines :returns: Dictionary of engines :rtype: dict[str, AugLLMConfig] Available examples: - "anthropic_vs_openai": Claude vs GPT-4 - "gpt4_only": GPT-4 for all roles - "claude_only": Claude for all roles - "mixed_providers": Different provider per role - "budget_friendly": Cost-effective models .. py:function:: create_generic_chess_engines(player_configs) Create chess engines using the generic system. :param player_configs: Dictionary of role name to player configuration :returns: Dictionary of configured engines :rtype: dict[str, AugLLMConfig] .. rubric:: Example >>> configs = { ... "white_player": PlayerAgentConfig(llm_config="gpt-4"), ... "black_player": PlayerAgentConfig(llm_config="claude-3-opus"), ... "white_analyzer": PlayerAgentConfig(llm_config="gpt-4"), ... "black_analyzer": PlayerAgentConfig(llm_config="claude-3-opus"), ... } >>> engines = create_generic_chess_engines(configs) .. py:function:: create_generic_chess_engines_simple(white_model = 'gpt-4o', black_model = 'claude-3-5-sonnet-20240620', temperature = 0.7, **kwargs) Create chess engines with simple model configurations using generics. :param white_model: Model for white player and analyzer :param black_model: Model for black player and analyzer :param temperature: Temperature for player engines :param \*\*kwargs: Additional configuration parameters :returns: Dictionary of engines :rtype: dict[str, AugLLMConfig] .. rubric:: Example >>> engines = create_generic_chess_engines_simple("gpt-4", "claude-3-opus") >>> engines = create_generic_chess_engines_simple( ... "anthropic:claude-3-5-sonnet-20240620", ... "openai:gpt-4o", ... temperature=0.8 ... ) .. py:function:: create_role_specific_chess_engines() Create chess engines with different models per role using generics. This example shows how to use different LLM models for players vs analyzers, demonstrating the flexibility of the generic system. :returns: Dictionary of engines :rtype: dict[str, AugLLMConfig] .. py:function:: create_typed_chess_engines() Demonstrate type-safe engine creation using the generic system. This function shows how the generic system provides compile-time type checking for player identifiers and role names. :returns: Dictionary of engines :rtype: dict[str, AugLLMConfig] .. py:function:: demonstrate_generic_pattern() Demonstrate how the generic pattern works across different games. This function shows how the same generic system can be used for any two-player game with just different player identifiers and prompts.