@posthog/ai 8.1.0 → 8.1.2
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/anthropic/index.cjs +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/gemini/index.cjs +1 -1
- package/dist/gemini/index.mjs +1 -1
- package/dist/index.cjs +10 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -20
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +34 -33
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.d.ts +3 -0
- package/dist/langchain/index.mjs +34 -33
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/openai/index.cjs +1 -1
- package/dist/openai/index.mjs +1 -1
- package/dist/openai-agents/index.cjs +1 -1
- package/dist/openai-agents/index.mjs +1 -1
- package/dist/vercel/index.cjs +11 -21
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +11 -21
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/vercel/index.mjs
CHANGED
|
@@ -395,7 +395,7 @@ function sanitizeValues(obj) {
|
|
|
395
395
|
return jsonSafe;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
var version = "8.1.
|
|
398
|
+
var version = "8.1.2";
|
|
399
399
|
|
|
400
400
|
const DEFAULT_MAX_DEPTH = 3;
|
|
401
401
|
const MAX_STACK_LINES = 20;
|
|
@@ -860,32 +860,22 @@ const extractTokenCount = value => {
|
|
|
860
860
|
}
|
|
861
861
|
return undefined;
|
|
862
862
|
};
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
// V2 style: top-level reasoningTokens
|
|
867
|
-
if ('reasoningTokens' in usage) {
|
|
868
|
-
return usage.reasoningTokens;
|
|
863
|
+
const extractUsageToken = (usage, topLevelKey, nestedObjectKey, nestedValueKey) => {
|
|
864
|
+
if (topLevelKey in usage) {
|
|
865
|
+
return usage[topLevelKey];
|
|
869
866
|
}
|
|
870
|
-
|
|
871
|
-
if (
|
|
872
|
-
return
|
|
867
|
+
const nestedTokens = usage[nestedObjectKey];
|
|
868
|
+
if (nestedTokens && typeof nestedTokens === 'object' && nestedValueKey in nestedTokens) {
|
|
869
|
+
return nestedTokens[nestedValueKey];
|
|
873
870
|
}
|
|
874
871
|
return undefined;
|
|
875
872
|
};
|
|
876
873
|
|
|
874
|
+
// Helper to extract reasoning tokens from V2 (usage.reasoningTokens) or V3 (usage.outputTokens.reasoning)
|
|
875
|
+
const extractReasoningTokens = usage => extractUsageToken(usage, 'reasoningTokens', 'outputTokens', 'reasoning');
|
|
876
|
+
|
|
877
877
|
// Helper to extract cached input tokens from V2 (usage.cachedInputTokens) or V3 (usage.inputTokens.cacheRead)
|
|
878
|
-
const extractCacheReadTokens = usage =>
|
|
879
|
-
// V2 style: top-level cachedInputTokens
|
|
880
|
-
if ('cachedInputTokens' in usage) {
|
|
881
|
-
return usage.cachedInputTokens;
|
|
882
|
-
}
|
|
883
|
-
// V3 style: nested in inputTokens.cacheRead
|
|
884
|
-
if ('inputTokens' in usage && usage.inputTokens && typeof usage.inputTokens === 'object' && 'cacheRead' in usage.inputTokens) {
|
|
885
|
-
return usage.inputTokens.cacheRead;
|
|
886
|
-
}
|
|
887
|
-
return undefined;
|
|
888
|
-
};
|
|
878
|
+
const extractCacheReadTokens = usage => extractUsageToken(usage, 'cachedInputTokens', 'inputTokens', 'cacheRead');
|
|
889
879
|
|
|
890
880
|
// Helper to extract cache write tokens from V3 (usage.inputTokens.cacheWrite). Providers like
|
|
891
881
|
// Amazon Bedrock populate this standardized field instead of providerMetadata.anthropic.
|