Adaptive routing initial version
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled

This commit is contained in:
2026-05-18 11:38:12 +02:00
parent 14838ae968
commit a27945101c
7 changed files with 476 additions and 89 deletions

View File

@@ -4,6 +4,7 @@ Integration coverage for the adaptive routing workplan flow.
from datetime import datetime, timezone
from examples.adaptive_routing_fixture_batch import populate_ledger
from llm_connect.adapter import MockLLMAdapter
from llm_connect.quality import QualityLedger, QualityObservation
from llm_connect.routing import AdaptiveRoutingPolicy, RoutingRule
@@ -88,3 +89,21 @@ def test_adaptive_policy_converges_to_cheapest_qualifying_adapter(tmp_path):
)
assert policy.resolve("summarize", quality_floor=0.8) is cheap
def test_fixture_batch_populates_three_candidate_observations_per_task(tmp_path):
ledger = QualityLedger(tmp_path / "quality.jsonl")
populate_ledger(ledger)
observations = ledger.read_all()
by_task_type: dict[str, set[str]] = {}
for observation in observations:
by_task_type.setdefault(observation.task_type, set()).add(observation.adapter_id)
assert set(by_task_type) == {
"summarize-source",
"extract-relations",
"evaluate-entity",
}
assert all(len(adapter_ids) == 3 for adapter_ids in by_task_type.values())