File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
packages/core/src/tracing/vercel-ai Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,13 @@ function processEndedVercelAiSpan(span: SpanJSON): void {
119119 renameAttributeKey ( attributes , AI_USAGE_PROMPT_TOKENS_ATTRIBUTE , GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE ) ;
120120 renameAttributeKey ( attributes , AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE , GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE ) ;
121121
122+ // Input tokens is the sum of prompt tokens and cached input tokens
123+ if ( typeof attributes [ GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE ] === 'number' &&
124+ typeof attributes [ GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE ] === 'number'
125+ ) {
126+ attributes [ GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE ] = attributes [ GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE ] + attributes [ GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE ] ;
127+ }
128+
122129 if (
123130 typeof attributes [ GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE ] === 'number' &&
124131 typeof attributes [ GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE ] === 'number'
You can’t perform that action at this time.
0 commit comments