|
1 | 1 | # 🍰 PatchVec — Lightweight, Pluggable Vector Search Microservice |
2 | 2 |
|
3 | | -Upload → chunk → index (with metadata) → search via REST and CLI. |
| 3 | +Patchvec is a compact vector store built for people who want provenance and fast iteration on RAG plumbing. No black boxes, no hidden pipelines: every chunk records document id, page, and byte offsets, and you can swap embeddings or storage backends per collection. |
4 | 4 |
|
5 | | ---- |
| 5 | +## ⚙️ Core capabilities |
6 | 6 |
|
7 | | -## 🚀 Quickstart |
| 7 | +- **Docker images** — prebuilt CPU/GPU images published to the GitLab Container Registry. |
| 8 | +- **Tenants and collections** — isolation by tenant with per-collection configuration. |
| 9 | +- **Pluggable embeddings** — choose the embedding adapter per collection; wire in local or hosted models. |
| 10 | +- **REST and CLI** — production use over HTTP, quick experiments with the bundled CLI. |
| 11 | +- **Deterministic provenance** — every hit returns doc id, page, offset, and snippet for traceability. |
8 | 12 |
|
9 | | -### 🖥️ CPU-only Dev (default) |
10 | | -```bash |
11 | | -python -m venv .venv |
12 | | -source .venv/bin/activate |
13 | | -python -m pip install --upgrade pip |
14 | | -pip install -r requirements-cpu.txt |
15 | | -./pavesrv.sh |
16 | | -``` |
| 13 | +## 🧭 Workflows |
| 14 | + |
| 15 | +### 🐳 Docker workflow (prebuilt images) |
| 16 | + |
| 17 | +Pull the image that fits your hardware from the [https://gitlab.com/flowlexi](Flowlexi) Container Registry on Gitlab (CUDA builds publish as `latest`, CPU-only as `latest-cpu`). |
17 | 18 |
|
18 | | -### 📦 Install from PyPI |
19 | 19 | ```bash |
20 | | -python -m venv .venv |
21 | | -source .venv/bin/activate |
22 | | -python -m pip install --upgrade pip |
23 | | -pip install patchvec[cpu] # or patchvec[gpu] for CUDA |
| 20 | +docker pull registry.gitlab.com/flowlexi/patchvec/patchvec:latest |
| 21 | +docker pull registry.gitlab.com/flowlexi/patchvec/patchvec:latest-cpu |
24 | 22 | ``` |
25 | 23 |
|
26 | | -### ▶️ Run the Server |
27 | | -From source: |
| 24 | +Run the service by choosing the tag you need and mapping the API port locally: |
| 25 | + |
28 | 26 | ```bash |
29 | | -./pavesrv.sh |
| 27 | +docker run -d --name patchvec \ |
| 28 | + -p 8086:8086 \ |
| 29 | + registry.gitlab.com/flowlexi/patchvec/patchvec:latest-cpu |
30 | 30 | ``` |
31 | | -From PyPI: |
| 31 | + |
| 32 | +Use the bundled CLI inside the container to create a tenant/collection, ingest a demo document, and query it: |
| 33 | + |
32 | 34 | ```bash |
33 | | -pavesrv |
| 35 | +docker exec patchvec pavecli create-collection demo books |
| 36 | +docker exec patchvec pavecli upload demo books /app/demo/20k_leagues.txt \ |
| 37 | + --docid=verne-20k --metadata='{"lang":"en"}' |
| 38 | +docker exec patchvec pavecli search demo books "captain nemo" -k 3 |
34 | 39 | ``` |
35 | 40 |
|
36 | | -### ⚙️ Minimal Config |
37 | | -For production (static auth), set env vars (do not commit secrets): |
38 | | -```env |
39 | | -PATCHVEC_AUTH__MODE=static |
40 | | -PATCHVEC_AUTH__GLOBAL_KEY=sekret-passwod |
41 | | -``` |
42 | | -(Optional: copy `config.yml.example` to an untracked `config.yml` and tweak as needed) |
43 | | -(Tip: use an untracked `tenants.yml` and point `auth.tenants_file` to it in `config.yml`.) |
| 41 | +See below for REST and UI. |
44 | 42 |
|
45 | | ---- |
| 43 | +Stop the container when you are done: |
46 | 44 |
|
47 | | -## 🔧 Overriding Server Settings (uvicorn) |
48 | | -You can override a few server knobs via environment variables: |
49 | 45 | ```bash |
50 | | -HOST=127.0.0.1 PORT=9000 RELOAD=1 WORKERS=4 LOG_LEVEL=debug pavesrv |
| 46 | +docker rm -f patchvec |
51 | 47 | ``` |
52 | | -> Note: Full configuration uses the `PATCHVEC_...` env scheme (e.g., `PATCHVEC_SERVER__PORT=9000`). |
53 | 48 |
|
54 | | ---- |
| 49 | +### 🐍 PyPI workflow |
55 | 50 |
|
56 | | -## 🌐 REST API Examples |
| 51 | +Install Patchvec from PyPI inside an isolated virtual environment and point it at a local configuration directory: |
57 | 52 |
|
58 | | -**Create a collection** |
59 | 53 | ```bash |
60 | | -curl -X POST "http://localhost:8086/collections/acme/invoices" |
61 | | -``` |
| 54 | +mkdir -p ~/pv && cd ~/pv #or wherever |
| 55 | +python -m venv .venv-pv |
| 56 | +source .venv-pv/bin/activate |
| 57 | +python -m pip install --upgrade pip |
| 58 | +python -m pip install "patchvec[cpu]" # or "patchvec[gpu]" for CUDA |
62 | 59 |
|
63 | | -**Upload a TXT/PDF/CSV document** |
64 | | -```bash |
65 | | -curl -X POST "http://localhost:8086/collections/acme/invoices/documents" -F "file=@sample.txt" -F "docid=DOC-1" -F 'metadata={"lang":"pt"}' |
66 | | -``` |
| 60 | +# grab the default configs |
| 61 | +curl -LO https://raw.githubusercontent.com/patchvec/patchvec/main/config.yml.example |
| 62 | +curl -LO https://raw.githubusercontent.com/patchvec/patchvec/main/tenants.yml.example |
| 63 | +cp config.yml.example config.yml |
| 64 | +cp tenants.yml.example tenants.yml |
67 | 65 |
|
68 | | -**Search (GET, no filters)** |
69 | | -```bash |
70 | | -curl "http://localhost:8086/collections/acme/invoices/search?q=garantia&k=5" |
71 | | -``` |
| 66 | +# sample demo corpus |
| 67 | +curl -LO https://raw.githubusercontent.com/patchvec/patchvec/main/demo/20k_leagues.txt |
72 | 68 |
|
73 | | -**Search (POST with filters)** |
74 | | -```bash |
75 | | -curl -X POST "http://localhost:8086/collections/acme/invoices/search" -H "Content-Type: application/json" -d '{"q": "garantia", "k": 5, "filters": {"docid": "DOC-1"}}' |
| 69 | +# point Patchvec at the config directory and set a local admin key |
| 70 | +export PATCHVEC_CONFIG="$HOME/pv/config.yml" |
| 71 | +export PATCHVEC_GLOBAL_KEY=super-sekret |
| 72 | + |
| 73 | +# option A: run the service (stays up until you stop it) |
| 74 | +pavesrv |
| 75 | + |
| 76 | +# option B: operate entirely via the CLI (no server needed) |
| 77 | +pavecli create-collection demo books |
| 78 | +pavecli upload demo books 20k_leagues.txt --docid=verne-20k --metadata='{"lang":"en"}' |
| 79 | +pavecli search demo books "captain nemo" -k 3 |
76 | 80 | ``` |
77 | 81 |
|
78 | | -**Health / Metrics** |
| 82 | +Deactivate the virtual environment with `deactivate` when finished. |
| 83 | + |
| 84 | +### 🌐 REST API and Web UI usage |
| 85 | + |
| 86 | +When the server is running (either via Docker or `pavesrv`), the API listens on `http://localhost:8086`. The following `curl` commands mirror the CLI sequence above—adjust the file path to wherever you stored the corpus (`/app/demo/20k_leagues.txt` in Docker, `~/pv/20k_leagues.txt` for PyPI installs) and reuse the bearer token exported earlier: |
| 87 | + |
79 | 88 | ```bash |
80 | | -curl "http://localhost:8086/health" |
81 | | -curl "http://localhost:8086/metrics" |
| 89 | +# create collection |
| 90 | +curl -H "Authorization: Bearer $PATCHVEC_GLOBAL_KEY" \ |
| 91 | + -X POST http://localhost:8086/collections/demo/books |
| 92 | + |
| 93 | +# ingest document |
| 94 | +curl -H "Authorization: Bearer $PATCHVEC_GLOBAL_KEY" \ |
| 95 | + -X POST http://localhost:8086/collections/demo/books/documents \ |
| 96 | + -F "file=@20k_leagues.txt" \ |
| 97 | + -F 'metadata={"lang":"en"}' |
| 98 | + |
| 99 | +# run search |
| 100 | +curl -H "Authorization: Bearer $PATCHVEC_GLOBAL_KEY" \ |
| 101 | + "http://localhost:8086/collections/demo/books/search?q=captain+nemo&k=3" |
82 | 102 | ``` |
83 | 103 |
|
84 | | ---- |
| 104 | +There is a simple Swagger UI available at the root of the server. Just point your browser to `http://localhost:8086/` |
| 105 | + |
| 106 | +Health and metrics endpoints are available at `/health` and `/metrics`. |
| 107 | + |
| 108 | +Configuration files copied in either workflow can be customised. Runtime options are also accepted via the `PATCHVEC_*` environment variable scheme (`PATCHVEC_SERVER__PORT`, `PATCHVEC_AUTH__MODE`, etc.), which precedes conf files. |
| 109 | + |
| 110 | +### 🛠️ Developer workflow |
| 111 | + |
| 112 | +Building from source relies on the `Makefile` shortcuts (`make install-dev`, `USE_CPU=1 make serve`, `make test`, etc.). The full contributor workflow, target reference, and task claiming rules live in [CONTRIBUTING.md](CONTRIBUTING.md). |
| 113 | + |
| 114 | +## 🗺️ Roadmap |
| 115 | + |
| 116 | +Short & mid-term chores are tracked in [`ROADMAP.md`](ROADMAP.md). Pick one, open an issue titled `claim: <task>`, and ship a patch. |
85 | 117 |
|
86 | 118 | ## 📜 License |
| 119 | + |
87 | 120 | GPL-3.0-or-later — (C) 2025 Rodrigo Rodrigues da Silva |
0 commit comments