whatisgithub

What is ai-companion-runtime?

yf0522/ai-companion-runtime — explained in plain English

Analysis updated 2026-05-18

22PythonAudience · developerComplexity · 4/5Setup · hard

In one sentence

A backend system for an AI chat companion that detects your emotions, checks for safety risks, and recalls memories in parallel while streaming replies over WebSocket.

Mindmap

mindmap
  root((repo))
    What it does
      Emotion-aware AI chat
      Parallel analysis engines
      Real-time WebSocket replies
    Tech stack
      Python FastAPI
      Next.js
      Redis PostgreSQL pgvector
    Memory layers
      Recent messages in Redis
      Vector memories in pgvector
      Long-term archive storage
    AI models
      Qwen DeepSeek OpenAI-compatible
      Primary fallback fast model
    Setup
      Docker Compose

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build an emotionally aware AI chat assistant with real-time streaming replies.

USE CASE 2

Add layered short-term and long-term memory to an AI companion using Redis and pgvector.

USE CASE 3

Configure fallback AI models so replies never stall.

What is it built with?

PythonFastAPINext.jsRedisPostgreSQLpgvectorDocker

How does it compare?

yf0522/ai-companion-runtimeagno-agi/agent-platform-railwayalexantaluo0/acot-vla-wm
Stars222222
LanguagePythonPythonPython
Setup difficultyhardmoderatehard
Complexity4/54/55/5
Audiencedeveloperdeveloperresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires Docker Compose to run the backend, frontend, Redis, and PostgreSQL with pgvector together.

So what is it?

AI Companion Runtime is a backend system for building an AI chat assistant that tracks your emotional state during conversation and adjusts its responses accordingly. The core idea is that the assistant does not just read what you type and respond: it also runs separate analysis steps in parallel to detect what emotion you seem to be expressing, assess whether the message contains anything that might require a safety intervention, and recall relevant memories from past conversations before generating a reply. The system uses WebSocket connections so messages stream back to the user in real time. When you send a message, several engines run at the same time: one tries to understand the intent, one classifies the emotion (choosing from states like joy, sadness, anger, fear, fatigue, anxiety, or neutral), one checks a risk rulebook, and one searches a memory store for relevant past context. Depending on the results, the assistant might soften its tone, give shorter replies, provide crisis-line information, or proceed normally. The personality and emotional adaptation rules are defined in YAML configuration files that can be edited without restarting the service. Memory is stored in five layers with different speeds and lifespans. The most recent 20 messages stay in Redis for instant access. A session summary and a user profile are also cached in Redis. Older important memories are stored as vector embeddings in PostgreSQL using a tool called pgvector, which allows searching by meaning rather than exact keywords. Long-term archives go to object storage. The project supports several AI model providers, including Qwen, DeepSeek, OpenAI-compatible services, and locally running models. You configure a primary model, a fallback, and a fast model in a YAML file. If the primary model takes too long to start generating a reply, the fast model kicks in automatically so the user is not left waiting. For observability, every conversation request gets a trace ID that tracks each processing step, the time taken, token usage, and cost. A timeline view in the frontend shows this information visually. The frontend is built with Next.js, and the backend uses Python with FastAPI. The recommended way to run the whole stack is via Docker Compose, which starts the backend, frontend, databases, Redis, and monitoring tools in one command.

Copy-paste prompts

Prompt 1
Help me run AI Companion Runtime locally with Docker Compose.
Prompt 2
Explain how the five-layer memory system works in this project.
Prompt 3
Show me how to configure a primary, fallback, and fast AI model in YAML.
Prompt 4
Walk me through the emotion classification and risk rulebook engines.

Frequently asked questions

What is ai-companion-runtime?

A backend system for an AI chat companion that detects your emotions, checks for safety risks, and recalls memories in parallel while streaming replies over WebSocket.

What language is ai-companion-runtime written in?

Mainly Python. The stack also includes Python, FastAPI, Next.js.

How hard is ai-companion-runtime to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is ai-companion-runtime for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.