Skip to content

RetainDB/retaindb-langchain-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retaindb-langchain-starter

LangChain + LangGraph chatbot with persistent memory powered by RetainDB.

Memories survive server restarts and new sessions. The LangGraph agent retrieves relevant context before each reply and stores every turn for future recall.

Stack

  • LangChain + LangGraph — agent orchestration
  • OpenAI gpt-4o-mini — chat completions
  • RetainDB — persistent memory (direct REST calls)
  • FastAPI — HTTP interface

Quickstart

# 1. Clone
git clone https://github.com/Alinxus/retaindb-langchain-starter
cd retaindb-langchain-starter

# 2. Install
pip install -r requirements.txt

# 3. Configure
cp .env.example .env
# Edit .env with your keys

# 4. Run
uvicorn main:app --reload

API

POST /chat

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{"user_id": "alice", "message": "I am building a SaaS in Python"}'
{ "reply": "That's exciting! What kind of SaaS are you building?" }

After a server restart:

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{"user_id": "alice", "message": "What do you know about me?"}'
{ "reply": "You're building a SaaS in Python!" }

How it works

POST /chat
  │
  ├─► LangGraph agent node
  │     ├─► POST /v1/context/query  ──► RetainDB retrieves relevant memories
  │     ├─► ChatOpenAI gpt-4o-mini (memories in system prompt)
  │     └─► POST /v1/learn  ──► Stores the turn for future sessions
  │
  └─► Returns reply

Project structure

retaindb-langchain-starter/
├── agent.py        # LangGraph graph + RetainDB memory functions
├── main.py         # FastAPI app
├── requirements.txt
├── .env.example
└── README.md

Environment variables

Variable Description
RETAINDB_API_KEY Get free at retaindb.com
OPENAI_API_KEY Get at platform.openai.com

Related starters

About

LangChain + LangGraph + RetainDB persistent memory starter for Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages