The assistant
Every chart on the site is paired with a short note written by a language model conditioned on the underlying numbers. On the live local version, a chat panel lets you ask follow-up questions in real time. This page documents how it works and lets you replay recorded conversations for each pathology.
What it does
The assistant takes a structured scenario (the parameters used to generate a chart) plus a free-form question and returns a short, restrained answer grounded in the numbers. It is not a general chatbot. The system prompt forbids em-dashes, exclamation marks, emojis, hype words ("powerful", "actually", "essentially"), and chain-of-thought preamble ("Let me analyse..."), and asks for 80 to 130 words.
How it is wired
- Provider. Opencode Zen, an OpenAI-compatible gateway that fronts several open-weights and proprietary models behind a single key.
- Model. Configurable. Default for this build:
minimax-m2.5-free. Paid alternatives includeqwen3.6-plusandkimi-k2.6. - SDK. The Python
openaipackage, pointed athttps://opencode.ai/zen/v1via thebase_urlparameter. - Output contract. Strict JSON for the analyst notes (parsed with a tolerant extractor that handles code fences). Free text for the chat answers.
- Caching. Notes and recorded Q&A are generated once at build time and committed to the repository. The public site never makes an LLM call.
Why the public site is read-only
Any API key shipped to a browser is a public key. Embedding the
OPENCODE_API_KEY in client JavaScript would let any visitor
spend the budget. The two usable workarounds (a serverless proxy or a
per-visitor key) both add deployment surface that does not fit a static
portfolio site.
Instead, the public site shows the assistant in its most honest form: recorded conversations that demonstrate exactly what the live version produces. The repository ships a Streamlit version with the chat panel wired to a live model. The local version is the full demo.
Run the full demo locally
- Clone the repo.
cp .env.example .envand add your Opencode Zen key.uv syncuv run streamlit run app/streamlit_app.py
Recorded conversations
One demo per pathology. Click a question to replay the response. All answers were generated by the language model at build time with the same prompt the live chat panel uses.