Implement LLM-WP-0007: Kimi K3 default and EUR spend reporting
Add moonshotai/kimi-k3 as OpenRouter basemodel default after live smoke, USD→EUR cost conversion, append-only usage ledger, and CLI run/cost/spend week commands with token and euro reporting.
This commit is contained in:
parent
f3121c3f1f
commit
09aa1f3604
21 changed files with 1396 additions and 103 deletions
40
tests/test_fx.py
Normal file
40
tests/test_fx.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import pytest
|
||||
|
||||
from llm_connect.fx import DEFAULT_EUR_PER_USD, FxRate, resolve_fx_rate
|
||||
|
||||
|
||||
def test_resolve_fx_prefers_explicit_rate():
|
||||
rate = resolve_fx_rate(0.85)
|
||||
|
||||
assert rate is not None
|
||||
assert rate.eur_per_usd == pytest.approx(0.85)
|
||||
assert rate.source == "explicit"
|
||||
assert rate.usd_to_eur(10.0) == pytest.approx(8.5)
|
||||
|
||||
|
||||
def test_resolve_fx_reads_env(monkeypatch):
|
||||
monkeypatch.setenv("LLM_CONNECT_EUR_PER_USD", "0.9")
|
||||
|
||||
rate = resolve_fx_rate()
|
||||
|
||||
assert rate is not None
|
||||
assert rate.eur_per_usd == pytest.approx(0.9)
|
||||
assert rate.source == "env:LLM_CONNECT_EUR_PER_USD"
|
||||
|
||||
|
||||
def test_resolve_fx_falls_back_to_snapshot():
|
||||
rate = resolve_fx_rate(env={})
|
||||
|
||||
assert rate is not None
|
||||
assert rate.eur_per_usd == pytest.approx(DEFAULT_EUR_PER_USD)
|
||||
assert rate.source.startswith("snapshot:")
|
||||
|
||||
|
||||
def test_invalid_env_rate_raises():
|
||||
with pytest.raises(ValueError, match="LLM_CONNECT_EUR_PER_USD"):
|
||||
resolve_fx_rate(env={"LLM_CONNECT_EUR_PER_USD": "0"})
|
||||
|
||||
|
||||
def test_fx_rate_rejects_non_positive():
|
||||
with pytest.raises(ValueError, match="eur_per_usd"):
|
||||
FxRate(eur_per_usd=-1, source="x")
|
||||
Loading…
Add table
Add a link
Reference in a new issue