AI Companion — a persona bot with a stable face and memory
A companion bot with a LoRA-locked visual persona, persistent dialogue memory and on-demand generation of in-character images.
Context
A believable AI character needs two things generic chatbots lack: a face that stays the same from image to image, and a memory that keeps the conversation coherent across sessions. Without the first, every generated picture shows a different-looking stranger; without the second, the character forgets who it is talking to.
AI Companion was built to hold both constants — identity and memory — fixed, while the conversation itself stays free-form.
Approach
The visual identity problem is solved at the model layer, not the prompt layer. A Flux LoRA is fine-tuned on the character, so consistency is a property of the weights rather than of prompt engineering — the persona survives changes of pose, scene and outfit that would break a prompt-only approach.
Dialogue is handled by an LLM behind a persona system prompt, and every exchange is persisted to Supabase keyed by user. The character therefore carries context between sessions: it can reference earlier conversations instead of starting cold each time.
Architecture
The bot runs on aiogram 3 against the Telegram Bot API. Incoming messages are routed either to the dialogue path — context loaded from Supabase, LLM response generated in character, context written back — or to the generation path, where a request for an image is turned into a LoRA-conditioned Flux job and the result is returned into the chat.
Both paths share the same persona definition, so what the character says and how it looks come from one source of truth rather than two systems drifting apart.
Key engineering details
The hard constraint is identity drift. Prompt-described characters mutate; a trained LoRA does not, which is why the identity lives in a fine-tuned model rather than in a paragraph of description. Generation requests are still prompt-shaped — scene, mood, action — but the face is non-negotiable.
Memory is deliberately structured as per-user conversation state in Postgres (Supabase) rather than in-process context, so the bot restarts cleanly, scales horizontally and can later support retention policies and paid tiers without rearchitecting.
Outcome & what shipped
The shipped prototype covers the full loop: a Telegram bot with a persistent, LoRA-locked persona that converses in character and produces on-persona images on demand.
It serves as the reference architecture for anywhere a consistent character outperforms a generic assistant: brand mascots that answer customers, virtual consultants with a face, and themed subscription bots where the persona is the product. Planned extensions are subscription and credit tiers, a wider emotional range for the persona, and white-label packaging.
What we built
Persona lock
A fine-tuned Flux LoRA keeps the character's face consistent across every generated image.
Dialogue memory
Per-user conversation context persisted in Supabase so the persona stays coherent across sessions.
In-character generation
On-request image generation conditioned on the LoRA — scene and mood vary, identity does not.
Telegram delivery
Runs as an aiogram 3 bot on the Telegram Bot API, backed by Supabase.