A chat interface allowing users to ask questions about the ChaosChain Litepaper, powered by Retrieval-Augmented Generation (RAG).
This project consists of:
- Backend: A FastAPI application using LangChain to process documents, create embeddings, store them in ChromaDB, and generate answers using an OpenAI model (like GPT-4o-mini). It provides a streaming API compatible with the Vercel AI SDK.
- Frontend: A Next.js application using the
assistant-ui
library for the chat interface, consuming the backend's streaming API.
- Clone Repository:
git clone <your-repo-url> cd litepaper-chat
- Backend Setup:
- Navigate to
backend/
. - Create a Python virtual environment:
python -m venv venv
- Activate it:
source venv/bin/activate
(Linux/macOS) or.\venv\Scripts\activate.ps1
(Windows PowerShell) - Install dependencies:
pip install -r requirements.txt
(You might need to create requirements.txt first:pip freeze > requirements.txt
)
- Navigate to
- Frontend Setup:
- Navigate to
frontend/
. - Install dependencies:
npm install
- Navigate to
- Environment Variables:
- Create a
.env
file in the project root. - Copy contents from
.env.example
and fill in yourOPENAI_API_KEY
. - Ensure
LITEPAPER_SRC_DIR
points to the correct litepaper source (e.g., the GitHub repo URL). - Update
CORS_ORIGINS
if your frontend runs on a different port during development or after deployment.
- Create a
-
Start Backend:
cd backend # Activate venv if needed python -m uvicorn app.main:app --reload --port 8000
The first time, it will clone the repo and build the vector store.
-
Start Frontend:
cd frontend npm run dev
Access the chat at http://localhost:3000 (or the port Next.js indicates).
- Frontend: Deploy the
frontend
directory as a Next.js application (e.g., on Vercel). Set theNEXT_PUBLIC_API_URL
environment variable to the deployed backend URL. - Backend: Deploy the
backend
directory as a Python application (e.g., on Render, Fly.io). Set environment variables (OPENAI_API_KEY
,CORS_ORIGINS
, etc.) on the hosting platform.
litepaper-chat/
├── backend/ # FastAPI backend
│ ├── app/ # Main application code
│ ├── scripts/ # Data ingestion scripts
│ └── tests/ # Backend tests
├── frontend/ # React frontend
│ ├── src/ # Source code
│ └── public/ # Static assets
└── data/ # Data directory
└── vector_store/ # ChromaDB vector store
- Python 3.9+
- Node.js 18+
- Git
- Backend API documentation: http://localhost:8000/docs
- Frontend development server: http://localhost:5173
MIT