RAG & Retrieval
The@deepagents/retrieval package provides a local-first RAG (Retrieval-Augmented Generation) system that ingests content from various sources, creates vector embeddings, and provides intelligent semantic search.
Overview
Build AI applications that can intelligently search and retrieve information from:- GitHub repositories and releases
- RSS feeds and blog posts
- Local files and PDFs
- Linear issues
- Any custom data source
Key Features
Connector Pattern Ingest from multiple sources using a unified interface. Each connector handles content fetching, processing, and metadata extraction. Local Embeddings Use FastEmbed for local embedding generation with models like BGE-Small-EN-V15. No external API calls required. SQLite Vector Storage Store embeddings in SQLite using sqlite-vec for efficient vector similarity search with cosine distance. Semantic Search Find relevant content using natural language queries. The system automatically handles embedding, chunking, and similarity ranking. Content Change Detection Automatic detection of content changes using SHA-256 hashing. Only re-processes documents when they’ve actually changed.Quick Start
Architecture
Core Concepts
Connectors Connectors implement theConnector interface and provide:
- A unique
sourceIdfor tracking content - An async generator that yields documents with
id,content, andmetadata - Optional ingestion strategies (
never,contentChanged,expired)
- Fetches content from the connector
- Splits content into chunks using text splitters
- Generates embeddings for each chunk
- Stores embeddings with metadata in SQLite
- Embedding the query text
- Computing cosine similarity with stored embeddings
- Ranking results by similarity score
- Returning the top N matches
Use Cases
Documentation Search Ingest technical documentation and enable natural language search across your knowledge base. Code Intelligence Index your codebase and search for relevant code examples, patterns, or implementations. Content Monitoring Track RSS feeds, release notes, or blog posts and query for specific topics or updates. Issue Analysis Ingest Linear issues or GitHub issues and search for related bugs, features, or discussions.Next Steps
Installation
Install and set up the retrieval package
Ingestion
Learn how to ingest documents
Connectors
Explore available connectors
Search
Perform semantic similarity search