mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-01 08:16:13 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
859b31e2bc | ||
|
|
fa0b2834c5 | ||
|
|
ecbe3158c0 | ||
|
|
bac50f2150 | ||
|
|
4bf02226dc | ||
|
|
c8f4e7d3e5 | ||
|
|
3d4a8e0e14 |
@@ -149,7 +149,6 @@ async def info() -> dict:
|
||||
"mints": global_settings.cashu_mints,
|
||||
"http_url": global_settings.http_url,
|
||||
"onion_url": global_settings.onion_url,
|
||||
"models": [], # kept for back-compat; prefer /v1/models
|
||||
}
|
||||
|
||||
|
||||
@@ -163,4 +162,4 @@ app.include_router(admin_router)
|
||||
app.include_router(balance_router)
|
||||
app.include_router(deprecated_wallet_router)
|
||||
app.include_router(providers_router)
|
||||
app.include_router(proxy_router)
|
||||
app.include_router(proxy_router)
|
||||
@@ -183,14 +183,23 @@ async def calculate_discounted_max_cost(
|
||||
else:
|
||||
adjusted = adjusted + math.ceil(-estimated_prompt_delta_sats * 1000)
|
||||
|
||||
if max_tokens := body.get("max_tokens"):
|
||||
estimated_completion_delta_sats = (
|
||||
max_completion_allowed_sats - max_tokens * model_pricing.completion
|
||||
)
|
||||
if estimated_completion_delta_sats >= 0:
|
||||
adjusted = adjusted - math.floor(estimated_completion_delta_sats * 1000)
|
||||
max_tokens_raw = body.get("max_tokens", None)
|
||||
if max_tokens_raw is not None:
|
||||
try:
|
||||
max_tokens_int = int(max_tokens_raw)
|
||||
except (TypeError, ValueError):
|
||||
logger.warning(
|
||||
"Invalid max_tokens; ignoring in cost adjustment",
|
||||
extra={"max_tokens": str(max_tokens_raw)[:64], "model": model},
|
||||
)
|
||||
else:
|
||||
adjusted = adjusted + math.ceil(-estimated_completion_delta_sats * 1000)
|
||||
estimated_completion_delta_sats = (
|
||||
max_completion_allowed_sats - max_tokens_int * model_pricing.completion
|
||||
)
|
||||
if estimated_completion_delta_sats >= 0:
|
||||
adjusted = adjusted - math.floor(estimated_completion_delta_sats * 1000)
|
||||
else:
|
||||
adjusted = adjusted + math.ceil(-estimated_completion_delta_sats * 1000)
|
||||
|
||||
logger.debug(
|
||||
"Discounted max cost computed",
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ async def get_wallet(mint_url: str, unit: str = "sat", load: bool = True) -> Wal
|
||||
id = f"{mint_url}_{unit}"
|
||||
if id not in _wallets:
|
||||
_wallets[id] = await Wallet.with_db(
|
||||
mint_url, db=".wallet", load_all_keysets=True, unit=unit
|
||||
mint_url, db=".wallet", unit=unit
|
||||
)
|
||||
|
||||
if load:
|
||||
|
||||
@@ -62,7 +62,6 @@ async def test_root_endpoint_structure_and_performance(
|
||||
"mints",
|
||||
"http_url",
|
||||
"onion_url",
|
||||
"models",
|
||||
]
|
||||
for field in required_fields:
|
||||
assert field in data, f"Missing required field: {field}"
|
||||
@@ -75,15 +74,9 @@ async def test_root_endpoint_structure_and_performance(
|
||||
assert isinstance(data["mints"], list)
|
||||
assert isinstance(data["http_url"], str)
|
||||
assert isinstance(data["onion_url"], str)
|
||||
assert isinstance(data["models"], list)
|
||||
|
||||
# Validate models structure if any exist
|
||||
for model in data["models"]:
|
||||
assert isinstance(model, dict)
|
||||
# Models should have at least basic fields
|
||||
model_required_fields = ["id", "name"]
|
||||
for field in model_required_fields:
|
||||
assert field in model, f"Model missing required field: {field}"
|
||||
# Ensure models field is not present (removed as per issue #184)
|
||||
assert "models" not in data, "Models field should not be present in base URL output"
|
||||
|
||||
# Verify no database state changes
|
||||
diff = await db_snapshot.diff()
|
||||
@@ -457,4 +450,4 @@ async def test_info_endpoints_response_consistency(
|
||||
# Model IDs should be the same
|
||||
first_ids = {m["id"] for m in first_models}
|
||||
response_ids = {m["id"] for m in models}
|
||||
assert first_ids == response_ids
|
||||
assert first_ids == response_ids
|
||||
Reference in New Issue
Block a user