vocal_helper.llm module

vocal_helper.llm

Optional LLM analyst stage. Consumes Utterance events and maintains a rolling summary of the conversation up to recent_window_s (default 60 s) before now.

Algorithm

  • Keep a deque of recent utterances with timestamps.

  • After every new Utterance : - Move utterances whose t1 is older than

    now recent_window_s from the recent buffer into the summarisation queue.

    • If the summarisation queue grew by flush_every_n (default 5) new utterances, ask the LLM to fold them into the running summary field.

    • Emit a SummarySnapshot with the current (summary, recent) pair.

The LLM call runs in a worker thread (Ollama’s HTTP client blocks). If the LLM is unreachable, the stage logs a warning and emits a SummarySnapshot with the previous summary unchanged, so downstream consumers never miss an event.

Author

Warith HARCHAOUI — https://linkedin.com/in/warith-harchaoui

class vocal_helper.llm.GemmaAnalystStage(*, model='gemma3:4b', recent_window_s=60.0, flush_every_n=5, flush_every_s=60.0, host=None, prompt_template='You are a meeting note-taker. Update the running summary below by integrating the new utterances. Keep it concise (≤ 6 bullet points), preserve speaker attributions, and drop low-signal small talk. Output only the updated summary, nothing else.\n\nCurrent summary:\n{summary}\n\nNew utterances (older newer):\n{new_block}\n')[source]

Bases: object

Producer/consumer LLM analyst with a rolling summary.

Parameters:
  • model (str) – Ollama model tag. Default "gemma4:e4b" — Gemma 4 4B effective, the canonical light analyst across the AI Helpers suite. On Apple-Silicon, ollama resolves the -mlx variant automatically when present.

  • recent_window_s (float) – How many seconds of verbatim transcript to keep before folding into the summary. Default 60 s.

  • flush_every_n (int) – Update the summary every flush_every_n new utterances that crossed the recent window. Default 5.

  • host (str, optional) – Ollama host URL. Defaults to the OLLAMA_HOST env var or http://localhost:11434.

  • prompt_template (str) – Override the canonical summarisation prompt. Two placeholders : {summary} (current digest) and {new_block} (newly evicted utterances). Default keeps a ≤ 6-bullet meeting digest.

  • flush_every_s (float | None)

async run(inbox, outbox)[source]

Consume Utterance from inbox, push SummarySnapshot.

Parameters:
  • inbox (Queue)

  • outbox (Queue)

Return type:

None