"""Frontend handler — bridges the Streamlit UI with the FastAPI backend.""" import requests BASE_URL = "http://localhost:8000" def fix_newlines(text: str, model_name: str | None = None) -> dict: payload = {"text": text} if model_name: payload["model_name"] = model_name resp = requests.post(f"{BASE_URL}/fix-newlines", json=payload) resp.raise_for_status() return resp.json() def fix_newlines_all_models(text: str) -> dict: resp = requests.post(f"{BASE_URL}/fix-newlines-all-models", json={"text": text}) resp.raise_for_status() return resp.json() def health() -> dict: resp = requests.get(f"{BASE_URL}/health") resp.raise_for_status() return resp.json()