fix(ai-elements): read nested usage token details

- use ai v7 usage detail fields for reasoning and cache token counts.
- keep context usage cost rendering compatible with the updated SDK types.
This commit is contained in:
QuentinHsu
2026-07-03 16:35:18 +08:00
parent a6c0201257
commit aa334c0850
+2 -2
View File
@@ -347,7 +347,7 @@ export const ContextReasoningUsage = ({
}: ContextReasoningUsageProps) => {
const { t } = useTranslation()
const { usage, modelId } = useContextValue()
const reasoningTokens = usage?.reasoningTokens ?? 0
const reasoningTokens = usage?.outputTokenDetails.reasoningTokens ?? 0
if (children) {
return children
@@ -388,7 +388,7 @@ export const ContextCacheUsage = ({
}: ContextCacheUsageProps) => {
const { t } = useTranslation()
const { usage, modelId } = useContextValue()
const cacheTokens = usage?.cachedInputTokens ?? 0
const cacheTokens = usage?.inputTokenDetails.cacheReadTokens ?? 0
if (children) {
return children