Portfolio Project
What Would (S)he Say
A Generative AI chatbot with multiple “personas” including Homer Simpson, Barbie, and Jesus Christ. I built the “personas” by generating vector stores in Python with LangChain and OpenAI, now hosted in Supabase pgvector after a measured migration off Weaviate.
Aug 2025
Overview
What Would (S)he Say is a live generative AI chatbot that answers any question in the voice of a selected persona (Homer Simpson, Barbie, Jesus). Rather than relying on prompt instructions alone to imitate a voice, each persona is grounded in its own vector store built from primary source material: episode dialogue, screenplays, scripture. I generated the vector stores in Python with LangChain and OpenAI, originally stored them in a hosted Weaviate cluster, wired the backend through Supabase, and vibe coded the React front end and edge functions in Lovable. It has since been consolidated onto Supabase pgvector and Vercel, eliminating two paid services without changing anything a user sees. It's deployed and running.
Problem
Getting a language model to convincingly hold a specific voice is harder than it looks. Prompt instructions alone produce a thin imitation — the model approximates a character from whatever it absorbed in training, and the result drifts toward generic within a few turns. The interesting question is whether grounding responses in the character's actual recorded language produces meaningfully better fidelity than describing that character to the model. This project was built to test that, and to see how far a modern AI-assisted stack could carry a working product end to end.
Approach
The build-time work happens in Python. For each persona, I assembled a source corpus — the full dialogue archive of The Simpsons, the Barbie screenplay, the American King James Version of the Bible — then chunked it into Document objects and batch uploaded them to generate that persona's vector store. Source selection is the load-bearing decision here: a corpus of a character's actual recorded speech is what the retrieval layer has to work with, and no amount of prompt engineering downstream compensates for a thin one.
At runtime, selecting a persona from the dropdown instantiates a retriever against the matching vector store. When a user submits a question, the application queries that retriever by similarity match to assemble context, composes a RAG chain from the user's question, the retrieved context, and a persona-specific prompt, invokes it against OpenAI, and streams the response back to the chat window. Front end and edge functions were built in Lovable on Vite, TypeScript, React, shadcn-ui, and Tailwind, with Supabase handling backend connectivity.
Consolidating the Stack
The original architecture spread across three vendors, and the hosted vector database was the expensive one. Rather than cancel it and hope the replacement worked, I ran the migration as a measured exercise: understand what was actually stored, determine the minimum needed to preserve behavior, prove equivalence, then cut over behind a flag.
The audit was the valuable part. The cluster held 190,290 vectors, but the application could only ever retrieve about a third of them — the runtime query filters to a single character per persona, so every other speaker's dialogue in the Simpsons archive was paying rent and never being read. Deduplication trimmed the reachable set further. The audit also surfaced a quieter problem: several contiguous blocks of rows had failed silently during the original batch uploads, including the chapters covering Jesus's trial, which was exactly the kind of gap the Jesus persona would be asked about. The migration re-embedded and restored those 137 missing rows.
The final load was 56,478 vectors into Supabase pgvector, stored as 3,072-dimension halfvec with HNSW indexes — small enough to sit comfortably on an inexpensive compute tier. I kept the original text-embedding-3-large embeddings rather than regenerating at lower dimensions, since the footprint no longer justified the retrieval risk.
Equivalence was tested with a fixed 120-query harness comparing the new retrieval path against an exact-search baseline, tuned until two of three personas matched closely. Homer never did, and the reason turned out to be interesting rather than alarming: 25,000 short, thematically redundant lines mean several different lines are near-equally good matches for any given question, so exact and approximate search legitimately disagree on which one surfaces. A blind pairwise comparison of generated answers settled it — responses generated from identical context disagreed almost as often as responses generated from different context, meaning the retrieval difference was indistinguishable from the model's own sampling variance. The ID-overlap metric was measuring the wrong thing for that corpus.
The cutover itself ran behind an environment flag with both backends live, so rollback was a single variable change. The front end moved from Lovable's hosting to Vercel in a parallel pass. The user-facing contract never changed: same request shape, same response shape, same prompts, same model.
Outcome
The application is live and working. Persona responses read distinctly (e.g. Homer's answers sound structurally different from Barbie's or Jesus's) not just tonally relabeled, which is the qualitative result the retrieval approach was meant to produce. Building it end to end also demonstrated how compressed the path from concept to deployed product has become: the entire front end and edge layer was prompted into existence in Lovable, leaving my actual engineering effort concentrated where it mattered, on corpus selection and the retrieval pipeline.
The consolidation produced a second, less glamorous result: the same application now runs on roughly 30% of the stored vectors, one fewer vendor, and a materially lower monthly bill, with retrieval quality that survived deliberate attempts to prove it had degraded. Most of that saving came from auditing what the system actually used rather than from any clever optimization — the unreachable 70% had been accumulating cost since the day it was uploaded.
The honest limits still track to source data. Persona quality is bounded by corpus depth and cleanliness, a full multi-season dialogue archive gives the retriever far more to match against than a single screenplay, and that asymmetry shows. The migration produced a real retrieval-level evaluation harness, which the project previously lacked, but that harness measures whether two backends agree — not whether either one is faithfully Homer. Persona fidelity is still assessed by inspection rather than measured, and a proper evaluation framework remains the first thing I'd add. It's a demonstration of what grounded persona retrieval can do, not a production system with guardrails around it.
View the Code Repository on GitHub
