Skip to main content

Production-grade AI Personality Engine — emotions, relationships, evolution, and character-driven interactions

Project description

██╗  ██╗ █████╗  ██████╗ ██╗   ██╗██╗   ██╗ █████╗
██║ ██╔╝██╔══██╗██╔════╝ ██║   ██║╚██╗ ██╔╝██╔══██╗
█████╔╝ ███████║██║  ███╗██║   ██║ ╚████╔╝ ███████║
██╔═██╗ ██╔══██║██║   ██║██║   ██║  ╚██╔╝  ██╔══██║
██║  ██╗██║  ██║╚██████╔╝╚██████╔╝   ██║   ██║  ██║
╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝  ╚═════╝    ╚═╝   ╚═╝  ╚═╝

A Production-Grade AI Personality Engine

Give your AI a soul.

Python License Docker FastAPI


What is KAGUYA?

KAGUYA is a modular Personality Operating Layer for AI systems. It gives AI agents, chatbots, VTubers, NPCs, and digital companions:

  • Persistent Identity — consistent personality across conversations
  • Emotional Intelligence — real-time mood simulation with decay
  • Relationship Memory — per-user trust, familiarity, and affinity tracking
  • Response Modification — LLM output shaped by personality + emotion + relationships
  • Personality Evolution — traits gradually change based on interactions

Architecture

┌─────────────────────────────────────────────────────┐
│                    KAGUYA Engine                     │
├─────────────┬─────────────┬─────────────┬───────────┤
│ Personality │  Emotion    │ Relationship│ Evolution │
│   Core      │  Engine     │  System     │  Engine   │
├─────────────┴─────────────┴─────────────┴───────────┤
│              Response Modifier Middleware             │
├─────────────────────────────────────────────────────┤
│         Storage Layer (SQLite / PostgreSQL)          │
├─────────────────────────────────────────────────────┤
│           REST API  │  WebSocket  │  Dashboard      │
└─────────────────────────────────────────────────────┘

Quick Start

# Install
pip install kaguya

# Or with Docker
docker-compose up -d

Basic Usage

from kaguya.personality.traits import TraitVector
from kaguya.personality.profile import CharacterProfile
from kaguya.emotion.engine import EmotionalStateEngine
from kaguya.relationships.manager import RelationshipManager
from kaguya.middleware.response_modifier import ResponseModifier

# Create a personality
profile = CharacterProfile(
    name="Sakura",
    traits=TraitVector(
        kindness=0.9,
        humor=0.6,
        empathy=0.85,
        confidence=0.4,
        curiosity=0.7,
    ),
)

# Initialize systems
emotion = EmotionalStateEngine(profile)
relationships = RelationshipManager()
modifier = ResponseModifier(profile, emotion, relationships)

# Modify an LLM prompt based on personality
enhanced_prompt = modifier.modify_prompt(
    base_prompt="You are a helpful assistant.",
    user_id="user_123"
)

Character Presets

from kaguya.personality.presets import tsundere, kuudere, chaotic_gremlin

# Use a preset personality
profile = tsundere(name="Kaguya")
profile = kuudere(name="Ice Queen")
profile = chaotic_gremlin(name="Gremlin")

REST API

# Start the server
uvicorn api.main:app --host 0.0.0.0 --port 8000

# Create personality
curl -X POST http://localhost:8000/personality \
  -H "Content-Type: application/json" \
  -d '{"name": "Kaguya", "traits": {"kindness": 0.8, "humor": 0.6}}'

# Get emotional state
curl http://localhost:8000/emotion/{personality_id}

# Chat with personality
curl -X POST http://localhost:8000/chat \
  -d '{"personality_id": "xxx", "user_id": "user_1", "message": "Hello!"}'

Features

Feature Description
🎭 Personality Traits 10+ traits with float precision (0.0-1.0)
💜 Emotion Engine Valence-Arousal model with decay and transitions
💕 Relationships Per-user trust, familiarity, affinity, respect
🧠 Memory Bias Personality-influenced memory retrieval
📈 Evolution Gradual trait changes from interactions
🔧 Response Modifier LLM prompt enhancement based on state
🎨 Character Presets tsundere, kuudere, chaotic_gremlin, and more
🖥️ Dashboard Futuristic dark-mode visualization
🐳 Docker One-command deployment
🔌 REST API Full CRUD + WebSocket streaming

Dashboard

Access at http://localhost:8000/dashboard after starting the server.

Features:

  • Personality radar chart
  • Real-time emotion gauge
  • Relationship map
  • Mood timeline
  • Trait evolution graph

Project Structure

kaguya/
├── src/kaguya/
│   ├── personality/    # Trait system, profiles, presets
│   ├── emotion/        # Emotional state engine
│   ├── relationships/  # Per-user relationship tracking
│   ├── evolution/      # Personality evolution over time
│   ├── middleware/      # Response modification
│   └── storage/        # Database layer
├── api/                # FastAPI REST API + WebSocket
├── dashboard/          # Web dashboard
├── examples/           # Usage examples
├── tests/              # Test suite
└── docs/               # Documentation

Tech Stack

  • Python 3.10+
  • FastAPI — REST API + WebSocket
  • SQLAlchemy — async ORM
  • SQLite / PostgreSQL — storage
  • Docker — deployment

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License — see LICENSE for details.


Built with ❤️ for the AI character community

KAGUYA — Because AI deserves a personality.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kaguya-0.1.0.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kaguya-0.1.0-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file kaguya-0.1.0.tar.gz.

File metadata

  • Download URL: kaguya-0.1.0.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for kaguya-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6133ff6e7ab58f7b568d6a924a30d18e474d31058ff8d1715d5b6d5be9030cff
MD5 9fd55e4eefc82e02bef8ec0ece476c21
BLAKE2b-256 19c8992a3104cb444dbccf4585d57f288dcda59b45e6973e252a09a6b77cadc7

See more details on using hashes here.

File details

Details for the file kaguya-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kaguya-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for kaguya-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cbaf8107736b52dc2c57102b20f7f0fc65f67438e640c10946387e896c4565d
MD5 939ce34eaf82a7157a278892141eae5f
BLAKE2b-256 f3ee09d14a5ffe0be476de4f4b331801150bd537dd07f35a8c5d908cbb9df666

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page