Inspiration
Most of us have a friend in medical school, and they all say the same thing: the part they feel least prepared for isn't the pharmacology or the anatomy, it's sitting across from a real patient and figuring out what's actually wrong. Taking a good history is a skill, and like any skill you get better at it by doing it badly a few times first. The problem is that you can't really practise on real patients, and actors for simulated consultations are expensive and only available a handful of times per semester.
So we asked a simple question: what if a student could have a patient to talk to whenever they wanted? One who doesn't just hand over the diagnosis, who sometimes rambles, who only mentions the important detail if you ask the right follow-up. And what if their teacher could see where the whole class keeps getting stuck?
That became Fahlawyia, a virtual interview patient for history-taking practice.
What it does
Fahlawyia has two sides, one for doctors (teachers) and one for students.
For doctors
- Create a fictional patient case in seconds: describe a disease and the app generates a patient with a name, personality, background and a set of medical facts they "know". The diagnosis stays hidden from students.
- Publish cases to the class, preview them yourself, and archive old ones.
- A Class Insights page shows the average score per case, diagnosis accuracy, which history topics students miss most often (with a suggested question to teach), common wrong diagnoses, and how scores change with difficulty. It even writes a few plain-language findings, like "Most consultations with this patient missed what triggers the symptoms. It may be worth teaching explicitly."
For students
- Pick a patient and a difficulty: Easy (answers directly), Medium (a bit vague), or Hard (never names the symptom outright, you have to dig).
- Talk to the patient by typing or by speaking out loud. The patient answers with a voice, and optionally as a talking video avatar.
- When you're done, submit your diagnosis and get a debrief: a score, what you did well (quoting your own words back to you), what to focus on next time, ready-made questions you could have asked, and a checklist of the history topics you covered or missed. Every point links back to the exact moment in the transcript.
How we built it
- Backend: Python with FastAPI and SQLite. Each case is a structured file of facts the patient is allowed to reveal.
- Frontend: Next.js and React, with the browser's Web Audio API for recording and streaming audio.
- The patient's brain: OpenAI models. The most important design decision was that the model never invents medical facts. Each student question is first routed to the relevant facts, then the model drafts a reply in character, and a separate "fact-check" call verifies that the reply only uses facts from the case. If a draft fails the check, we retry, and if that fails too we fall back to the last verified answer instead of letting the patient make something up.
- Voice: OpenAI's Realtime API for speech-to-text (with live partial transcripts while you're still talking) and text-to-speech, streamed over a WebSocket so the patient starts speaking before the whole sentence is generated.
- Avatars and video: patient portraits are generated with FLUX through Hugging Face, and talking-head replies come from Pruna, with FFmpeg trimming the clips.
- Feedback: a checklist-based score (diagnosis, history coverage, facts uncovered, questioning technique) plus a stronger model that writes the personal coaching. The final score is a weighted sum:
$$ \text{score} = \sum_{k \in {\text{diagnosis},\ \text{coverage},\ \text{facts},\ \text{technique}}} \text{points}_k \quad\text{out of } 100 $$
Challenges we ran into
- Making the patient feel like a patient. Early on, when a student asked "How are you?", the patient cheerfully replied "I'm fine, how can I help you?", as if they were the doctor. We had to teach it its role explicitly, and treat a wellbeing question as an invitation to describe the complaint.
- Hallucinations vs. strictness. Our fact-check was so strict at one point that the patient couldn't even say "Hello" back, because a greeting isn't a medical fact. Finding the balance between "never invent symptoms" and "be a normal human" took several iterations.
- Not repeating itself. Ask the same thing twice and a language model tends to give the exact same sentence. We added variation, and made the patient a little clearer each time you come back to a topic, the way a real person would.
- Latency. A conversation feels dead if you wait seven seconds for an answer. We got the time from finishing a question to hearing the first word of the reply down from about 6.5 s to roughly 3 s, by streaming audio, keeping a speech channel open per consultation, and closing connections in the background. One bug alone (waiting on a connection handshake) was costing us 2 seconds on every spoken question.
- A tight budget. We had about \$30 of API credits for the whole hackathon, so we tested with fake patients and scripted conversations wherever we could and only used the real models when it mattered.
- Merging work from different laptops late at night, without breaking each other's features.
Accomplishments that we're proud of
- A patient that stays grounded in its case. It won't invent a symptom the case doesn't have, yet it still sounds like a person.
- The difficulty levels genuinely change the conversation. On Hard you have to work for every detail.
- Talking to the patient out loud feels close to a real conversation, with live captions while you speak.
- Feedback that is specific to you: it quotes what you said and tells you exactly which question to try next time.
- Giving teachers something they rarely get: a clear picture of where the whole class struggles.
- More than a hundred automated tests, so we could move fast without breaking things.
What we learned
- With language models, the hard part isn't getting an answer, it's getting the right kind of answer reliably. Splitting the work into small, checkable steps (route → draft → verify) worked far better than one big clever prompt.
- Perceived speed matters more than raw speed. Showing a live transcript and starting the audio early made the app feel twice as fast even when the total time barely changed.
- Good feedback is short, concrete and kind. A wall of scores helps nobody; "here's one thing you did well, here's one thing to try" actually gets read.
- Building for two very different users (a nervous student and a busy teacher) forces you to think about what each of them actually needs to see first.
What's next for Fahlawyia
- Feedback backed by the literature: linking each tip to established guidance on patient communication, so students can see why a technique matters.
- Harder and more realistic patients: emotional patients, patients who are worried or defensive, and patients who bring their own wrong ideas about what they have.
- More languages, starting with German, since many students practise for consultations in a second language.
- Physical exam and test results, so a case can continue after the history.
- Accounts and classes, so each teacher sees only their own students, plus progress tracking over a whole semester.
- Testing it with real medical students and teachers, and letting their feedback decide what we build next.