Ask questions about a codebase in plain English. The assistant finds the most relevant code with semantic search, then has a local LLM answer using that code as context.
data/*.py ──► chunk (500 chars) ──► embed (all-MiniLM-L6-v2) ──► FAISS index
│
question ──► embed ──► top-k nearest chunks ──► llama3.2 (Ollama) ──► answer + sources
- Ingest:
ingest.pysplits every.pyfile indata/into chunks, embeds them and savesindex.faiss+chunks.pkl. - Retrieve:
search.pyembeds your question and pulls the closest chunks from the index. - Answer: the chunks and your question go to a local
llama3.2model, which answers from the code (or says it doesn't know).
Everything runs locally. No API keys needed.
Prerequisites: Python 3.10+ and Ollama installed.
# 1. Install dependencies
pip install streamlit faiss-cpu sentence-transformers requests
# 2. Pull the model and start Ollama
ollama pull llama3.2
ollama serve
# 3. Build the index from the files in data/
python ingest.py
# 4. Launch the app
streamlit run app.pyTo query your own code, drop .py files into data/ and re-run python ingest.py.
- 💬 Chat interface with conversation history
- 🎚️ Adjustable number of retrieved sources (1–10)
- 📚 Retrieved code shown under each answer with filename, match distance and syntax highlighting
- ⚡ One-click example questions to get started
- 🖥️ CLI mode:
python search.py
| File | Purpose |
|---|---|
app.py |
Streamlit chat UI |
search.py |
Semantic search + LLM call (also runnable as a CLI) |
ingest.py |
Chunks, embeds and indexes files in data/ |
encode_example.py |
Small demo of embedding similarity |
data/ |
Sample codebase to query |