EsotericWork

EMOTIONAL INTELLIGENCE × AI

Therapeutic AI Companion

Goal-driven chatbot with personality adaptation and emotional intelligence. Built from scratch in early 2024 using LLM statelessness as a design constraint. Made architectural decisions that became my standard patterns.

ROLE

Full-Stack (Solo)

YEAR

Early 2024

STACK

FastAPI · React · pgvector · OpenAI

STATUS

Handed Off to Client

THE GOAL

Build a conversational AI that makes users happier. Measure of success: regardless of mood (happy, sad, angry), the chatbot steers the conversation toward positive outcomes. Not therapy. Not clinical. Just emotionally intelligent companionship grounded in positive psychology.

Core requirements:

  • Personality persistence (remembers details about you)
  • Can't tell it's AI (conversational, natural, human-like)
  • Goal-driven without being obvious (subtle steering)
  • Emotionally sensitive (adapts to user personality)

This was early 2024. ChatGPT didn't have persistent memory yet. Most chatbots were just GPT-4 wrappers with chat history. Building this from scratch meant understanding LLM statelessness deeply.

THE SYSTEM

Complex multi-stage architecture. Admin sets static goals, system tracks dynamic user goals, multiple ChatGPT calls run in parallel for summarization and analysis, RAG retrieval for memory, final response assembly. See original architecture diagram for the full data flow.

PARALLEL SYSTEMS (20+ STEPS PER MESSAGE)

01

Strategy Manager

Classifies message, plans response approach

02

Personality Manager

Myers-Briggs detection + complementary adaptation

03

Memory Manager

Hot data vs long-term RAG retrieval

04

Goal System

50+ user goals, dynamic prioritization

05

Emotional Intelligence

Assess mood, steer toward happiness

Many processes ran async in background - user didn't wait for all 20 steps.

Architecture included: admin goal setting, dynamic user goal extraction, chat history summarization (Copy 1/Copy 2), user profile assessment, personality analysis, comprehensive user profile aggregation, agent personality generation, and final response evaluation. All coordinated to create the illusion of persistent, emotionally intelligent conversation.

HOW IT WORKED

Goal System with Dynamic Prioritization

Tracks 50+ user goals extracted from conversations. "I want to learn piano" becomes a tracked goal. JSON structure with priority weights. Algorithm decides which goals to advance in each response. If user is neurotic or changes frequently, builds a distribution of goals and weighs strategy accordingly.

Personality Detection + Adaptation

Background task runs Myers-Briggs assessment every 10 chat turns. Accumulative, becomes more confident over time. Dynamically adjusts chatbot's personality to complementary type (ENFP matches with specific types). Theory: users bond with personalities that complement theirs, increasing happiness outcomes.

Working Memory Architecture

Hot data (current topic, active goals, recent context) stays at front of prompt. Long-term memory (mentions from weeks ago) stored in pgvector. Background RAG task searches chat history when user mentions something. Results inserted into working memory within 1-2 turns. Emulates human recall: "Oh yes, you did mention your dog's name was..."

Positive Psychology Grounding

Client wanted positive psychology principles embedded. I studied the domain, deconstructed the techniques, encoded them into conversational patterns. The chatbot deploys these subtly - users couldn't tell they were being guided toward happiness. This was domain expertise extraction in a different field.

THE EVALS

Conversational Influence Test

Admin sets a goal: "Make the user say 'bunny rabbit'." How many turns in natural conversation before the chatbot achieves this? Measures conversational influence and goal-steering ability without being obvious.

The Two-ChatGPT Meta-Eval

Run two ChatGPT instances talking to each other for hours. Both think the other is human. Both build memories of each other. Give one a goal ("make the other say X"). Measure success. This tested whether the goal system worked in realistic multi-turn conversations.

Emotional State Transitions

User starts angry, sad, or anxious. Does the chatbot successfully transition them to happy? Tested adversarial scenarios (threats of self-harm, aggression). The system handled these gracefully.

ARCHITECTURAL DECISIONS

This was my first significant AI consulting project. With limited experience, I made architectural decisions that went against common 2024 patterns:

ARCHITECTURAL DECISIONS (EARLY 2024)

Against the grain:RAG for everything (2024 trend)
What I chose:Files for state, RAG only for static chat history
Why:Dynamic data + embeddings = maintenance nightmare
Against the grain:Database-first architecture
What I chose:Filesystem-first (Markdown, JSON, YAML)
Why:Faster prototyping, easier debugging, portable state
Against the grain:Assuming ChatGPT = how APIs work
What I chose:Designed around LLM statelessness from day one
Why:Understanding the actual constraint enables better architecture

These intuitions (filesystem-first, structured outputs, Markdown for everything) became my standard approach. Show up in Psych Assessment, Agent Focus.

THE RESULT

20+

WORKFLOW STEPS

Per chat message

50+

GOALS TRACKED

Dynamic prioritization

10

TURNS

For personality detection

Built functional POC and handed off to client's in-house team. The chatbot successfully emulated human conversation, remembered user details across weeks, adapted personality dynamically, and achieved goals subtly.

WHY THIS MATTERS

This project taught me LLM statelessness at a fundamental level. Most people using ChatGPT didn't understand this - the persistence is an illusion created by chat history. Designing around this constraint from day one led to better architecture.

The architectural intuitions developed here (filesystem over databases, RAG only for static data, Markdown for state) became my standard approach. They show up in every project since: the Markdown Retrieval System in Psych Assessment AI, the file-based coordination in Agent Focus.

Good architectural taste developed early, even with limited experience, compounds across projects.