feat(ui): explicit chat state machine — typing indicator, streaming progress, timeout and error recovery
This commit is contained in:
@@ -18,7 +18,10 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
from typing import Any
|
||||
@@ -79,6 +82,20 @@ def compose_answer(body: dict[str, Any]) -> str:
|
||||
)
|
||||
|
||||
|
||||
@app.post("/__shutdown__")
|
||||
def shutdown() -> dict[str, Any]:
|
||||
"""Test hook (loading-feedback story): terminate this mock process to
|
||||
simulate an LLM outage. The E2E fixture restores a fresh instance on
|
||||
the same port afterwards, so the rest of the session keeps working."""
|
||||
|
||||
def _die() -> None:
|
||||
time.sleep(0.1) # let the HTTP response flush before we exit
|
||||
os.kill(os.getpid(), signal.SIGTERM)
|
||||
|
||||
threading.Thread(target=_die, daemon=True).start()
|
||||
return {"status": "shutting down"}
|
||||
|
||||
|
||||
@app.get("/v1/models")
|
||||
def models() -> dict[str, Any]:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user