@posthog/ai 6.5.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { wrapLanguageModel } from 'ai';
6
6
  import AnthropicOriginal from '@anthropic-ai/sdk';
7
7
  import { GoogleGenAI } from '@google/genai';
8
8
 
9
- var version = "6.5.0";
9
+ var version = "6.5.1";
10
10
 
11
11
  // Type guards for safer type checking
12
12
  const isString = value => {
@@ -3572,6 +3572,11 @@ class LangChainCallbackHandler extends BaseCallbackHandler {
3572
3572
  } else if (usage.reasoningTokens != null) {
3573
3573
  additionalTokenData.reasoningTokens = usage.reasoningTokens;
3574
3574
  }
3575
+ // In LangChain, input_tokens is the sum of input and cache read tokens.
3576
+ // Our cost calculation expects them to be separate, for Anthropic.
3577
+ if (parsedUsage.input && additionalTokenData.cacheReadInputTokens) {
3578
+ parsedUsage.input = Math.max(parsedUsage.input - additionalTokenData.cacheReadInputTokens, 0);
3579
+ }
3575
3580
  return [parsedUsage.input, parsedUsage.output, additionalTokenData];
3576
3581
  }
3577
3582
  parseUsage(response) {