@posthog/ai 8.6.0 → 8.6.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 +10 -5
- package/dist/anthropic/index.cjs.map +1 -1
- package/dist/anthropic/index.mjs +11 -6
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/gemini/index.cjs +10 -5
- package/dist/gemini/index.cjs.map +1 -1
- package/dist/gemini/index.mjs +11 -6
- package/dist/gemini/index.mjs.map +1 -1
- package/dist/index.cjs +126 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +127 -79
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +31 -32
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +31 -32
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/openai/index.cjs +10 -5
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +11 -6
- package/dist/openai/index.mjs.map +1 -1
- package/dist/openai-agents/index.cjs +24 -4
- package/dist/openai-agents/index.cjs.map +1 -1
- package/dist/openai-agents/index.d.ts +1 -1
- package/dist/openai-agents/index.mjs +24 -4
- package/dist/openai-agents/index.mjs.map +1 -1
- package/dist/otel/index.cjs +5 -3
- package/dist/otel/index.cjs.map +1 -1
- package/dist/otel/index.mjs +5 -3
- package/dist/otel/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +127 -81
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +128 -82
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/openai/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AzureOpenAI, OpenAI } from 'openai';
|
|
2
2
|
import { v4 } from 'uuid';
|
|
3
|
-
import { uuidv7 } from '@posthog/core';
|
|
3
|
+
import { toJsonSafeValue, uuidv7 } from '@posthog/core';
|
|
4
4
|
|
|
5
5
|
// Type guards for safer type checking
|
|
6
6
|
|
|
@@ -533,7 +533,7 @@ function formatOpenAIResponsesInput(input, instructions) {
|
|
|
533
533
|
return messages;
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
var version = "8.6.
|
|
536
|
+
var version = "8.6.2";
|
|
537
537
|
|
|
538
538
|
const DEFAULT_MAX_DEPTH = 3;
|
|
539
539
|
const MAX_STACK_LINES = 20;
|
|
@@ -652,8 +652,13 @@ const captureAiGeneration$1 = async (client, options) => {
|
|
|
652
652
|
const eventType = options.eventType ?? AIEvent.Generation;
|
|
653
653
|
const privacyMode = options.privacyMode ?? false;
|
|
654
654
|
const usage = options.usage ?? {};
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
|
|
656
|
+
// Check privacy before reading or traversing input/output. Besides avoiding
|
|
657
|
+
// needless work, this ensures hostile getters/proxies cannot observe a value
|
|
658
|
+
// that the caller explicitly requested us to redact.
|
|
659
|
+
const shouldRedact = withPrivacyMode(client, privacyMode, false) === null;
|
|
660
|
+
const safeInput = shouldRedact ? null : toJsonSafeValue(options.input);
|
|
661
|
+
const safeOutput = shouldRedact ? null : toJsonSafeValue(options.output);
|
|
657
662
|
let httpStatus = options.httpStatus;
|
|
658
663
|
let errorData = {};
|
|
659
664
|
if (options.error) {
|
|
@@ -714,8 +719,8 @@ const captureAiGeneration$1 = async (client, options) => {
|
|
|
714
719
|
$ai_provider: options.providerOverride ?? options.provider,
|
|
715
720
|
$ai_model: options.modelOverride ?? options.model,
|
|
716
721
|
$ai_model_parameters: options.modelParameters ?? {},
|
|
717
|
-
$ai_input:
|
|
718
|
-
$ai_output_choices:
|
|
722
|
+
$ai_input: safeInput,
|
|
723
|
+
$ai_output_choices: safeOutput,
|
|
719
724
|
$ai_http_status: httpStatus,
|
|
720
725
|
$ai_input_tokens: usage.inputTokens ?? 0,
|
|
721
726
|
...(usage.outputTokens !== undefined ? {
|