from __future__ import annotations import os DEFAULT_MODEL_POLICY = { "planning": "sol", "project_brain": "sol", "archaeology_interpretation": "sol", "agent_design": "sol", "escalation": "sol", "coding": "qwen", "review": "qwen", "reasoning": "qwen", "venture_ideation": "sol", "venture_research": "luna", "venture_portfolio_ic": "terra", "story_planning": "terra", "story_prose": "terra", "story_continuity": "luna", "story_review": "terra", "story_revision": "luna", } ENV_BY_ROLE = { "planning": "ARTIFEX_PLANNING_MODEL", "project_brain": "ARTIFEX_PROJECT_BRAIN_MODEL", "archaeology_interpretation": "ARTIFEX_ARCHAEOLOGY_MODEL", "agent_design": "ARTIFEX_AGENT_DESIGN_MODEL", "escalation": "ARTIFEX_ESCALATION_MODEL", "coding": "ARTIFEX_CODING_MODEL", "review": "ARTIFEX_REVIEW_MODEL", "reasoning": "ARTIFEX_REASONING_MODEL", "venture_ideation": "ARTIFEX_VENTURE_IDEATION_MODEL", "venture_research": "ARTIFEX_VENTURE_RESEARCH_MODEL", "venture_portfolio_ic": "ARTIFEX_VENTURE_PORTFOLIO_IC_MODEL", "story_planning": "ARTIFEX_STORY_PLANNING_MODEL", "story_prose": "ARTIFEX_STORY_PROSE_MODEL", "story_continuity": "ARTIFEX_STORY_CONTINUITY_MODEL", "story_review": "ARTIFEX_STORY_REVIEW_MODEL", "story_revision": "ARTIFEX_STORY_REVISION_MODEL", } PURPOSE_TO_ROLE = { "PROJECT_BRAIN": "project_brain", "PLANNING": "planning", "ARCHAEOLOGY_INTERPRETATION": "archaeology_interpretation", "AGENT_DESIGN": "agent_design", "ESCALATION": "escalation", "CODING": "coding", "REVIEW": "review", "REASONING": "reasoning", "STORY_PLANNING": "story_planning", "STORY_PROSE": "story_prose", "STORY_CONTINUITY": "story_continuity", "STORY_REVIEW": "story_review", "STORY_REVISION": "story_revision", } def model_for_role(role: str) -> str: normalized = role.lower() env_name = ENV_BY_ROLE.get(normalized) if env_name: configured = os.environ.get(env_name) if configured: return configured.strip().lower() return DEFAULT_MODEL_POLICY.get(normalized, DEFAULT_MODEL_POLICY["reasoning"]) def model_for_purpose(purpose: str) -> str: role = PURPOSE_TO_ROLE.get(str(purpose).upper(), "reasoning") return model_for_role(role)