raymuz's picture
NLL V7.2 unified: 42-rule engine + Gradio 6 professional UI
eee3b29 verified
Raw History Blame Contribute Delete
1.25 kB
"""NLL V7.2 production: FastAPI + Flask API + professional Gradio 6 UI."""
from pathlib import Path
import gradio as gr
from fastapi import FastAPI
from starlette.middleware.wsgi import WSGIMiddleware
from runtime import engine as nll
# Cell 9 was authored for the notebook's shared globals. Construct it in the
# SAME namespace as the original engine so callbacks receive real functions.
_ui_file = Path(__file__).resolve().parent / "runtime" / "cell9_v7_2.py"
exec(compile(_ui_file.read_text(encoding="utf-8"), str(_ui_file), "exec"), nll.__dict__)
assert len(nll.RULES) == 42
assert nll.Engine.one.__name__ == "_one_with_must_paraphrase_v3"
assert nll.MUST_PARAPHRASE_RUNTIME.get("rule_count") == 42
assert isinstance(nll.NLL_APP, gr.Blocks)
from api.flask_api import flask_app
app = FastAPI(title="NLL Universal Professional Editor V7.2")
@app.get("/health")
def health():
return {
"status": "ok",
"release": "7.2",
"rules": len(nll.RULES),
"must_paraphrase": nll.Engine.one.__name__ == "_one_with_must_paraphrase_v3",
}
app.mount("/api", WSGIMiddleware(flask_app))
# Gradio 6 CSS must be passed to mount_gradio_app, not Blocks().
app = gr.mount_gradio_app(app, nll.NLL_APP, path="/", css=nll.CELL9_CSS)