Skip to content

almightymoon/ai-rag-starter

Repository files navigation

AI RAG Starter

Production-ready Retrieval-Augmented Generation (RAG) API built with FastAPI, ChromaDB, and OpenAI-compatible LLMs.

CI License: MIT

Features

  • Document ingestion — PDF, TXT, Markdown via LangChain loaders
  • Vector store — ChromaDB with persistent storage
  • Embeddings — OpenAI or any OpenAI-compatible endpoint (Ollama, vLLM)
  • RAG pipeline — Chunk → embed → retrieve → generate with citations
  • REST API/ingest, /query, /health endpoints
  • Docker — One-command local deployment

Architecture

Documents → Chunker → Embeddings → ChromaDB
                                      ↓
User Query → Embed → Retrieve top-k → LLM → Answer + Sources

Quick Start

cp .env.example .env   # add OPENAI_API_KEY
pip install -r requirements.txt
uvicorn app.main:app --reload
# Ingest documents
curl -X POST http://localhost:8000/ingest \
  -H "Content-Type: application/json" \
  -d '{"text": "Kubernetes is a container orchestration platform.", "source": "docs"}'

# Query
curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{"question": "What is Kubernetes?"}'

Docker

docker compose up --build

API

Endpoint Method Description
/health GET Health check
/ingest POST Add text to vector store
/ingest/file POST Upload and ingest a file
/query POST RAG question answering

Configuration

Variable Default Description
OPENAI_API_KEY API key for embeddings + LLM
OPENAI_BASE_URL https://api.openai.com/v1 Compatible API base URL
EMBEDDING_MODEL text-embedding-3-small Embedding model
LLM_MODEL gpt-4o-mini Chat model
CHROMA_PERSIST_DIR ./chroma_data Vector store path

License

MIT © almightymoon

About

Production RAG API — FastAPI + ChromaDB + OpenAI-compatible LLMs

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages