@posthog/ai 8.2.1 → 8.2.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 +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 +11 -1
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +11 -1
- 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.2";
|
|
534
534
|
|
|
535
535
|
const DEFAULT_MAX_DEPTH = 3;
|
|
536
536
|
const MAX_STACK_LINES = 20;
|
|
@@ -1355,6 +1355,10 @@ function preserveAPIPromiseHelpers(parentPromise, wrappedPromise) {
|
|
|
1355
1355
|
}
|
|
1356
1356
|
return apiPromise;
|
|
1357
1357
|
}
|
|
1358
|
+
const TERMINAL_RESPONSE_STATUSES = new Set(['completed', 'failed', 'cancelled', 'incomplete']);
|
|
1359
|
+
function isPendingBackgroundResponse(params, response) {
|
|
1360
|
+
return params.background === true && !response.usage && !!response.status && !TERMINAL_RESPONSE_STATUSES.has(response.status);
|
|
1361
|
+
}
|
|
1358
1362
|
class PostHogOpenAI extends OpenAI {
|
|
1359
1363
|
constructor(config) {
|
|
1360
1364
|
const {
|
|
@@ -1780,6 +1784,9 @@ class WrappedResponses extends Responses {
|
|
|
1780
1784
|
} else {
|
|
1781
1785
|
const wrappedPromise = parentPromise.then(async result => {
|
|
1782
1786
|
if ('output' in result) {
|
|
1787
|
+
if (isPendingBackgroundResponse(openAIParams, result)) {
|
|
1788
|
+
return result;
|
|
1789
|
+
}
|
|
1783
1790
|
const latency = (Date.now() - startTime) / 1000;
|
|
1784
1791
|
const availableTools = extractAvailableToolCalls('openai', openAIParams);
|
|
1785
1792
|
const formattedOutput = formatResponseOpenAI({
|
|
@@ -1848,6 +1855,9 @@ class WrappedResponses extends Responses {
|
|
|
1848
1855
|
try {
|
|
1849
1856
|
const parentPromise = super.parse(openAIParams, options);
|
|
1850
1857
|
const wrappedPromise = parentPromise.then(async result => {
|
|
1858
|
+
if (isPendingBackgroundResponse(openAIParams, result)) {
|
|
1859
|
+
return result;
|
|
1860
|
+
}
|
|
1851
1861
|
const latency = (Date.now() - startTime) / 1000;
|
|
1852
1862
|
await captureAiGeneration(this.phClient, {
|
|
1853
1863
|
...posthogParams,
|