fix: enforce internal embeddings contract

This commit is contained in:
2026-08-08 17:33:19 +02:00
parent 2911e008d1
commit c875fa52ce
5 changed files with 131 additions and 3 deletions
+21 -2
View File
@@ -106,7 +106,7 @@ roots:
sessions: {runtime_root / 'sessions'}
artifacts: {runtime_root / 'artifacts'}
indexes: {runtime_root / 'indexes'}
embeddings: {{base_url: http://embedding.invalid, model: embed, dim: 768}}
embeddings: {{provider: ollama_internal, base_url: http://embedding:11434, model: qwen3-embedding:0.6b, dim: 1024}}
""")
monkeypatch.setenv("THT_DATA_ROOT", str(data_root))
@@ -204,7 +204,7 @@ dwh:
vectors:
type: thoth_vector_http
writer: {base_url: https://vectors.test/, api_key: writer}
embeddings: {base_url: http://ollama:11434, dim: 768}
embeddings: {provider: ollama_internal, base_url: http://embedding:11434, model: qwen3-embedding:0.6b, dim: 1024}
"""
)
@@ -302,6 +302,25 @@ dwh:
load_config(workspace)
def test_rejects_external_top_level_embedding_configuration(tmp_path):
workspace = tmp_path / "workspace.yaml"
workspace.write_text(
"""
dwh:
type: postgres_direct
connection: {database: analytics, schema: mart, user: reader, password: secret}
embeddings:
provider: openai_compatible
base_url: https://embedding.example.test
model: text-embedding-3-large
dim: 3072
"""
)
with pytest.raises(ConfigError, match="ollama_internal|provider|base_url|model|1024"):
load_config(workspace)
def test_builds_typed_evidence_sources_and_keeps_legacy_compatible(tmp_path):
common = """
dwh:
+17
View File
@@ -137,3 +137,20 @@ def test_internal_embeddings_reject_non_finite_values():
with pytest.raises(EmbeddingsError, match="finite|finit"):
embedder.embed(["alpha"])
def test_internal_embeddings_reject_non_object_json_payload():
from tht.vectorstore.embeddings import OllamaInternalEmbeddings
embedder = OllamaInternalEmbeddings(
EmbeddingsConfig(
provider="ollama_internal",
base_url="http://embedding:11434",
model="qwen3-embedding:0.6b",
dim=1024,
),
session=_Session([_Response([_vector(1.0)])]),
)
with pytest.raises(EmbeddingsError, match="response|payload|embeddings"):
embedder.embed(["alpha"])