Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/test_dspy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ def log_message(self, *args):
@pytest.mark.optional
def test_teacher_uses_pinned_engine_overrides_and_unchanged_metering_against_loopback_double(monkeypatch):
pytest.importorskip("dspy")
pytest.importorskip("litellm")
litellm = pytest.importorskip("litellm")
# Use synthetic rates so metering stays independent of the published model catalog.
monkeypatch.setitem(litellm.model_cost, "deepseek/deepseek-flash", {
"input_cost_per_token": 0.000001, "output_cost_per_token": 0.000002,
"litellm_provider": "deepseek", "mode": "chat",
})
_Provider.seen = []
server = HTTPServer(("127.0.0.1", 0), _Provider)
thread = threading.Thread(target=server.serve_forever, daemon=True)
Expand All @@ -105,7 +110,8 @@ def test_teacher_uses_pinned_engine_overrides_and_unchanged_metering_against_loo
assert account["reported_input_tokens"] == 10 and account["reported_output_tokens"] == 5
assert account["observed_response_models"] == ["deepseek-flash"]
# Cost metadata comes from LiteLLM's response; DSPy 3.4 native engines would report it unknown.
assert account["cost_unknown_calls"] == 0 and account["sdk_estimated_cost"] is not None
assert account["cost_unknown_calls"] == 0
assert account["sdk_estimated_cost"] == pytest.approx(0.000020)
assert account["dollar_cost"] is None
assert teacher.lm.history == [] and teacher.revise.history == []
assert teacher.lm.cache is False
Expand Down
Loading