md-first memory extraction framework for AI agents. Markdown is the single source of truth; SQLite holds state and LanceDB provides the rebuildable vector + BM25 + scalar index. The codebase follows a single-direction DDD layering (entrypoints -> service -> memory -> infra, with component / core / config cross-cutting) enforced by import-linter. Engineering surface: - Coding conventions in .claude/rules/ (path-scoped) and workflows in .claude/skills/ (/commit, /new-branch, /pr). - GitHub Actions CI runs make lint + test + integration; pre-commit mirrors the gates locally (ruff, hygiene hooks, gitlint commit-msg). - Commit messages follow Conventional Commits, enforced by gitlint. - make lint also enforces datetime two-zone discipline and OpenAPI drift.
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
"""``build_rerank_provider`` — settings validation + provider routing."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import SecretStr
|
|
|
|
from everos.component.rerank import (
|
|
DeepInfraRerankProvider,
|
|
VllmRerankProvider,
|
|
build_rerank_provider,
|
|
)
|
|
from everos.config.settings import RerankSettings
|
|
|
|
|
|
def test_raises_when_model_missing() -> None:
|
|
s = RerankSettings(model=None, api_key=SecretStr("k"), base_url="https://x")
|
|
with pytest.raises(ValueError, match="EVEROS_RERANK__MODEL"):
|
|
build_rerank_provider(s)
|
|
|
|
|
|
def test_raises_when_base_url_missing() -> None:
|
|
s = RerankSettings(model="m", api_key=SecretStr("k"), base_url=None)
|
|
with pytest.raises(ValueError, match="EVEROS_RERANK__BASE_URL"):
|
|
build_rerank_provider(s)
|
|
|
|
|
|
def test_deepinfra_requires_api_key() -> None:
|
|
s = RerankSettings(
|
|
provider="deepinfra", model="m", api_key=None, base_url="https://x"
|
|
)
|
|
with pytest.raises(ValueError, match="EVEROS_RERANK__API_KEY"):
|
|
build_rerank_provider(s)
|
|
|
|
|
|
def test_deepinfra_builds_provider() -> None:
|
|
s = RerankSettings(
|
|
provider="deepinfra",
|
|
model="m",
|
|
api_key=SecretStr("k"),
|
|
base_url="https://api/v1/inference",
|
|
)
|
|
p = build_rerank_provider(s)
|
|
assert isinstance(p, DeepInfraRerankProvider)
|
|
|
|
|
|
def test_vllm_accepts_empty_api_key() -> None:
|
|
"""vLLM self-hosted: empty api_key is allowed (no auth header)."""
|
|
s = RerankSettings(
|
|
provider="vllm",
|
|
model="m",
|
|
api_key=None,
|
|
base_url="http://localhost:8000/v1",
|
|
)
|
|
p = build_rerank_provider(s)
|
|
assert isinstance(p, VllmRerankProvider)
|
|
|
|
|
|
def test_vllm_with_api_key() -> None:
|
|
s = RerankSettings(
|
|
provider="vllm",
|
|
model="m",
|
|
api_key=SecretStr("k"),
|
|
base_url="http://localhost:8000/v1",
|
|
)
|
|
p = build_rerank_provider(s)
|
|
assert isinstance(p, VllmRerankProvider)
|