41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""
|
|
@scenario BaseScenario (swarm/scenarios/base_scenario.py)
|
|
@purpose Abstract interface for all swarm simulation scenarios.
|
|
"""
|
|
from abc import ABC, abstractmethod
|
|
from typing import Dict, Any, Callable, List, Optional
|
|
from pydantic import BaseModel, Field
|
|
from swarm.core.calibration import HistoricalBaseline, SimulationDispersion, CalibratedProjection
|
|
|
|
|
|
class ScenarioResult(BaseModel):
|
|
scenario_type: str
|
|
scenario_title: str
|
|
baseline: HistoricalBaseline
|
|
dispersion: SimulationDispersion
|
|
projection: CalibratedProjection
|
|
summary_metrics: Dict[str, Any]
|
|
archetype_breakdown: List[Dict[str, Any]]
|
|
interview_samples: List[Dict[str, str]]
|
|
agent_logs: List[Dict[str, Any]]
|
|
report_markdown: str
|
|
execution_time_ms: int
|
|
prompt_tokens: int
|
|
completion_tokens: int
|
|
total_cost_usd: float
|
|
|
|
|
|
class BaseScenario(ABC):
|
|
@abstractmethod
|
|
async def run(
|
|
self,
|
|
input_params: Dict[str, Any],
|
|
store_id: int = 1,
|
|
cancellation_check: Optional[Callable[[], bool]] = None,
|
|
heartbeat_callback: Optional[Callable[[], None]] = None
|
|
) -> ScenarioResult:
|
|
"""
|
|
Executes the scenario simulation with active cancellation checking
|
|
and heartbeat signaling between rounds.
|
|
"""
|
|
pass
|