in yourbench/utils/inference/inference_tracking.py [0:0]
def _log_individual_call(model_name: str, input_tokens: int, output_tokens: int, tags: List[str], encoding_name: str):
"""Logs a single inference call's cost details."""
global _individual_header_written
try:
_ensure_logs_dir()
is_new_file = not os.path.exists(_individual_log_file)
mode = "a" if not is_new_file else "w"
with open(_individual_log_file, mode, newline="", encoding="utf-8") as f:
writer = csv.writer(f)
# Write header only if the file is new or header wasn't written yet in this run
if is_new_file or not _individual_header_written:
writer.writerow(["timestamp", "model_name", "stage", "input_tokens", "output_tokens", "encoding_used"])
_individual_header_written = True
stage = ";".join(tags) if tags else "unknown"
timestamp = datetime.datetime.now(datetime.timezone.utc).isoformat()
writer.writerow([timestamp, model_name, stage, input_tokens, output_tokens, encoding_name])
except Exception as e:
logger.error(f"Failed to write to individual cost log: {e}")