@posthog/ai 8.6.8 → 8.7.0
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 +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +11 -1
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +1 -1
- package/dist/langchain/index.mjs +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/otel/index.cjs +9 -3
- package/dist/otel/index.cjs.map +1 -1
- package/dist/otel/index.d.ts +9 -3
- package/dist/otel/index.mjs +9 -3
- package/dist/otel/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +11 -1
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +11 -1
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/vercel/index.mjs
CHANGED
|
@@ -406,7 +406,7 @@ function sanitizeValues(obj) {
|
|
|
406
406
|
return jsonSafe;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
var version = "8.
|
|
409
|
+
var version = "8.7.0";
|
|
410
410
|
|
|
411
411
|
const DEFAULT_MAX_DEPTH = 3;
|
|
412
412
|
const MAX_STACK_LINES = 20;
|
|
@@ -655,6 +655,12 @@ const captureAiGeneration = async (client, options) => {
|
|
|
655
655
|
function isV3Model(model) {
|
|
656
656
|
return model.specificationVersion === 'v3';
|
|
657
657
|
}
|
|
658
|
+
function getSpecificationVersion(model) {
|
|
659
|
+
if (typeof model === 'object' && model !== null && 'specificationVersion' in model) {
|
|
660
|
+
return model.specificationVersion;
|
|
661
|
+
}
|
|
662
|
+
return undefined;
|
|
663
|
+
}
|
|
658
664
|
|
|
659
665
|
// Content types for the output array
|
|
660
666
|
|
|
@@ -997,6 +1003,10 @@ const adjustAnthropicV3CacheTokens = (model, modelId, provider, usage) => {
|
|
|
997
1003
|
* Automatically detects the model version and applies appropriate instrumentation.
|
|
998
1004
|
*/
|
|
999
1005
|
const wrapVercelLanguageModel = (model, phClient, options) => {
|
|
1006
|
+
const specificationVersion = getSpecificationVersion(model);
|
|
1007
|
+
if (specificationVersion !== 'v2' && specificationVersion !== 'v3') {
|
|
1008
|
+
throw new Error(`[PostHog AI] withTracing supports Vercel AI SDK v5 and v6 models only. ` + `Use @ai-sdk/otel with @posthog/ai/otel for AI SDK v7 models.`);
|
|
1009
|
+
}
|
|
1000
1010
|
const traceId = options.posthogTraceId ?? v4();
|
|
1001
1011
|
const mergedOptions = {
|
|
1002
1012
|
...options,
|