games.api.setup¶
Game API setup utilities.
This module provides utilities for setting up game APIs using the standardized GameAPI system from haive-dataflow.
Classes¶
Configuration for game API setup. |
Functions¶
|
Create a Chess game API. |
|
Create a Connect4 game API. |
|
Create a game API with the standardized system. |
|
Create a Tic-Tac-Toe game API. |
Module Contents¶
- class games.api.setup.GameAPIConfig(/, **data)¶
Bases:
pydantic.BaseModel
Configuration for game API setup.
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.
- Parameters:
data (Any)
- games.api.setup.create_chess_api(app, config_overrides=None, **kwargs)¶
Create a Chess game API.
- Parameters:
- Returns:
Configured GameAPI for chess
- Return type:
haive.dataflow.api.game_api.GameAPI
Examples
>>> app = FastAPI() >>> chess_api = create_chess_api( ... app, ... config_overrides={ ... "white_model": "gpt-4", ... "black_model": "claude-3-opus", ... "enable_analysis": True ... } ... )
- games.api.setup.create_connect4_api(app, config_overrides=None, **kwargs)¶
Create a Connect4 game API.
- Parameters:
- Returns:
Configured GameAPI for Connect4
- Return type:
haive.dataflow.api.game_api.GameAPI
Examples
>>> app = FastAPI() >>> connect4_api = create_connect4_api( ... app, ... config_overrides={ ... "red_model": "gpt-3.5-turbo", ... "yellow_model": "gpt-3.5-turbo", ... "temperature": 0.5 ... } ... )
- games.api.setup.create_game_api(app, agent_class, api_config=None, **kwargs)¶
Create a game API with the standardized system.
- Parameters:
app (fastapi.FastAPI) – FastAPI application instance
agent_class (type[haive.core.engine.agent.agent.Agent]) – The game agent class
api_config (GameAPIConfig | None) – API configuration
**kwargs – Additional arguments passed to GameAPI
- Returns:
Configured GameAPI instance
- Return type:
haive.dataflow.api.game_api.GameAPI
- games.api.setup.create_tic_tac_toe_api(app, config_overrides=None, **kwargs)¶
Create a Tic-Tac-Toe game API.
- Parameters:
- Returns:
Configured GameAPI for Tic-Tac-Toe
- Return type:
haive.dataflow.api.game_api.GameAPI
Examples
>>> app = FastAPI() >>> ttt_api = create_tic_tac_toe_api( ... app, ... config_overrides={ ... "x_model": "claude-3-haiku", ... "o_model": "claude-3-haiku", ... "example_config": "budget" ... } ... )