This repository contains a minimal FastAPI app with a simple Retrieval-Augmented Generation (RAG) flow.
What I added
main.py- main FastAPI app.generate_ai_responsenow implements a local RAG flow using OpenAI embeddings + ChatCompletion whenOPENAI_API_KEYis present.knowledge/- folder to store.txtdocuments used as the knowledge base (one sample file is provided)..rag_index.json(created at runtime) caches document embeddings.requirements.txtlists the python dependencies.
Quickstart (macOS / zsh)
- Create a virtualenv and install deps:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt- Create a
.envfile (or copy.env.example) and setOPENAI_API_KEYplus ERPNext vars:
cp .env.example .env
# edit .env and set OPENAI_API_KEY and ERPNext values
-
Add knowledge files (plain
.txt) into theknowledge/folder. A sample is included. -
Run the app:
uvicorn main:app --reloadNotes
- If
OPENAI_API_KEYisn't set oropenaiisn't installed,generate_ai_responsefalls back to a simulated response. - For production, use a proper vector DB (Qdrant/Pinecone) and secure secrets management instead of
.env.