Commit aa334c08 by QuentinHsu

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.
parent a6c02012
...@@ -347,7 +347,7 @@ export const ContextReasoningUsage = ({ ...@@ -347,7 +347,7 @@ export const ContextReasoningUsage = ({
}: ContextReasoningUsageProps) => { }: ContextReasoningUsageProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const { usage, modelId } = useContextValue() const { usage, modelId } = useContextValue()
const reasoningTokens = usage?.reasoningTokens ?? 0 const reasoningTokens = usage?.outputTokenDetails.reasoningTokens ?? 0
if (children) { if (children) {
return children return children
...@@ -388,7 +388,7 @@ export const ContextCacheUsage = ({ ...@@ -388,7 +388,7 @@ export const ContextCacheUsage = ({
}: ContextCacheUsageProps) => { }: ContextCacheUsageProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const { usage, modelId } = useContextValue() const { usage, modelId } = useContextValue()
const cacheTokens = usage?.cachedInputTokens ?? 0 const cacheTokens = usage?.inputTokenDetails.cacheReadTokens ?? 0
if (children) { if (children) {
return children return children
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment