aboutsummaryrefslogtreecommitdiffstats
path: root/PLAN.md
diff options
context:
space:
mode:
authorClawd <ai@clawd.bot>2026-03-05 07:19:28 -0800
committerClawd <ai@clawd.bot>2026-03-05 07:19:28 -0800
commit03d8f49479b3446cf7f8ab9b6fdb2401584e3f12 (patch)
tree18d9710e061c1f3d1717ba2b8256edeb85e43459 /PLAN.md
parent231286de90f85d699f77e17871552534d75bd8bb (diff)
Add Ollama support as default provider, clean Embedder interface
Diffstat (limited to 'PLAN.md')
-rw-r--r--PLAN.md69
1 files changed, 38 insertions, 31 deletions
diff --git a/PLAN.md b/PLAN.md
index 88545b9..2c59e97 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -103,35 +103,55 @@ type Chunker interface {
103 103
104## Phase 4: Embedding Generation 104## Phase 4: Embedding Generation
105 105
106Generate embeddings via OpenAI-compatible API (internal endpoint). 106Provider interface with Ollama (default) and OpenAI-compatible backends.
107 107
108**Input:** List of chunks 108**Input:** List of chunks
109**Output:** Chunks with embedding vectors 109**Output:** Chunks with embedding vectors
110 110
111```go 111```go
112// Provider interface — easy to swap
112type Embedder interface { 113type Embedder interface {
113 Embed(ctx context.Context, texts []string) ([][]float32, error) 114 Embed(ctx context.Context, texts []string) ([][]float32, error)
115 Dimensions() int
114} 116}
115 117
116type Embedder struct { 118// Ollama provider (default)
117 baseURL string // defaults to OpenAI, configurable for internal API 119type OllamaEmbedder struct {
120 baseURL string // default: http://localhost:11434
121 model string // default: nomic-embed-text
122}
123
124// OpenAI-compatible provider
125type OpenAIEmbedder struct {
126 baseURL string // configurable for internal API
118 apiKey string 127 apiKey string
119 model string // "text-embedding-3-small" 128 model string // text-embedding-3-small, etc.
120} 129}
121``` 130```
122 131
123**Batching:** Batch chunks to minimize API calls (~100 per request). 132**Provider selection via flag:**
133```bash
134codevec index . --provider ollama --model nomic-embed-text
135codevec index . --provider openai --model text-embedding-3-small
136```
124 137
125**Config:** 138**Config:**
126- `CODEVEC_API_KEY` — API key 139- `--provider` — `ollama` (default) or `openai`
127- `CODEVEC_BASE_URL` — Embedding API endpoint 140- `--model` — model name (provider-specific defaults)
128- `--model` flag for model selection 141- `CODEVEC_API_KEY` — API key (OpenAI provider)
142- `CODEVEC_BASE_URL` — Override endpoint (both providers)
143
144**Ollama models for embeddings:**
145- `nomic-embed-text` — 768 dims, good general purpose
146- `mxbai-embed-large` — 1024 dims, higher quality
129 147
130**Tasks:** 148**Tasks:**
131- [ ] Implement OpenAI-compatible embedding client (stdlib `net/http`) 149- [ ] Define `Embedder` interface
132- [ ] Support custom base URL for internal API 150- [ ] Implement `OllamaEmbedder` (POST to `/api/embeddings`)
133- [ ] Batch requests 151- [ ] Implement `OpenAIEmbedder` (POST to `/v1/embeddings`)
134- [ ] Handle rate limits with exponential backoff 152- [ ] Provider factory based on `--provider` flag
153- [ ] Batch requests where supported
154- [ ] Handle errors gracefully (connection refused, model not found)
135 155
136--- 156---
137 157
@@ -159,9 +179,11 @@ CREATE TABLE files (
159 indexed_at INTEGER DEFAULT (unixepoch()) 179 indexed_at INTEGER DEFAULT (unixepoch())
160); 180);
161 181
182-- Dimension set at index creation based on model
183-- nomic-embed-text: 768, mxbai-embed-large: 1024, text-embedding-3-small: 1536
162CREATE VIRTUAL TABLE vec_chunks USING vec0( 184CREATE VIRTUAL TABLE vec_chunks USING vec0(
163 id INTEGER PRIMARY KEY, 185 id INTEGER PRIMARY KEY,
164 embedding FLOAT[1536] 186 embedding FLOAT[768] -- adjusted per model
165); 187);
166``` 188```
167 189
@@ -247,7 +269,9 @@ Only re-index changed files.
247 "indexed_at": 1709654400 269 "indexed_at": 1709654400
248 } 270 }
249 }, 271 },
250 "model": "text-embedding-3-small", 272 "provider": "ollama",
273 "model": "nomic-embed-text",
274 "dimensions": 768,
251 "version": 1 275 "version": 1
252} 276}
253``` 277```
@@ -280,7 +304,6 @@ Only re-index changed files.
280 304
281- TypeScript chunker (tree-sitter + TS grammar) 305- TypeScript chunker (tree-sitter + TS grammar)
282- Python chunker 306- Python chunker
283- Ollama embedder for local/offline use
284- `codevec serve` HTTP API 307- `codevec serve` HTTP API
285- Watch mode (re-index on file change) 308- Watch mode (re-index on file change)
286- Import/export index 309- Import/export index
@@ -300,22 +323,6 @@ require (
300 323
301--- 324---
302 325
303## Estimated Effort
304
305| Phase | Effort |
306|-------|--------|
307| 1. Skeleton | 30 min |
308| 2. Walker | 1 hr |
309| 3. Chunker | 2 hr |
310| 4. Embedder | 1 hr |
311| 5. Storage | 2 hr |
312| 6. CLI | 1 hr |
313| 7. Incremental | 1 hr |
314| 8. Polish | 30 min |
315| **Total** | ~9 hr |
316
317---
318
319## Decisions 326## Decisions
320 327
3211. **CLI framework:** Cobra 3281. **CLI framework:** Cobra