PyCatan-AI / pycatan /ai /__init__.py
shon
1
525124a
"""
AI Agent Infrastructure for PyCatan
This package contains the infrastructure for building LLM-based AI agents
that can play Settlers of Catan autonomously.
Main Components:
- AIManager: Central coordinator for all AI agents
- AIUser: User interface wrapper for AI agents
- AILogger: Logging and session management
- AgentState: Per-agent state tracking
Supporting Components:
- config: Configuration management for AI agents
- prompt_manager: Prompt construction and game state filtering
- state_filter: Game state filtering and perspective transformation
- prompt_templates: Prompt structure and action templates
- response_parser: LLM response parsing and validation
- llm_client: LLM API abstraction and client
- schemas: JSON schemas for LLM responses
- agent_tools: Helper tools for LLM decision-making (NEW!)
Architecture Overview:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ AI System Architecture β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β”‚
β”‚ GameManager AIManager β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ get_input() β”‚ Creates prompts β”‚
β”‚ β–Ό β”‚ Sends to LLM β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Parses responses β”‚
β”‚ β”‚ AIUser │◄──────── delegates to ──────►│ β”‚
β”‚ β”‚(Wrapper)β”‚ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β–Ό β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ AILogger β”‚ β”‚
β”‚ β”‚ (Logging) β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ Components: β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Config β”‚ β”‚ Prompt β”‚ β”‚ Response β”‚ β”‚
β”‚ β”‚ Management β”‚ β”‚ Manager β”‚ β”‚ Parser β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ βœ… βœ… βœ… β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Agent State β”‚ β”‚ LLM Client β”‚ β”‚ Schemas β”‚ β”‚
β”‚ β”‚ Tracking β”‚ β”‚ (Gemini) β”‚ β”‚ (JSON) β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ βœ… βœ… βœ… β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Status: βœ… Complete | 🚧 In Development | ❌ Not Started
"""
__version__ = "2.0.0"
# Main classes
from pycatan.ai.ai_manager import AIManager
from pycatan.ai.ai_user import AIUser
from pycatan.ai.ai_logger import AILogger
from pycatan.ai.agent_state import AgentState, compute_state_hash
# Supporting classes
from pycatan.ai.config import AIConfig
from pycatan.ai.prompt_manager import PromptManager
from pycatan.ai.response_parser import ResponseParser
from pycatan.ai.llm_client import LLMResponse, LLMClient, GeminiClient, OpenRouterClient, create_llm_client
from pycatan.ai.schemas import ResponseType, ACTIVE_TURN_RESPONSE_SCHEMA, OBSERVING_RESPONSE_SCHEMA
from pycatan.ai.state_optimizer import optimize_state_for_ai, format_with_legend, game_state_to_dict
# Agent tools
from pycatan.ai.agent_tools import AgentTools
__all__ = [
# Main classes
"AIManager",
"AIUser",
"AILogger",
"AgentState",
"compute_state_hash",
# Configuration
"AIConfig",
# Prompt handling
"PromptManager",
"ResponseParser",
# LLM
"LLMResponse",
"LLMClient",
"GeminiClient",
"OpenRouterClient",
"create_llm_client",
# Schemas
"ResponseType",
"ACTIVE_TURN_RESPONSE_SCHEMA",
"OBSERVING_RESPONSE_SCHEMA",
# State optimization
"optimize_state_for_ai",
"format_with_legend",
"game_state_to_dict",
# Agent tools
"AgentTools",
]