- pages/2_Демо-консоль.py: persona selector, virtual clock bar (+1 h, to 08:00/20:00, next day, reset with confirm), fallback patient web chat (buttons from Reply.buttons, kind styling, outbox drained after every action and on a 2 s fragment poll), scenario panel - pages/3_Сплит-экран.py: patient chat or PATIENT_WEB_URL iframe on the left, compact doctor panel (patients, live alerts, red banner on a new acute alert) on the right - console/playback.py: data/synthetic/<persona>.jsonl runner (advance_to/press/text/ expect_color/start), date chaining between days, pause on failure with retry/skip/manual - console/api.py: own HTTP client over the frozen API contract, ApiError only Refs #17 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
"""Demo console (#17, ADR-004/005): web chat of the patient, demo clock and scenario playback.
|
|
|
|
Everything goes through the HTTP API (`API_BASE_URL`); the page keeps working when the backend serves fixtures.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import streamlit as st
|
|
|
|
# `streamlit run dashboard/app.py` already puts dashboard/ on sys.path; this keeps the page runnable on its own.
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from console import widgets as w # noqa: E402
|
|
from console.playback_ui import render_playback_panel # noqa: E402
|
|
|
|
st.set_page_config(page_title="Демо-консоль", page_icon="🎬", layout="wide")
|
|
|
|
persona = w.select_persona()
|
|
w.show_flash()
|
|
st.sidebar.caption(f"API: {w.get_api().base_url}")
|
|
|
|
st.title("Демо-консоль")
|
|
st.caption("Прототип на синтетических данных. Время — виртуальные демо-часы (ADR-005).")
|
|
w.render_clock_bar(persona, key="console-clock")
|
|
st.divider()
|
|
|
|
chat_col, play_col = st.columns([1.05, 1], gap="large")
|
|
with chat_col:
|
|
st.subheader(f"💬 Чат пациента — {persona.get('display_name') or persona['token']}")
|
|
w.render_chat(persona["token"], height=560, key="console-chat")
|
|
with play_col:
|
|
render_playback_panel(persona)
|