@posthog/ai 8.16.2 → 8.17.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/README.md +8 -0
- package/dist/adk/index.cjs +1 -1
- package/dist/adk/index.mjs +1 -1
- package/dist/anthropic/index.cjs +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/claude-agent-sdk/index.cjs +1 -1
- package/dist/claude-agent-sdk/index.mjs +1 -1
- package/dist/evaluations/index.cjs +2 -0
- package/dist/evaluations/index.cjs.map +1 -1
- package/dist/evaluations/index.d.ts +3 -0
- package/dist/evaluations/index.mjs +2 -0
- package/dist/evaluations/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/langchain/middleware/index.cjs +1 -1
- package/dist/langchain/middleware/index.mjs +1 -1
- package/dist/openai/index.cjs +17 -4
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +17 -4
- 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 +2 -2
package/dist/openai/index.mjs
CHANGED
|
@@ -548,7 +548,7 @@ function formatOpenAIResponsesInput(input, instructions) {
|
|
|
548
548
|
}
|
|
549
549
|
//#endregion
|
|
550
550
|
//#region package.json
|
|
551
|
-
var version = "8.
|
|
551
|
+
var version = "8.17.0";
|
|
552
552
|
//#endregion
|
|
553
553
|
//#region src/serializeError.ts
|
|
554
554
|
const DEFAULT_MAX_DEPTH = 3;
|
|
@@ -1303,8 +1303,8 @@ var OpenAIChatStreamAccumulator = class {
|
|
|
1303
1303
|
if (Array.isArray(choice?.delta?.tool_calls)) {
|
|
1304
1304
|
this.firstTokenTime ??= receivedAt;
|
|
1305
1305
|
for (const toolCall of choice.delta.tool_calls) {
|
|
1306
|
-
|
|
1307
|
-
const current = this.toolCalls.get(
|
|
1306
|
+
const key = this.toolCallKey(toolCall);
|
|
1307
|
+
const current = this.toolCalls.get(key) ?? {
|
|
1308
1308
|
id: "",
|
|
1309
1309
|
name: "",
|
|
1310
1310
|
arguments: ""
|
|
@@ -1312,7 +1312,8 @@ var OpenAIChatStreamAccumulator = class {
|
|
|
1312
1312
|
if (toolCall.id) current.id = toolCall.id;
|
|
1313
1313
|
if (toolCall.function?.name) current.name = toolCall.function.name;
|
|
1314
1314
|
if (toolCall.function?.arguments) current.arguments += toolCall.function.arguments;
|
|
1315
|
-
this.toolCalls.set(
|
|
1315
|
+
this.toolCalls.set(key, current);
|
|
1316
|
+
this.lastToolCallKey = key;
|
|
1316
1317
|
}
|
|
1317
1318
|
}
|
|
1318
1319
|
if (chunk.usage) this.usage = {
|
|
@@ -1325,6 +1326,18 @@ var OpenAIChatStreamAccumulator = class {
|
|
|
1325
1326
|
rawUsage: chunk.usage
|
|
1326
1327
|
};
|
|
1327
1328
|
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Some OpenAI-compatible providers stream tool calls without an `index`. Match those deltas by a known
|
|
1331
|
+
* `id`; a new `id` or a function name opens a new call, and anything else continues the latest call.
|
|
1332
|
+
*/
|
|
1333
|
+
toolCallKey(toolCall) {
|
|
1334
|
+
if (toolCall.index !== void 0) return toolCall.index;
|
|
1335
|
+
if (toolCall.id) {
|
|
1336
|
+
for (const [key, existing] of this.toolCalls) if (existing.id === toolCall.id) return key;
|
|
1337
|
+
}
|
|
1338
|
+
if (toolCall.id || toolCall.function?.name || this.lastToolCallKey === void 0) return `no-index-${this.toolCalls.size}`;
|
|
1339
|
+
return this.lastToolCallKey;
|
|
1340
|
+
}
|
|
1328
1341
|
result() {
|
|
1329
1342
|
const content = [];
|
|
1330
1343
|
if (this.accumulatedContent) content.push({
|