feat: use internal ollama embeddings
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
# Task 4 Report — Narrow harness embedding configuration to internal Ollama
|
||||
|
||||
## Status
|
||||
|
||||
Implemented on 2026-08-08 in `/Users/mp/projects/ThothII/.worktrees/git-workspace-registry`.
|
||||
|
||||
## RED evidence
|
||||
|
||||
Command:
|
||||
|
||||
```bash
|
||||
cd harness
|
||||
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py -q
|
||||
```
|
||||
|
||||
Observed before implementation:
|
||||
|
||||
- exit code `1`
|
||||
- `10 failed, 10 passed`
|
||||
- failures proved the missing `OllamaInternalEmbeddings` client and missing internal-only config validation
|
||||
|
||||
Representative failures:
|
||||
|
||||
- `ImportError: cannot import name 'OllamaInternalEmbeddings'`
|
||||
- `AttributeError: 'EmbeddingsConfig' object has no attribute 'provider'`
|
||||
- config tests `DID NOT RAISE ConfigError` for external provider, API key, and non-private base URL
|
||||
|
||||
## GREEN evidence
|
||||
|
||||
Focused behavior suite:
|
||||
|
||||
```bash
|
||||
cd harness
|
||||
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py -q
|
||||
```
|
||||
|
||||
- exit code `0`
|
||||
- `20 passed`
|
||||
|
||||
Relevant harness verification:
|
||||
|
||||
```bash
|
||||
cd harness
|
||||
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py tests/test_ollama_ensure.py -q
|
||||
```
|
||||
|
||||
- exit code `0`
|
||||
- `36 passed, 2 warnings`
|
||||
|
||||
Changed-file lint:
|
||||
|
||||
```bash
|
||||
cd harness
|
||||
./.venv/bin/ruff check tht/config.py tht/config_compat.py tht/vectorstore/embeddings.py tht/cli/ollama_cmd.py tests/test_config_resources.py tests/test_internal_embeddings.py
|
||||
```
|
||||
|
||||
- exit code `0`
|
||||
- `All checks passed!`
|
||||
|
||||
Patch hygiene:
|
||||
|
||||
```bash
|
||||
git diff --check
|
||||
```
|
||||
|
||||
- exit code `0`
|
||||
|
||||
## What changed
|
||||
|
||||
- translated schema-v3 `resources.embeddings` into the harness-compatible embedding config view
|
||||
- validated the internal embedding contract only for that runtime-owned `resources.embeddings` path:
|
||||
- provider must be `ollama_internal`
|
||||
- model must be `qwen3-embedding:0.6b`
|
||||
- dimensions must be `1024`
|
||||
- base URL must be `http://embedding:11434` or loopback HTTP on port `11434`
|
||||
- extra fields like `api_key` are rejected
|
||||
- replaced the active embed client with `OllamaInternalEmbeddings`, using one bounded `/api/embed` request per batch
|
||||
- removed task/query prefix rewriting from the active embedding path
|
||||
- validated response count, vector dimension, and finite numeric values before returning embeddings
|
||||
- kept `tht ollama ensure --json` stdout pristine while warming through the internal client
|
||||
|
||||
## Self-review
|
||||
|
||||
- kept changes inside the brief-listed files
|
||||
- preserved DWH and session-persistence behavior
|
||||
- preserved the legacy `OllamaEmbeddings` import path as an alias to avoid unrelated call-site churn
|
||||
|
||||
## Concerns
|
||||
|
||||
- the focused harness verification still emits two pre-existing warnings:
|
||||
- `DeprecationWarning` from `testcontainers.postgres`
|
||||
- `FutureWarning` because `resources` currently flows through the legacy config translation path
|
||||
Reference in New Issue
Block a user