feat: 兼容了用量使用显示

This commit is contained in:
chenchun
2025-07-22 10:40:23 +08:00
parent b6d670c240
commit a0eb234539
8 changed files with 97 additions and 75 deletions

View File

@@ -132,8 +132,7 @@ public class AiGateWayManager : DomainService
TokenUsage = data.Usage
});
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.Usage.InputTokens ?? 0,
data.Usage.OutputTokens ?? 0);
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.Usage);
}
await response.WriteAsJsonAsync(data, cancellationToken);
@@ -200,7 +199,7 @@ public class AiGateWayManager : DomainService
{
await foreach (var data in completeChatResponse)
{
if (data.Usage is not null && data.Usage.TotalTokens is not null)
if (data.Usage is not null)
{
tokenUsage = data.Usage;
}
@@ -261,8 +260,7 @@ public class AiGateWayManager : DomainService
TokenUsage = tokenUsage
});
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, tokenUsage.InputTokens ?? 0,
tokenUsage.OutputTokens ?? 0);
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, tokenUsage);
}
}
}