app¶
NiceGUI front end: one page per conversation plus the /ws/audio WebSocket.
The page renders the pipeline rail (one station per Lane), the
conversation, an activity trace that marks every request that left the machine, the notes
panel and, when a tool needs permission, a confirmation dialog. Microphone and speaker audio
travel over a plain WebSocket so the binary stream stays out of NiceGUI’s own socket.
Attributes¶
Classes¶
Widgets of one browser tab and the event pump that updates them. |
|
Holds the runtime and the live sessions of this process. |
Functions¶
|
Cache-busting token that changes whenever any static asset changes. |
|
Apply a JSON control message from the browser; malformed messages are ignored. |
|
Bridge one browser's audio WebSocket and its session until it disconnects. |
|
Attach middleware, routes, static files and the page to the NiceGUI app. |
|
Run the web UI (blocks until Ctrl+C). |
Module Contents¶
- app.logger¶
- app.STATIC_DIR: pathlib.Path¶
- app.RAIL: tuple[tuple[voicemate.events.Lane, str, str], ...]¶
- app.BADGES: dict[str, str]¶
- app.MIC_SHORTCUT: str = 'Ctrl+M'¶
- app.HOLD_SHORTCUT: str = 'Ctrl+H'¶
- app.FOCUS_ICON: str = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor"...¶
- app.asset_version() str¶
Cache-busting token that changes whenever any static asset changes.
NiceGUI serves static files as immutable for a year, so edited assets need new URLs.
- app.handle_control_message(session: voicemate.pipeline.orchestrator.VoiceSession, text: str) None¶
Apply a JSON control message from the browser; malformed messages are ignored.
- async app.serve_audio(websocket: fastapi.WebSocket, session: voicemate.pipeline.orchestrator.VoiceSession) None¶
Bridge one browser’s audio WebSocket and its session until it disconnects.
- class app.ConversationPage(session: voicemate.pipeline.orchestrator.VoiceSession, config: voicemate.config.Config, on_new_conversation: collections.abc.Callable[[], object] | None = None, click_mic: collections.abc.Callable[[], object] | None = None)¶
Widgets of one browser tab and the event pump that updates them.
- Parameters:
session – The tab’s voice session.
config – Application configuration.
on_new_conversation – Starts a fresh conversation thread (the page then reloads).
click_mic – Presses the microphone button (what the global hotkey does; the button itself when omitted).
- session¶
- config¶
- on_new_conversation = None¶
- stations: dict[voicemate.events.Lane, tuple[nicegui.ui.element, nicegui.ui.label, nicegui.ui.label]]¶
- rail¶
- reply: nicegui.ui.label | None = None¶
- last_user: nicegui.ui.label | None = None¶
- mic_on = False¶
- notes_view() None¶
Open notes, todos and reminders with a checkbox to complete them.
- show_history(lines: list[voicemate.pipeline.conversation.ChatLine]) None¶
Render the earlier messages of a reopened conversation.
- async send() None¶
Submit the text box as a turn.
- async answer(text: str) None¶
Answer the pending confirmation (dialog buttons).
- async pump() None¶
Apply every session event to the page until the page goes away.
- apply(event: voicemate.events.Event) None¶
Render one event (events without a handler, such as audio, are ignored).
- class app.Server(config: voicemate.config.Config, runtime: voicemate.runtime.Runtime | None = None)¶
Holds the runtime and the live sessions of this process.
- Parameters:
config – Application configuration.
runtime – An already loaded runtime (tests); otherwise loaded at startup.
- config¶
- runtime = None¶
- sessions: dict[str, voicemate.pipeline.orchestrator.VoiceSession]¶
- threads¶
- thread_id() str¶
The current conversation; it survives page reloads and server restarts.
- new_conversation() str¶
Start a fresh conversation thread (long-term memory is kept).
- async open_session() tuple[str, voicemate.pipeline.orchestrator.VoiceSession]¶
A session for a new page, continuing the current conversation.
- async announce_reminder(note: voicemate.memory.notes.Note) None¶
Tell every open tab about a due reminder (each speaks it only when idle).
- make_reminders() voicemate.pipeline.reminders.Reminders | None¶
The reminder checker for this server (None when there is no notes database).
- start_reminders() None¶
Start the one reminder watcher of this server (a no-op when it already runs).
- press_to_talk(on: bool) None¶
The global hotkey went down or up: the newest open page starts or stops listening.
- start_hotkey() None¶
Listen for the global hold-to-talk key (off, with a log line, when that fails).
- async startup() None¶
Load every model before the first page is served.
- async shutdown() None¶
Stop the reminder watcher, close sessions and release the runtime.
- fake_mic_name(requested: str | None) str | None¶
The
?fake_mic=file to replay, if test audio is enabled and the name is safe.
- async build_page(fake_mic: str | None = None) ConversationPage | None¶
Build the conversation page for the current client (the
/route).
- app.register(server: Server) None¶
Attach middleware, routes, static files and the page to the NiceGUI app.
- app.serve(config: voicemate.config.Config, open_browser: bool = True) None¶
Run the web UI (blocks until Ctrl+C).