Files
ai-torture-chamber/chamber_local.py
T

32 lines
1010 B
Python

"""Portable chamber launcher: original relay app at /chamber, static site at /.
One process, one port — clone anywhere, `./chamber up`, get the full lab.
The upstream live/server.py stays unmodified; this only mounts it.
"""
import os
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(ROOT / "live"))
import server # noqa: E402 (loads the model at import — env vars go before this)
from fastapi import FastAPI # noqa: E402
from fastapi.staticfiles import StaticFiles # noqa: E402
SITE = ROOT / "site"
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
app.mount("/chamber", server.app)
if SITE.exists():
app.mount("/", StaticFiles(directory=str(SITE), html=True), name="site")
else:
app.mount("/", server.app) # no site dir: relay everywhere
if __name__ == "__main__":
import uvicorn
port = int(os.environ.get("CHAMBER_PORT", "8000"))
uvicorn.run(app, host=os.environ.get("CHAMBER_HOST", "127.0.0.1"), port=port)