a16z-infra /companion-app

AI companions with memory: a lightweight stack to create and host your own AI companions

★ 5,983⑂ 947👁 60⑃ 62● 47▤ 0
TypeScriptCreated 2023-06-22ai-companion-stack.com/
5,983
stars
+0+-1+5
947
forks
60
watchers
62
prs
47
issues
0
releases
–
discussions

README

AI Companion App (based on AI Getting Started template)

Live Demo

Join our community Discord: AI Stack Devs




This is a tutorial stack to create and host AI companions that you can chat with on a browser or text via SMS. It allows you to determine the personality and backstory of your companion, and uses a vector database with similarity search to retrieve and prompt so the conversations have more depth. It also provides some conversational memory by keeping the conversation in a queue and including it in the prompt. 

It currently contains companions on both ChatGPT and Vicuna hosted on Replicate. 

There are many possible use cases for these companions - romantic (AI girlfriends / boyfriends), friendship, entertainment, coaching, etc. You can guide your companion towards your ideal use case with the backstory you write and the model you choose.

Note This project is purely intended to be a developer tutorial and starter stack for those curious on how chatbots are built. If you're interested in what a production open source platform looks like, check out Steamship. Or what the leading AI chat platforms look like, check out Character.ai.

 Overview

- 💻 Stack
- 🧠 Quickstart
- 🚀 How does this work?
- 👤 Adding/modifying characters
- 👩‍💻 How to contribute to this repo
- 🐍 Python support
- 💽 Exporting your companion to Character.ai

 Stack

The stack is based on the AI Getting Started Stack:

- Auth: Clerk
- App logic: Next.js
- VectorDB: Pinecone / Supabase pgvector
- LLM orchestration: Langchain.js
- Text model: OpenAI, Replicate (Vicuna13b)
- Text streaming: ai sdk
- Conversation history: Upstash
- Deployment: Fly
- Text with companion: Twilio

 Quickstart

The following instructions should get you up and running with a fully
functional, local deployment of four AIs to chat with. Note that the companions
running on Vicuna (Rosie and Lucky) will take more time to respond as we've not
dealt with the cold start problem. So you may have to wait around a bit :)

 1. Fork and Clone repo

Fork the repo to your Github account, then run the following command to clone the repo:


git clone [email protected]:[YOUR_GITHUB_ACCOUNT_NAME]/companion-app.git


Alternatively, you can launch the app quickly through Github Codespaces by clicking on "Code" - "Codespaces" - "+"


If you choose to use Codespaces, npm dependencies will be installed automatically and you can proceed to step 3. 

 2. Install dependencies


cd companion-app
npm install


 3. Fill out secrets


cp .env.local.example .env.local


Secrets mentioned below will need to be copied to .env.local

a. Clerk Secrets

Go to https://dashboard.clerk.com/ - "Add Application" - Fill in Application name/select how your users should sign in - Create Application
Now you should see both NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY on the screen


If you want to text your AI companion in later steps, you should also enable "phone number" under "User & Authentication" - "Email, Phone, Username" on the

Snapshot: 2026-11-04T14:00:00Z · Data license Apache-2.0 · JSON