@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.
@@ -6,7 +6,7 @@ var AnthropicOriginal = require('@anthropic-ai/sdk');
6
6
  var buffer = require('buffer');
7
7
  var uuid = require('uuid');
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
 
@@ -2,7 +2,7 @@ import AnthropicOriginal from '@anthropic-ai/sdk';
2
2
  import { Buffer } from 'buffer';
3
3
  import { v4 } from 'uuid';
4
4
 
5
- var version = "6.5.0";
5
+ var version = "6.5.1";
6
6
 
7
7
  // Type guards for safer type checking
8
8
 
@@ -6,7 +6,7 @@ var genai = require('@google/genai');
6
6
  var buffer = require('buffer');
7
7
  var uuid = require('uuid');
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
 
@@ -2,7 +2,7 @@ import { GoogleGenAI } from '@google/genai';
2
2
  import { Buffer } from 'buffer';
3
3
  import { v4 } from 'uuid';
4
4
 
5
- var version = "6.5.0";
5
+ var version = "6.5.1";
6
6
 
7
7
  // Type guards for safer type checking
8
8
 
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ function _interopNamespaceDefault(e) {
26
26
 
27
27
  var uuid__namespace = /*#__PURE__*/_interopNamespaceDefault(uuid);
28
28
 
29
- var version = "6.5.0";
29
+ var version = "6.5.1";
30
30
 
31
31
  // Type guards for safer type checking
32
32
  const isString = value => {
@@ -3592,6 +3592,11 @@ class LangChainCallbackHandler extends BaseCallbackHandler {
3592
3592
  } else if (usage.reasoningTokens != null) {
3593
3593
  additionalTokenData.reasoningTokens = usage.reasoningTokens;
3594
3594
  }
3595
+ // In LangChain, input_tokens is the sum of input and cache read tokens.
3596
+ // Our cost calculation expects them to be separate, for Anthropic.
3597
+ if (parsedUsage.input && additionalTokenData.cacheReadInputTokens) {
3598
+ parsedUsage.input = Math.max(parsedUsage.input - additionalTokenData.cacheReadInputTokens, 0);
3599
+ }
3595
3600
  return [parsedUsage.input, parsedUsage.output, additionalTokenData];
3596
3601
  }
3597
3602
  parseUsage(response) {