A GitHub Copilot Agent Skill for using Retrieval-Augmented Generation (RAG) to increase accuracy of AI responses based on information from manuals, datasheets, etc.
Uses a locally stored vector store based on hashlib to store the embeddings, and provides a cli tool for generating embeddings from PDF files using Ollama.
Install Ollama.
Install Python dependencies
pip install requests PyPDF2 pycryptodomeInstall Ollama model (default is nomic-embed-text)
ollama pull nomic-embed-textcd your-repo
git submodule add https://github.com/Gherkin/vscode-pdf-rag-skill.git .github/skills/pdf-rag-knowledge
git submodule update --init --recursiveAdd to your repo's .vscode/settings.json (or set it globally):
{
"chat.useAgentSkills": true
}cd .github/skills/pdf-rag-knowledge
python3 rag_search.py --index /path/to/your/datasheets/*.pdfcd .github/skills/pdf-rag-knowledge
# Search
./search_rag.sh "GPIO pins"
python3 rag_search.py --search "power consumption"
# Check status
python3 rag_search.py --stats
# Index PDFs
python3 rag_search.py --index /path/to/pdfs/*.pdf
# Clear database
python3 rag_search.py --clearJust ask natural questions in Copilot Chat. The skill activates automatically when you ask about:
- Hardware specifications
- Pin configurations
- Register details
- Timing diagrams
- Power requirements
- Communication protocols
- Any technical info from datasheets
- Indexing: PDFs chunked into 2000-char segments with 400-char overlap
- Embeddings: Generated via Ollama (local, free, private)
- Search: Semantic similarity using cosine distance
- Integration: Auto-loads when Copilot detects relevant questions
Optional environment variables used (the default can be changed in the python script):
export OLLAMA_BASE_URL=http://localhost:11434
export OLLAMA_MODEL=mxbai-embed-large
export CHUNK_SIZE=2000
export CHUNK_OVERLAP=400# Check status
python3 rag_search.py --stats
# Test search
./search_rag.sh "test query"
# Verify Ollama
curl http://localhost:11434/api/tagsSee SKILL.md for detailed documentation.