feat: use internal ollama embeddings
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import pytest
|
||||
|
||||
from tht.adapters.evidence import FilesystemEvidenceSource, HttpManifestEvidenceSource
|
||||
from tht.adapters.factory import build_evidence_sources
|
||||
from tht.config import (
|
||||
ConfigError,
|
||||
PgvectorDirectConfig,
|
||||
PostgresDwhConfig,
|
||||
ThothRestDwhConfig,
|
||||
ThothVectorHttpConfig,
|
||||
workspace_id_for_config,
|
||||
load_config,
|
||||
workspace_id_for_config,
|
||||
)
|
||||
from tht.adapters.evidence import FilesystemEvidenceSource, HttpManifestEvidenceSource
|
||||
from tht.adapters.factory import build_evidence_sources
|
||||
|
||||
|
||||
def test_direct_vector_passwords_load_from_file_references(monkeypatch, tmp_path):
|
||||
@@ -213,6 +213,95 @@ embeddings: {base_url: http://ollama:11434, dim: 768}
|
||||
assert cfg.vectors.writer.api_key == "writer"
|
||||
|
||||
|
||||
def test_accepts_only_internal_ollama_embedding_contract(tmp_path):
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(
|
||||
"""
|
||||
dwh:
|
||||
type: postgres_direct
|
||||
connection: {database: analytics, schema: mart, user: reader, password: secret}
|
||||
resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://embedding:11434
|
||||
model: qwen3-embedding:0.6b
|
||||
dimensions: 1024
|
||||
"""
|
||||
)
|
||||
|
||||
cfg = load_config(workspace)
|
||||
|
||||
assert cfg.embeddings.provider == "ollama_internal"
|
||||
assert cfg.embeddings.base_url == "http://embedding:11434"
|
||||
assert cfg.embeddings.model == "qwen3-embedding:0.6b"
|
||||
assert cfg.embeddings.dim == 1024
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("snippet", "pattern"),
|
||||
[
|
||||
(
|
||||
"""
|
||||
resources:
|
||||
embeddings:
|
||||
provider: openai_compatible
|
||||
base_url: http://embedding:11434
|
||||
model: qwen3-embedding:0.6b
|
||||
dimensions: 1024
|
||||
""",
|
||||
"ollama_internal|provider",
|
||||
),
|
||||
(
|
||||
"""
|
||||
resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://embedding:11434
|
||||
model: qwen3-embedding:0.6b
|
||||
dimensions: 1024
|
||||
api_key: secret
|
||||
""",
|
||||
"api_key|extra",
|
||||
),
|
||||
(
|
||||
"""
|
||||
resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: https://embedding:11434
|
||||
model: qwen3-embedding:0.6b
|
||||
dimensions: 1024
|
||||
""",
|
||||
"base_url|internal|private|host",
|
||||
),
|
||||
(
|
||||
"""
|
||||
resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://example.com:11434
|
||||
model: qwen3-embedding:0.6b
|
||||
dimensions: 1024
|
||||
""",
|
||||
"base_url|internal|private|host",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_rejects_external_embedding_configuration(tmp_path, snippet, pattern):
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(
|
||||
"""
|
||||
dwh:
|
||||
type: postgres_direct
|
||||
connection: {database: analytics, schema: mart, user: reader, password: secret}
|
||||
"""
|
||||
+ snippet
|
||||
)
|
||||
|
||||
with pytest.raises(ConfigError, match=pattern):
|
||||
load_config(workspace)
|
||||
|
||||
|
||||
def test_builds_typed_evidence_sources_and_keeps_legacy_compatible(tmp_path):
|
||||
common = """
|
||||
dwh:
|
||||
|
||||
Reference in New Issue
Block a user