@posthog/ai 8.2.1 → 8.2.3
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 +5 -2
- package/dist/anthropic/index.cjs.map +1 -1
- package/dist/anthropic/index.mjs +5 -2
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/gemini/index.cjs +1 -1
- package/dist/gemini/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/langchain/index.cjs +1 -1
- package/dist/langchain/index.mjs +1 -1
- package/dist/openai/index.cjs +31 -6
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +31 -6
- package/dist/openai/index.mjs.map +1 -1
- package/dist/openai-agents/index.cjs +1 -1
- package/dist/openai-agents/index.mjs +1 -1
- package/dist/vercel/index.cjs +1 -1
- package/dist/vercel/index.mjs +1 -1
- package/package.json +4 -4
package/dist/openai/index.mjs
CHANGED
|
@@ -530,7 +530,7 @@ function formatOpenAIResponsesInput(input, instructions) {
|
|
|
530
530
|
return messages;
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
var version = "8.2.
|
|
533
|
+
var version = "8.2.3";
|
|
534
534
|
|
|
535
535
|
const DEFAULT_MAX_DEPTH = 3;
|
|
536
536
|
const MAX_STACK_LINES = 20;
|
|
@@ -999,7 +999,10 @@ let WrappedCompletions$1 = class WrappedCompletions extends AzureOpenAI.Chat.Com
|
|
|
999
999
|
});
|
|
1000
1000
|
throw error;
|
|
1001
1001
|
}
|
|
1002
|
-
})()
|
|
1002
|
+
})().catch(() => {
|
|
1003
|
+
// Swallow: analytics must never crash the host process. The caller
|
|
1004
|
+
// already receives this error via their own tee of the stream.
|
|
1005
|
+
});
|
|
1003
1006
|
|
|
1004
1007
|
// Return the other stream to the user
|
|
1005
1008
|
return stream2;
|
|
@@ -1158,7 +1161,10 @@ let WrappedResponses$1 = class WrappedResponses extends AzureOpenAI.Responses {
|
|
|
1158
1161
|
});
|
|
1159
1162
|
throw error;
|
|
1160
1163
|
}
|
|
1161
|
-
})()
|
|
1164
|
+
})().catch(() => {
|
|
1165
|
+
// Swallow: analytics must never crash the host process. The caller
|
|
1166
|
+
// already receives this error via their own tee of the stream.
|
|
1167
|
+
});
|
|
1162
1168
|
return stream2;
|
|
1163
1169
|
}
|
|
1164
1170
|
return value;
|
|
@@ -1355,6 +1361,10 @@ function preserveAPIPromiseHelpers(parentPromise, wrappedPromise) {
|
|
|
1355
1361
|
}
|
|
1356
1362
|
return apiPromise;
|
|
1357
1363
|
}
|
|
1364
|
+
const TERMINAL_RESPONSE_STATUSES = new Set(['completed', 'failed', 'cancelled', 'incomplete']);
|
|
1365
|
+
function isPendingBackgroundResponse(params, response) {
|
|
1366
|
+
return params.background === true && !response.usage && !!response.status && !TERMINAL_RESPONSE_STATUSES.has(response.status);
|
|
1367
|
+
}
|
|
1358
1368
|
class PostHogOpenAI extends OpenAI {
|
|
1359
1369
|
constructor(config) {
|
|
1360
1370
|
const {
|
|
@@ -1583,7 +1593,10 @@ class WrappedCompletions extends Completions {
|
|
|
1583
1593
|
});
|
|
1584
1594
|
throw error;
|
|
1585
1595
|
}
|
|
1586
|
-
})()
|
|
1596
|
+
})().catch(() => {
|
|
1597
|
+
// Swallow: analytics must never crash the host process. The caller
|
|
1598
|
+
// already receives this error via their own tee of the stream.
|
|
1599
|
+
});
|
|
1587
1600
|
|
|
1588
1601
|
// Return the other stream to the user
|
|
1589
1602
|
return stream2;
|
|
@@ -1771,7 +1784,10 @@ class WrappedResponses extends Responses {
|
|
|
1771
1784
|
});
|
|
1772
1785
|
throw error;
|
|
1773
1786
|
}
|
|
1774
|
-
})()
|
|
1787
|
+
})().catch(() => {
|
|
1788
|
+
// Swallow: analytics must never crash the host process. The caller
|
|
1789
|
+
// already receives this error via their own tee of the stream.
|
|
1790
|
+
});
|
|
1775
1791
|
return stream2;
|
|
1776
1792
|
}
|
|
1777
1793
|
return value;
|
|
@@ -1780,6 +1796,9 @@ class WrappedResponses extends Responses {
|
|
|
1780
1796
|
} else {
|
|
1781
1797
|
const wrappedPromise = parentPromise.then(async result => {
|
|
1782
1798
|
if ('output' in result) {
|
|
1799
|
+
if (isPendingBackgroundResponse(openAIParams, result)) {
|
|
1800
|
+
return result;
|
|
1801
|
+
}
|
|
1783
1802
|
const latency = (Date.now() - startTime) / 1000;
|
|
1784
1803
|
const availableTools = extractAvailableToolCalls('openai', openAIParams);
|
|
1785
1804
|
const formattedOutput = formatResponseOpenAI({
|
|
@@ -1848,6 +1867,9 @@ class WrappedResponses extends Responses {
|
|
|
1848
1867
|
try {
|
|
1849
1868
|
const parentPromise = super.parse(openAIParams, options);
|
|
1850
1869
|
const wrappedPromise = parentPromise.then(async result => {
|
|
1870
|
+
if (isPendingBackgroundResponse(openAIParams, result)) {
|
|
1871
|
+
return result;
|
|
1872
|
+
}
|
|
1851
1873
|
const latency = (Date.now() - startTime) / 1000;
|
|
1852
1874
|
await captureAiGeneration(this.phClient, {
|
|
1853
1875
|
...posthogParams,
|
|
@@ -2054,7 +2076,10 @@ class WrappedTranscriptions extends Transcriptions {
|
|
|
2054
2076
|
});
|
|
2055
2077
|
throw error;
|
|
2056
2078
|
}
|
|
2057
|
-
})()
|
|
2079
|
+
})().catch(() => {
|
|
2080
|
+
// Swallow: analytics must never crash the host process. The caller
|
|
2081
|
+
// already receives this error via their own tee of the stream.
|
|
2082
|
+
});
|
|
2058
2083
|
return stream2;
|
|
2059
2084
|
}
|
|
2060
2085
|
return value;
|