@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/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
|
@@ -552,7 +552,7 @@ function formatOpenAIResponsesInput(input, instructions) {
|
|
|
552
552
|
}
|
|
553
553
|
//#endregion
|
|
554
554
|
//#region package.json
|
|
555
|
-
var version = "8.
|
|
555
|
+
var version = "8.17.0";
|
|
556
556
|
//#endregion
|
|
557
557
|
//#region src/serializeError.ts
|
|
558
558
|
const DEFAULT_MAX_DEPTH = 3;
|
|
@@ -1307,8 +1307,8 @@ var OpenAIChatStreamAccumulator = class {
|
|
|
1307
1307
|
if (Array.isArray(choice?.delta?.tool_calls)) {
|
|
1308
1308
|
this.firstTokenTime ??= receivedAt;
|
|
1309
1309
|
for (const toolCall of choice.delta.tool_calls) {
|
|
1310
|
-
|
|
1311
|
-
const current = this.toolCalls.get(
|
|
1310
|
+
const key = this.toolCallKey(toolCall);
|
|
1311
|
+
const current = this.toolCalls.get(key) ?? {
|
|
1312
1312
|
id: "",
|
|
1313
1313
|
name: "",
|
|
1314
1314
|
arguments: ""
|
|
@@ -1316,7 +1316,8 @@ var OpenAIChatStreamAccumulator = class {
|
|
|
1316
1316
|
if (toolCall.id) current.id = toolCall.id;
|
|
1317
1317
|
if (toolCall.function?.name) current.name = toolCall.function.name;
|
|
1318
1318
|
if (toolCall.function?.arguments) current.arguments += toolCall.function.arguments;
|
|
1319
|
-
this.toolCalls.set(
|
|
1319
|
+
this.toolCalls.set(key, current);
|
|
1320
|
+
this.lastToolCallKey = key;
|
|
1320
1321
|
}
|
|
1321
1322
|
}
|
|
1322
1323
|
if (chunk.usage) this.usage = {
|
|
@@ -1329,6 +1330,18 @@ var OpenAIChatStreamAccumulator = class {
|
|
|
1329
1330
|
rawUsage: chunk.usage
|
|
1330
1331
|
};
|
|
1331
1332
|
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Some OpenAI-compatible providers stream tool calls without an `index`. Match those deltas by a known
|
|
1335
|
+
* `id`; a new `id` or a function name opens a new call, and anything else continues the latest call.
|
|
1336
|
+
*/
|
|
1337
|
+
toolCallKey(toolCall) {
|
|
1338
|
+
if (toolCall.index !== void 0) return toolCall.index;
|
|
1339
|
+
if (toolCall.id) {
|
|
1340
|
+
for (const [key, existing] of this.toolCalls) if (existing.id === toolCall.id) return key;
|
|
1341
|
+
}
|
|
1342
|
+
if (toolCall.id || toolCall.function?.name || this.lastToolCallKey === void 0) return `no-index-${this.toolCalls.size}`;
|
|
1343
|
+
return this.lastToolCallKey;
|
|
1344
|
+
}
|
|
1332
1345
|
result() {
|
|
1333
1346
|
const content = [];
|
|
1334
1347
|
if (this.accumulatedContent) content.push({
|