@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/anthropic/index.cjs
CHANGED
package/dist/anthropic/index.mjs
CHANGED
package/dist/gemini/index.cjs
CHANGED
package/dist/gemini/index.mjs
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
package/dist/langchain/index.cjs
CHANGED
package/dist/langchain/index.mjs
CHANGED
package/dist/openai/index.cjs
CHANGED
|
@@ -534,7 +534,7 @@ function formatOpenAIResponsesInput(input, instructions) {
|
|
|
534
534
|
return messages;
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
-
var version = "8.2.
|
|
537
|
+
var version = "8.2.2";
|
|
538
538
|
|
|
539
539
|
const DEFAULT_MAX_DEPTH = 3;
|
|
540
540
|
const MAX_STACK_LINES = 20;
|
|
@@ -1359,6 +1359,10 @@ function preserveAPIPromiseHelpers(parentPromise, wrappedPromise) {
|
|
|
1359
1359
|
}
|
|
1360
1360
|
return apiPromise;
|
|
1361
1361
|
}
|
|
1362
|
+
const TERMINAL_RESPONSE_STATUSES = new Set(['completed', 'failed', 'cancelled', 'incomplete']);
|
|
1363
|
+
function isPendingBackgroundResponse(params, response) {
|
|
1364
|
+
return params.background === true && !response.usage && !!response.status && !TERMINAL_RESPONSE_STATUSES.has(response.status);
|
|
1365
|
+
}
|
|
1362
1366
|
class PostHogOpenAI extends openai.OpenAI {
|
|
1363
1367
|
constructor(config) {
|
|
1364
1368
|
const {
|
|
@@ -1784,6 +1788,9 @@ class WrappedResponses extends Responses {
|
|
|
1784
1788
|
} else {
|
|
1785
1789
|
const wrappedPromise = parentPromise.then(async result => {
|
|
1786
1790
|
if ('output' in result) {
|
|
1791
|
+
if (isPendingBackgroundResponse(openAIParams, result)) {
|
|
1792
|
+
return result;
|
|
1793
|
+
}
|
|
1787
1794
|
const latency = (Date.now() - startTime) / 1000;
|
|
1788
1795
|
const availableTools = extractAvailableToolCalls('openai', openAIParams);
|
|
1789
1796
|
const formattedOutput = formatResponseOpenAI({
|
|
@@ -1852,6 +1859,9 @@ class WrappedResponses extends Responses {
|
|
|
1852
1859
|
try {
|
|
1853
1860
|
const parentPromise = super.parse(openAIParams, options);
|
|
1854
1861
|
const wrappedPromise = parentPromise.then(async result => {
|
|
1862
|
+
if (isPendingBackgroundResponse(openAIParams, result)) {
|
|
1863
|
+
return result;
|
|
1864
|
+
}
|
|
1855
1865
|
const latency = (Date.now() - startTime) / 1000;
|
|
1856
1866
|
await captureAiGeneration(this.phClient, {
|
|
1857
1867
|
...posthogParams,
|