Inspiration
Medical students learn history-taking and breaking bad news by practising on simulated patients played by trained actors. Actors are paid by the hour and hard to book, so each student gets only a few slots. Students go in nervous because every session counts. Nobody can practise at 11 p.m., or a tenth time, or without someone watching. Avelios asked for a patient students could actually talk to. We wanted one that behaves like a real patient: it doesn't hand over the whole story, and you have to ask the right questions to get it.
What it does
A.V.E. (Artificial Virtual Examinee) is a virtual patient for practising history-taking by voice. The student picks a patient and speaks to a face that talks back in real time. Typed chat is there as a fallback.
- Selective disclosure. Each fact in the case has a vague answer and a full answer. Ask "what brings you in?" and you get "just a bit tired." The full answer only comes when you ask directly and specifically.
- Lay language and fixed facts. The patient says "my chest feels tight," never "angina." Every case has a list of words the patient never uses. The patient never invents a symptom, contradicts the case or guesses its own diagnosis.
- Personality shown, never stated. Each case has its own persona, and difficulty levels (easy, medium, hard) change how much the patient volunteers or holds back.
- A face for each case. When a teacher publishes a case, the backend creates its own D-ID avatar, so a new patient gets a new face and voice.
- Feedback coach. When the student ends the session, they get a report: which facts they uncovered (quoting the patient's own words), which they missed (the topic and a question they could have asked, never the answer), and scores for communication such as open questions and empathy. Past sessions are saved, so students can come back and compare.
- Case creator for teachers. A teacher uploads a real clinical record (PDF or text). A pipeline turns it into a practice case with a persona. The teacher reviews it as Markdown, sets the difficulty and publishes it.
- Latency on screen. Every turn shows the OpenAI time and the end-to-end reply time.
How we built it
- Frontend: Next.js 16 (App Router), React 19 and TypeScript, with pages for the patient list, the interview, past sessions and the teacher area. Speech-to-text runs in the browser through the Web Speech API, behind a swappable interface.
- Patient engine: a Flask REST API. Each turn the browser sends the conversation history. The backend gives OpenAI the case sheet and a strict patient prompt. The case sheet never includes the diagnosis or test results, so the model can't leak what it was never told.
- Avatar and voice: a D-ID real-time agent over WebRTC. We use it only to speak and animate our own replies (
speak(), neverchat()), so the patient's knowledge stays in our repo and can be versioned and tested. - Record to case: text extraction and anonymization run locally with Presidio and spaCy. Only anonymized text ever reaches OpenAI, which then extracts the structured case and writes the persona. The type system enforces this: the OpenAI client only accepts an
AnonymizedTexttype, which can be created in only a few places. - Feedback: the model only classifies (was this fact covered? was that question open?). The scores are computed in code, so the same transcript always gets the same score.
- Cost control: every OpenAI call goes through one wrapper with a budget guard, caching, retries, a usage log and a mock mode. Our API key had a spending cap, so we couldn't afford runaway loops.
Challenges we ran into
- Latency. Speech recognition, the LLM, the avatar's speech and video streaming each add delay, and a long pause breaks the feeling of talking to a person. We put per-turn timing on screen early so we could see where the time went.
- Selective disclosure without stonewalling. The patient has to stay vague on broad questions but open up on specific ones. Tune it one way and the patient blurts everything out; tune it the other and it refuses to cooperate.
- Where the patient's brain lives. Our first version ran the persona inside D-ID Studio. That meant the case facts weren't in our code and couldn't be tested. We moved the patient's brain into our own backend and kept D-ID only for the face and voice.
- Keeping hidden data hidden. Student-facing endpoints must never return facts, diagnoses or test results. The feedback report needed careful rules about what it can show after the interview.
- Speech-to-text quirks, such as transcripts arriving twice, and testing voice in a noisy hackathon hall.
Accomplishments that we're proud of
- A patient that feels like a person. It plays things down, cracks jokes or worries, and makes you work for the story.
- A full loop in one weekend: a real clinical record goes in, gets anonymized, becomes a reviewed case with its own avatar, then a student interviews the patient and gets a feedback report.
- Privacy by design: patient records are anonymized locally before any external API sees them.
- Feedback scores computed in code, so they are reproducible, not left to a model's mood.
What we learned
- How real the patient feels depends far more on the prompt and the case structure than on the avatar. A good case sheet with vague and full answers for every fact does most of the work.
- Measure latency from the first prototype on. You can't improve what you can't see.
- Use the LLM to classify and do the arithmetic in code. It is cheaper, more consistent and easier to defend.
- Cut scope early. Login, polished UI and many specialties were out from day one.
What's next for A.V.E.
- A disclosure and consistency test set: scripted student questions that report pass or fail for each fact, proving the patient behaves correctly beyond one lucky demo.
- Natural turn-taking: letting the student interrupt the patient mid-sentence instead of using push-to-talk.
- Emotion in the voice and face that follows the patient's mood.
- Breaking-bad-news scenarios at the hardest difficulty level.
- Piloting with a medical faculty, with cases reviewed by clinicians.
Built With
- claude
- d-id
- git
- gpt
- next.js
- node.js
- openai
- presidio
- pydantic
- pymupdf
- python
- react
- restapi
- spacy
- typescript