ultisuite-backend/internal/ai/cost/usage.go
R3D347HR4Y 3978622050
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
refactor(ai): update AI gateway and cost management features
- Refactored AI gateway to utilize new cost management structures for usage tracking.
- Replaced deprecated token extraction methods with a unified cost parsing approach.
- Enhanced usage fallback mechanisms and introduced detailed usage metrics in responses.
- Added new metering functionality to record AI usage and costs effectively.
- Updated tests to reflect changes in usage parsing and cost calculations.
- Introduced new API endpoints for retrieving AI usage summaries and pricing information.
2026-06-16 10:46:33 +02:00

19 lines
382 B
Go

package cost
// UsageDetail holds token counts from a provider response.
type UsageDetail struct {
PromptTokens int
CompletionTokens int
CachedInputTokens int
ReasoningTokens int
TotalTokens int
}
func (u UsageDetail) UncachedInputTokens() int {
uncached := u.PromptTokens - u.CachedInputTokens
if uncached < 0 {
return u.PromptTokens
}
return uncached
}