feat: add project config and test scaffolding
This commit is contained in:
+2
-1
@@ -3,7 +3,8 @@ __pycache__/
|
|||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
venv/
|
venv/
|
||||||
|
.venv/
|
||||||
.env
|
.env
|
||||||
assets/
|
assets/
|
||||||
samples/
|
samples/*.wav
|
||||||
.backup/
|
.backup/
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
fastapi>=0.115.0
|
||||||
|
uvicorn[standard]>=0.34.0
|
||||||
|
torch>=2.2.0
|
||||||
|
diffusers>=0.30.0
|
||||||
|
transformers>=4.40.0
|
||||||
|
accelerate>=0.30.0
|
||||||
|
TTS>=0.22.0
|
||||||
|
Pillow>=10.0.0
|
||||||
|
numpy>=1.26.0
|
||||||
|
pydantic>=2.0.0
|
||||||
|
pytest>=8.0.0
|
||||||
|
pytest-asyncio>=0.23.0
|
||||||
|
httpx>=0.27.0
|
||||||
|
websockets>=12.0
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
"""Application configuration with Pydantic models."""
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
|
class EscalationConfig(BaseModel):
|
||||||
|
"""Escalation engine parameters."""
|
||||||
|
rate: float = 0.05
|
||||||
|
initial_batch_size: int = 40
|
||||||
|
max_images: int = 200
|
||||||
|
max_audio_clips: int = 50
|
||||||
|
asset_swap_min: float = 0.5 # seconds (at high intensity)
|
||||||
|
asset_swap_max: float = 15.0 # seconds (at low intensity)
|
||||||
|
voice_mean_interval: float = 60.0 # Poisson mean at intensity 0
|
||||||
|
silence_gap_min: float = 2.0
|
||||||
|
silence_gap_max: float = 30.0
|
||||||
|
fake_calm_chance: float = 0.08 # probability per phase update
|
||||||
|
fake_calm_duration_min: float = 10.0
|
||||||
|
fake_calm_duration_max: float = 30.0
|
||||||
|
cluster_burst_chance: float = 0.1
|
||||||
|
cluster_burst_count_min: int = 2
|
||||||
|
cluster_burst_count_max: int = 5
|
||||||
|
|
||||||
|
|
||||||
|
class ModelConfig(BaseModel):
|
||||||
|
"""AI model identifiers and generation parameters."""
|
||||||
|
sdxl_model_id: str = "stabilityai/sdxl-turbo"
|
||||||
|
sdxl_steps: int = 4
|
||||||
|
sdxl_guidance_scale: float = 0.0
|
||||||
|
sdxl_width: int = 512
|
||||||
|
sdxl_height: int = 512
|
||||||
|
xtts_model: str = "tts_models/multilingual/multi-dataset/xtts_v2"
|
||||||
|
xtts_language: str = "en"
|
||||||
|
|
||||||
|
|
||||||
|
class AppConfig(BaseModel):
|
||||||
|
"""Top-level application config."""
|
||||||
|
host: str = "0.0.0.0"
|
||||||
|
port: int = 8400
|
||||||
|
device: str = "cuda"
|
||||||
|
assets_dir: str = "assets"
|
||||||
|
samples_dir: str = "samples"
|
||||||
|
escalation: EscalationConfig = Field(default_factory=EscalationConfig)
|
||||||
|
models: ModelConfig = Field(default_factory=ModelConfig)
|
||||||
|
|
||||||
|
|
||||||
|
config = AppConfig()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Shared test fixtures."""
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
from server.config import config, EscalationConfig, ModelConfig, AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_defaults():
|
||||||
|
"""Config loads with sane defaults."""
|
||||||
|
assert config.port == 8400
|
||||||
|
assert config.host == "0.0.0.0"
|
||||||
|
assert config.device == "cuda"
|
||||||
|
|
||||||
|
|
||||||
|
def test_escalation_defaults():
|
||||||
|
"""Escalation config has correct default rate and timing."""
|
||||||
|
assert config.escalation.rate == 0.05
|
||||||
|
assert config.escalation.initial_batch_size == 40
|
||||||
|
assert config.escalation.max_images == 200
|
||||||
|
assert config.escalation.max_audio_clips == 50
|
||||||
|
|
||||||
|
|
||||||
|
def test_model_defaults():
|
||||||
|
"""Model config points to correct model IDs."""
|
||||||
|
assert "sdxl-turbo" in config.models.sdxl_model_id
|
||||||
|
assert "xtts" in config.models.xtts_model
|
||||||
|
|
||||||
|
|
||||||
|
def test_timing_defaults():
|
||||||
|
"""Timing ranges are ordered correctly."""
|
||||||
|
assert config.escalation.asset_swap_min < config.escalation.asset_swap_max
|
||||||
|
assert config.escalation.voice_mean_interval > 0
|
||||||
Reference in New Issue
Block a user