Commit cedcbc2
authored
feat(memory): add local embedding provider via transformers.js (#95)
Wire EMBEDDING_PROVIDER=local to an in-process embedding adapter so PR-memory works without an external embedding API. LocalEmbeddingAdapter runs a sentence-transformers model (default Xenova/all-MiniLM-L6-v2, 384-dim) through @huggingface/transformers, forcing the WASM backend and a single thread because the Alpine runner image cannot load the native onnxruntime-node binary.
The memory module now selects the embedding adapter from EMBEDDING_PROVIDER instead of hard-wiring Voyage, and EMBEDDING_MODEL becomes optional with a per-adapter default. A migration aligns pr_memory.embedding with EMBEDDING_DIMENSIONS, acting only when the dimension actually changes and truncating the (model-specific, now-incompatible) vectors since the column is NOT NULL. A persistent model-cache volume keeps the downloaded model across restarts.1 parent 0db8c80 commit cedcbc2
10 files changed
Lines changed: 1037 additions & 10 deletions
File tree
- src
- config
- memory
- infrastructure/adapters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
0 commit comments