"""Run the CORTEX AI API server. python -m cortex_ai.api.serve Uses the mock adapter by default so the server starts on any machine. Set CORTEX_ADAPTER=hf to load the real checkpoint instead. """ from __future__ import annotations import os from .server import create_app from ..adapters.mock import MockAdapter from ..config import CortexConfig def build_adapter(config: CortexConfig): kind = os.getenv("CORTEX_ADAPTER", "mock").lower() if kind == "hf": from ..adapters.hf_adapter import HFAdapter return HFAdapter(config.model_id).load() return MockAdapter() def main() -> None: import uvicorn config = CortexConfig.from_env() app = create_app(build_adapter(config), config) uvicorn.run(app, host=config.server.host, port=config.server.port) if __name__ == "__main__": main()