Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

About

Local live web RAG in one SQLite file: SpecStream search and extract results chunked into FTS5 and sqlite-vec, ranked by BM25 and vectors, refreshed from the live web.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Live web RAG in one SQLite file: SpecStream plus FTS5 and sqlite-vec

A local retrieval index built from the live web. SpecStream, the live web data engine, searches and reads the pages; one SQLite file keeps them as chunks with their URL, title, published date and read time, and ranks them with full text search (FTS5, BM25) and, when you add sqlite-vec, with vectors too. No server, no vector database, no framework: one Python file, standard library only for full text.

Step What runs Price
ingest "<topic>" GET /v1/web-search?speed=fast, then POST /v1/extract on the results, 20 pages a call $1 per 1,000 searches, $0.80 per 1,000 pages
add <urls> POST /v1/extract $0.80 per 1,000 pages
ask "<question>" SQLite only: BM25, fused with vector distance when vectors are on free
refresh --days 7 reads again every page older than 7 days $0.80 per 1,000 pages

So indexing the top 10 pages on a topic costs at most $0.009, and a thousand pages $0.80.

Run

git clone https://github.com/specstream/sqlite-vec-rag-specstream-starter
cd sqlite-vec-rag-specstream-starter

export SPECSTREAM_API_KEY=your_key        # Agents & API at specstream.ai/workspace; $2 free credit, no card
python rag.py ingest "vector database benchmarks 2026" --pages 10
python rag.py add https://www.sqlite.org/fts5.html https://alexgarcia.xyz/sqlite-vec/
python rag.py ask "which vector database is fastest at 10M rows?"
python rag.py stats

ingest prints how many results it found, how many pages it read and indexed, and the most it cost. ask prints each chunk as [n] title, published date, its URL, and the first 300 characters of its text.

A page that refuses the read or holds no text is left out; the rest keep the date the page states and the time SpecStream read it, so an answer can say how fresh it is.

Vectors with sqlite-vec

pip install sqlite-vec                                      # Python whose sqlite3 can load extensions
export EMBED_BASE_URL=http://localhost:11434/v1             # any OpenAI compatible /embeddings: Ollama, vLLM, LM Studio, OpenAI
export EMBED_MODEL=nomic-embed-text
python rag.py --db rag-vec.sqlite ingest "vector database benchmarks 2026"
python rag.py --db rag-vec.sqlite ask "managed vector search price per GB"

Each chunk gets its vector in a vec0 table, and ask fuses the BM25 and vector rankings by reciprocal rank. A page read again replaces its chunks and their vectors.

In your code

from rag import Index, web_search, extract

index = Index("rag.sqlite")
sources = web_search("EU AI Act general purpose AI obligations", num=10)
index.store(extract([s["url"] for s in sources if s.get("url")]))
for hit in index.search("when do the obligations apply?", k=5):
    print(hit["url"], hit["published"], hit["text"][:200])

Hand hit["text"] with its URL to any model as numbered sources. For a ready answer step on any model, see perplexity-rag-grounding-specstream.

Test

python -m unittest discover -s tests -v      # offline: a local fake plays SpecStream and the embeddings endpoint
pip install sqlite-vec && python -m unittest discover -s tests -v    # adds the vector tests
python tests/live_check.py                   # live and free: both SpecStream routes answer and ask for a key

All tests pass on Python 3.9 with sqlite-vec 0.1.9.

Links

Related data and plans

License

MIT

About

Local live web RAG in one SQLite file: SpecStream search and extract results chunked into FTS5 and sqlite-vec, ranked by BM25 and vectors, refreshed from the live web.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages