Python RAG assistant for TED talks using an OpenAI-compatible API (LLMOD) + Pinecone. API ready; no front-end yet. Vercel serverless deployment included.
- Python 3.13+
- Access to LLMOD/OpenAI-compatible API key and Pinecone credentials
- Create a virtual environment (if not already present):
- Windows PowerShell:
python -m venv .venv
- Windows PowerShell:
- Activate the environment:
- Windows PowerShell:
.\.venv\Scripts\Activate
- Windows PowerShell:
- Install runtime deps:
.\.venv\Scripts\python -m pip install --upgrade pip && .\.venv\Scripts\python -m pip install -r requirements.txt(For notebooks/ingest tools, also install dev extras:.\.venv\Scripts\python -m pip install -r requirements.dev.txt) - Copy
.env.exampleto.envand fillLLMOD_API_KEY(orOPENAI_API_KEY),PINECONE_API_KEY, and Pinecone index settings. - Register the Jupyter kernel (optional):
.\.venv\Scripts\python -m ipykernel install --user --name ted-rag --display-name "Python (ted-rag)" - (Optional) Launch Jupyter:
jupyter laborjupyter notebook
See .env.example for defaults:
LLMOD_API_KEY(orOPENAI_API_KEY)LLMOD_BASE_URL(defaulthttps://api.llmod.ai/v1)PINECONE_API_KEYPINECONE_INDEX/PINECONE_INDEX_NAME(defaultted-talks-index)PINECONE_CLOUD/PINECONE_REGIONDATASET_PATH(defaultdata/ted_talks_en.csv)EMBEDDING_MODEL(defaultRPRTHPB-text-embedding-3-small)CHAT_MODEL(defaultRPRTHPB-gpt-5-mini)CHUNK_SIZE(<= 2048),OVERLAP_RATIO(<= 0.3),TOP_K(<= 30)
src/settings.py— config and defaultssrc/text_splitter.py— token-aware chunkingsrc/ingest.py— load CSV, chunk, embed, and upsert to Pineconesrc/server.py— FastAPI app with/api/promptand/api/stats.env.example— environment templatedata/— placeted_talks_en.csvhererequirements.txt— Python dependencies.gitignore— ignores venv, caches, editor files
.\.venv\Scripts\python -m src.ingest --dataset data\ted_talks_en.csv --limit 200
Use --limit for cheap dry-runs; remove it to index all talks once satisfied.
.\.venv\Scripts\python -m uvicorn src.server:app --reload --port 8000
Endpoints:
POST /api/prompt— ask a question; returns model response, retrieved context, and augmented prompt.GET /api/stats— returnschunk_size,overlap_ratio, andtop_kcurrently configured.
./.venv/Scripts/python main.py "Your question here" --top-k 8 --index-name ted-talks-index
Options: --top-k to override retrieval depth, --index-name to point at a specific Pinecone index, --region to override Pinecone region.
- Add env vars in Vercel Dashboard:
LLMOD_API_KEY(orOPENAI_API_KEY),LLMOD_BASE_URL(if different),PINECONE_API_KEY,PINECONE_INDEX_NAME(orPINECONE_INDEX),PINECONE_REGION(orPINECONE_ENVIRONMENT), plus optionalEMBEDDING_MODEL,CHAT_MODEL,CHUNK_SIZE,OVERLAP_RATIO,TOP_K. - Ensure your Pinecone index dimension matches the embedding model (1536 for
RPRTHPB-text-embedding-3-small). - The repo includes
vercel.jsonandapi/index.py(FastAPI + Mangum handler). Deploy withvercelCLI from the project root. - After deploy, call
POST https://<your-deployment>/api/promptwith{ "question": "..." }to query.
- Pinecone index dim must match embedding model (1536 for
text-embedding-3-smallfamily). - Keep the index alive until grading is complete.
- Vercel deployment: package this FastAPI app as a serverless function (or wrap via an ASGI adapter) and expose the same endpoints.