Skip to content

HenryLoM/DigitalWife

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’ DigitalWife

❗️ Also known as Nicole or Object-10

Repo size Commits Last commit Latest release License

πŸ“‘ Table of Contents


✨ Overview

DigitalWife is a browser-based virtual companion built around:

  • Local LLM (via Ollama API).
  • Chat system with memory and logs.
  • A layered sprite system (character, clothes, expressions, places).
  • Popup-driven customization for character appearance and technical settings.
  • Arduino working robotic parts (in process)

🎬 Launching Process

  1. Download Ollama
brew install ollama                               # macOS
# curl -fsSL https://ollama.com/install.sh | sh   # Debian-based Linux
# https://ollama.com/download/windows             # Windows (installer link)
  1. Run Ollama
ollama serve
  1. Download an LLM
ollama pull <model name>
  1. Clone repository, install requirements, run app
git clone https://github.com/HenryLoM/DigitalWife.git
cd ./DigitalWife/
pip install -r backend/requirements.txt
python3 launch.py
  1. Inside the app
  • Enter chat page
  • Click Settings
  • Enter your model name
  • Click Save, then start using πŸš€

πŸ’‘ Prefer using your browser?

Instead of doing python3 launch.py from step 4, do this:


πŸ“‚ Project Structure

DigitalWife/
β”‚
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ .gitignore
β”œβ”€β”€ favicon.ico
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ homepage.html               # Landing page
β”‚   β”‚   β”œβ”€β”€ chat.html                   # Main chat interface
β”‚   β”‚   └── log.html                    # Logs / update notes
|   |
β”‚   β”œβ”€β”€ styles/                         # Styling
β”‚   β”‚   β”œβ”€β”€ chat.css
β”‚   β”‚   β”œβ”€β”€ homepage.css
β”‚   β”‚   └── log.css
β”‚   β”‚
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ *tag-variables.js           # Style variables (tags, HTML & CSS-related)
β”‚   β”‚   β”œβ”€β”€ *theme-switcher.js          # Light/dark mode toggler
β”‚   β”‚   β”œβ”€β”€ arduino-switcher.js         # UI toggle for Arduino ON/OFF
β”‚   β”‚   β”œβ”€β”€ chat.js                     # Core AI chat logic
β”‚   β”‚   β”œβ”€β”€ customization-popup.js      # Appearance customization popup
β”‚   β”‚   β”œβ”€β”€ emotion-ai.js               # Emotion detector
β”‚   β”‚   β”œβ”€β”€ vader-sentiment.js          # Sentiment analyzer
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ controllers/                # Scripts for page working
β”‚   β”‚   β”‚   β”œβ”€β”€ chat.js
β”‚   β”‚   β”‚   β”œβ”€β”€ homepage.js
β”‚   β”‚   β”‚   └── log.js
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ files/                      # Static AI memory & persona
β”‚   β”‚   β”‚   β”œβ”€β”€ avatar.txt              # User data
β”‚   β”‚   β”‚   β”œβ”€β”€ instructions.txt        # System prompt / lore
β”‚   β”‚   β”‚   β”œβ”€β”€ recollection.txt        # AI memory
β”‚   β”‚   β”‚   └── touching-phrases.txt    # Prewritten emotional phrases
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ modules/                    # Logic split into focused modules
β”‚   β”‚   β”‚   β”œβ”€β”€ emotion-ai-handler.js
β”‚   β”‚   β”‚   β”œβ”€β”€ interaction-handler.js
β”‚   β”‚   β”‚   β”œβ”€β”€ theme-handler.js
β”‚   β”‚   β”‚   └── ui-helper.js
β”‚   β”‚   β”‚
β”‚   β”‚   │── utils/                      # Generic helpers
β”‚   β”‚   β”‚   β”œβ”€β”€ frame-utils.js
β”‚   β”‚   β”‚   β”œβ”€β”€ memory-utils.js
β”‚   β”‚   β”‚   β”œβ”€β”€ popup-utils.js
β”‚   β”‚   β”‚   └── settings-utils.js
β”‚   β”‚   β”‚
β”‚   β”‚   │── api/                        # Modules to work with backend
β”‚   β”‚   β”‚   └── backend-api.js
β”‚   β”‚   β”‚
β”‚   β”‚   └── files/                      # Static AI memory & persona
β”‚   β”‚       β”œβ”€β”€ avatar.txt              # User data
β”‚   β”‚       β”œβ”€β”€ instructions.txt        # System prompt / lore
β”‚   β”‚       β”œβ”€β”€ recollection.txt        # AI memory
β”‚   β”‚       └── touching-phrases.txt    # Prewritten emotional phrases
β”‚   β”‚
β”‚   └── media/
β”‚       β”œβ”€β”€ screenshots/...             # Demo screenshots
β”‚       β”œβ”€β”€ places/...                  # Backgrounds (street, park, etc.)
β”‚       β”œβ”€β”€ frame/...                   # Decorative chat frame
β”‚       β”œβ”€β”€ mini-frame/...              # Smaller frame
β”‚       └── nicole/                     # Character sprites
β”‚           β”œβ”€β”€ bodies/...              # Skin tones
β”‚           β”œβ”€β”€ clothes/...             # Clothes & uniforms
β”‚           β”œβ”€β”€ expressions/...         # Neutral, happy, angry, sad, etc.
β”‚           └── additional/...          # Accessories (headphones, blush, etc.)
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ db.json
β”‚   β”œβ”€β”€ db_utils.py
β”‚   └── main.py
β”‚
β”œβ”€β”€ arduino/
β”‚   β”œβ”€β”€ arduino-controller.js           # Signal transfer for Arduino
β”‚   └── response-parser.js              # Parser for turning responses to commands

πŸ–₯️ HTML Pages

chat.html

  • Main interface:
    • Left: Chat window (messages).
    • Right: Wife sprite (layered images).
  • Controls:
    • Send message.
    • Save / Load / Restart chat.
    • Edit instructions, avatar, and memo.
    • Customize appearance (popup).
    • Technical settings (model, port, overlays).

homepage.html

  • Introduction and navigation.

log.html

  • Notes on updates.

βš™οΈ Core Scripts

chat.js

Handles all AI interactions and memory.

  • πŸ”Œ Ollama integration (chatWithOllama)

    • Connects to local Ollama instance.
    • Streams responses with abort support.
  • πŸ’¬ Chat workflow (handleAiResponse)

    • Builds message payload (instructions, avatar, memory, context).
    • Appends user + AI messages to localStorage and memory.
  • 🧠 Memory management

    • Add / update / delete / rewind / refresh messages.
    • Save & load chat logs (.txt).
    • Trim memory to avoid overload.
  • πŸ› οΈ Popup editing

    • Edit instructions, avatar, recollection.
    • Character counter (700 limit).
  • ⚑ Tech Details Editor (Settings)

    • Edit AI name, model, port.
    • Export/import JSON setups (appearance, overlays, settings).
  • πŸŽ›οΈ Appearance state

    • Save/restore sprite layers (body, hair, clothes, background).
    • Auto-update appearanceContext for AI input.
  • ✏️ Message controls

    • Refresh ↻, Delete β™», Edit ✎, Copy ⧉ per message.

emotion-ai.js

Handles emotion inference based on chat text. This script directly affects which expression sprite is displayed and whether the blush overlay is active.

  • ✍️ Uses a rewritten local version of VADER sentiment analysis (vader-sentiment.js).
  • πŸ… Detects blush state if certain keywords appear (e.g. β€œblush”, β€œawkward”, β€œembarrassed”, etc).
  • ↩️ Returns both:
    • Emotion label (happy, smile, annoyed, angry, sad, neutral).
    • Blush flag (true/false).
  • πŸ“Š Sentiment thresholds:
    • β‰₯ 0.8 β†’ happy 2
    • β‰₯ 0.6 β†’ happy 1
    • β‰₯ 0.5 β†’ smile 2
    • β‰₯ 0.3 β†’ smile 1
    • β‰₯ 0.1 β†’ neutral
    • β‰₯ -0.2 β†’ annoyed
    • β‰₯ -0.4 β†’ angry
    • β‰₯ -0.6 β†’ sad

customization-popup.js

Manages character customization popup.

  • πŸ‘‡ Opens with Customize button.

  • πŸ“‘ Two-page navigation:

    • Page 0: Clothes, Places, Additional.
    • Page 1: Skin Tones, Hairstyles.
  • 🎨 Assets defined in lists:

    • bodiesList β†’ skin tones.
    • hairList β†’ multiple styles (lob, long, bob, hime, twin).
    • clothesList β†’ casual, uniforms, swimwear, intimate.
    • placesList β†’ home, city, misc.
    • additionalList β†’ flowers, ribbons, headphones, blush.
  • βš™οΈ Each selection:

    • Updates corresponding localStorage overlay (clothes-overlay, background, etc.).
    • Updates selected* globals + appearanceContext.
    • Saves to localStorage and database.
  • 🫷 Includes close button and smooth transitions.


🎨 Assets

  • Nicole: Body + hair + clothes + expression layers.
  • Backgrounds: Living room, park, cafe, cinema, etc.
  • UI Frames: Retro decorative frame images.

πŸ’Ύ Memory System

  • Chat stored in array of { index, role, content }.
  • Index ensures sync between localStorage and memory.
  • Supports:
    • Save to .txt.
    • Load from .txt.
    • Export/import full setup (.json).
  • Trimmed to avoid overload (trimLimit).
  • AI gets the whole context each message, so every change affects the chatting.

πŸ› οΈ Settings & Customization

  • Instructions editor – edit AI personality/system prompt.
  • Avatar editor – edit user description.
  • Memo editor – edit AI recollection memory.
  • Tech Editor – manage AI name, Ollama model, port, overlays.
  • Appearance popup – select clothes, hair, place, accessories.

πŸ“œ Notes

  • Requires Ollama running locally (default port is 11434).
  • Default model: "NicoleShelterV1".
  • Uses localStorage to persist appearance, avatar, and AI memory across sessions.
  • Chat controls include refresh, edit, delete, copy for fine-grained conversation control.

πŸ“Έ Screenshots

screen of chat page Chat explanation

screen of settings menu Settings explanation


‴︎ Return to the πŸ“‘ Table of Contents ‴︎