Skip to content

Official Codebase of 3DCodeVerse

Python

backends: gemini-cli's per-model usage parser is public gemini_model_usage — eval's session_stats imported it by its private name

gaoypeng36603398451f
diff --git a/eval/bench/session_stats.py b/eval/bench/session_stats.py
index 31a3447a..cce50672 100644
--- a/eval/bench/session_stats.py
+++ b/eval/bench/session_stats.py
@@ -70,14 +70,14 @@ def tool_rates(sessions: list[Path]) -> tuple[Counter, Counter]:
def token_rates(sessions: list[Path]) -> dict[str, float]:
"""Prompt/cached tokens and requests for each session's MAIN model.
- ``agents.backends._model_usage`` owns the envelope — including the older
+ ``agents.backends.gemini_model_usage`` owns the envelope — including the older
``tokens.input`` schema this file would otherwise read as zero — so the tokens come
from it rather than from a second parser. A session's ``models`` map also carries
gemini-cli's own bookkeeping model (one request per session for the session title),
and docs/COST.md §30 counts main-role requests: the model with the most requests IS
the main role, and mixing the other in moves ``uncached per request`` by ~3 %.
"""
- from codeverse3d.agents.backends import _model_usage
+ from codeverse3d.agents.backends import gemini_model_usage
prompt = cached = requests = 0
for path in sessions:
@@ -85,7 +85,7 @@ def token_rates(sessions: list[Path]) -> dict[str, float]:
if not models:
continue
main = max(models, key=lambda n: int(((models[n] or {}).get("api") or {}).get("totalRequests") or 0))
- usage = _model_usage((models[main] or {}).get("tokens") or {}, main)
+ usage = gemini_model_usage((models[main] or {}).get("tokens") or {}, main)
prompt += usage.input_tokens
cached += usage.cached_tokens
requests += int(((models[main] or {}).get("api") or {}).get("totalRequests") or 0)
diff --git a/harness/codeverse3d/agents/backends.py b/harness/codeverse3d/agents/backends.py
index 4f792ef5..6f41b723 100644
--- a/harness/codeverse3d/agents/backends.py
+++ b/harness/codeverse3d/agents/backends.py
@@ -261,7 +261,7 @@ class GeminiRetries:
return ", ".join(f"{n} x {k}" for k, n in counts.items())
-def _model_usage(tok: dict[str, Any], name: str) -> Usage:
+def gemini_model_usage(tok: dict[str, Any], name: str) -> Usage:
"""One served model's counters in pricing semantics (``input_tokens`` = total prompt)."""
cached = int(tok.get("cached") or 0)
prompt = tok.get("prompt")
@@ -277,7 +277,7 @@ def usage_from_stats(stats: dict[str, Any], model: str) -> Usage:
u = Usage(backend="gemini-cli", model=model)
cost = 0.0
for name, m in (stats.get("models") or {}).items():
- part = _model_usage((m or {}).get("tokens") or {}, str(name))
+ part = gemini_model_usage((m or {}).get("tokens") or {}, str(name))
c = estimate_cost("gemini", str(name), part)
if c == 0.0 and name != model and (part.input_tokens or part.output_tokens):
c = estimate_cost("gemini", model, part) # utility model missing from the price table