This commit is contained in:
ping 2026-06-03 11:03:31 +08:00
parent 5a6524ffa5
commit 425137c7c3

View File

@ -95,7 +95,7 @@ def _normalize_usage_row(row, bill_amount_map=None):
'prompt_tokens': int(usage.get('prompt_tokens') or 0),
'completion_tokens': int(usage.get('completion_tokens') or 0),
'total_tokens': int(usage.get('total_tokens') or 0),
'amount': round(amount, 8),
'amount': round(amount, 4),
'bill_status': row.get('bill_status'),
'orderid': orderid,
'usage_time': row.get('created_at'),
@ -224,7 +224,7 @@ def _aggregate_admin_summary(items, user_map, org_map):
bucket['prompt_tokens'] += item.get('prompt_tokens') or 0
bucket['completion_tokens'] += item.get('completion_tokens') or 0
bucket['total_tokens'] += item.get('total_tokens') or 0
bucket['amount'] = round(bucket['amount'] + float(item.get('amount') or 0), 8)
bucket['amount'] = round(bucket['amount'] + float(item.get('amount') or 0), 4)
bucket['request_count'] += 1
usage_time = item.get('usage_time')
if usage_time:
@ -267,7 +267,7 @@ def _aggregate_items(items, group_by=None):
bucket['prompt_tokens'] += item.get('prompt_tokens') or 0
bucket['completion_tokens'] += item.get('completion_tokens') or 0
bucket['total_tokens'] += item.get('total_tokens') or 0
bucket['amount'] = round(bucket['amount'] + float(item.get('amount') or 0), 8)
bucket['amount'] = round(bucket['amount'] + float(item.get('amount') or 0), 4)
bucket['request_count'] += 1
return sorted(buckets.values(), key=lambda x: x['period'], reverse=True)
@ -279,7 +279,7 @@ def _summarize(items):
'prompt_tokens': sum(i.get('prompt_tokens') or 0 for i in items),
'completion_tokens': sum(i.get('completion_tokens') or 0 for i in items),
'total_tokens': sum(i.get('total_tokens') or 0 for i in items),
'amount': round(sum(float(i.get('amount') or 0) for i in items), 8),
'amount': round(sum(float(i.get('amount') or 0) for i in items), 4),
}