@zenning/openai 3.0.27 → 3.0.29
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/CHANGELOG.md +15 -0
- package/dist/index.js +74 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -11
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +73 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +73 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/internal/index.mjs
CHANGED
|
@@ -3210,6 +3210,11 @@ var openaiResponsesChunkSchema = lazySchema14(
|
|
|
3210
3210
|
action: z16.object({
|
|
3211
3211
|
commands: z16.array(z16.string())
|
|
3212
3212
|
})
|
|
3213
|
+
}),
|
|
3214
|
+
z16.object({
|
|
3215
|
+
type: z16.literal("compaction"),
|
|
3216
|
+
id: z16.string(),
|
|
3217
|
+
encrypted_content: z16.string()
|
|
3213
3218
|
})
|
|
3214
3219
|
])
|
|
3215
3220
|
}),
|
|
@@ -3301,6 +3306,13 @@ var openaiResponsesChunkSchema = lazySchema14(
|
|
|
3301
3306
|
output_index: z16.number(),
|
|
3302
3307
|
diff: z16.string()
|
|
3303
3308
|
}),
|
|
3309
|
+
z16.object({
|
|
3310
|
+
type: z16.literal("response.output_text.done"),
|
|
3311
|
+
item_id: z16.string(),
|
|
3312
|
+
output_index: z16.number(),
|
|
3313
|
+
content_index: z16.number(),
|
|
3314
|
+
text: z16.string()
|
|
3315
|
+
}),
|
|
3304
3316
|
z16.object({
|
|
3305
3317
|
type: z16.literal("error"),
|
|
3306
3318
|
sequence_number: z16.number(),
|
|
@@ -5043,6 +5055,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5043
5055
|
let hasFunctionCall = false;
|
|
5044
5056
|
const activeReasoning = {};
|
|
5045
5057
|
let serviceTier;
|
|
5058
|
+
const textEndEmitted = /* @__PURE__ */ new Set();
|
|
5059
|
+
let finishEmitted = false;
|
|
5046
5060
|
return {
|
|
5047
5061
|
stream: response.pipeThrough(
|
|
5048
5062
|
new TransformStream({
|
|
@@ -5215,20 +5229,36 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5215
5229
|
}
|
|
5216
5230
|
});
|
|
5217
5231
|
}
|
|
5232
|
+
} else if (isOutputTextDoneChunk(value)) {
|
|
5233
|
+
textEndEmitted.add(value.item_id);
|
|
5234
|
+
controller.enqueue({
|
|
5235
|
+
type: "text-end",
|
|
5236
|
+
id: value.item_id,
|
|
5237
|
+
providerMetadata: {
|
|
5238
|
+
[providerOptionsName]: {
|
|
5239
|
+
itemId: value.item_id,
|
|
5240
|
+
...ongoingAnnotations.length > 0 && {
|
|
5241
|
+
annotations: ongoingAnnotations
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5244
|
+
}
|
|
5245
|
+
});
|
|
5218
5246
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
5219
5247
|
if (value.item.type === "message") {
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5248
|
+
if (!textEndEmitted.has(value.item.id)) {
|
|
5249
|
+
controller.enqueue({
|
|
5250
|
+
type: "text-end",
|
|
5251
|
+
id: value.item.id,
|
|
5252
|
+
providerMetadata: {
|
|
5253
|
+
[providerOptionsName]: {
|
|
5254
|
+
itemId: value.item.id,
|
|
5255
|
+
...ongoingAnnotations.length > 0 && {
|
|
5256
|
+
annotations: ongoingAnnotations
|
|
5257
|
+
}
|
|
5228
5258
|
}
|
|
5229
5259
|
}
|
|
5230
|
-
}
|
|
5231
|
-
}
|
|
5260
|
+
});
|
|
5261
|
+
}
|
|
5232
5262
|
} else if (value.item.type === "function_call") {
|
|
5233
5263
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5234
5264
|
hasFunctionCall = true;
|
|
@@ -5465,6 +5495,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5465
5495
|
});
|
|
5466
5496
|
}
|
|
5467
5497
|
delete activeReasoning[value.item.id];
|
|
5498
|
+
} else if (value.item.type === "compaction") {
|
|
5499
|
+
controller.enqueue({
|
|
5500
|
+
type: "compaction",
|
|
5501
|
+
id: value.item.id,
|
|
5502
|
+
encrypted_content: value.item.encrypted_content,
|
|
5503
|
+
providerMetadata: {
|
|
5504
|
+
[providerOptionsName]: { itemId: value.item.id }
|
|
5505
|
+
}
|
|
5506
|
+
});
|
|
5468
5507
|
}
|
|
5469
5508
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
5470
5509
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
@@ -5631,6 +5670,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5631
5670
|
if (typeof value.response.service_tier === "string") {
|
|
5632
5671
|
serviceTier = value.response.service_tier;
|
|
5633
5672
|
}
|
|
5673
|
+
if (!finishEmitted) {
|
|
5674
|
+
finishEmitted = true;
|
|
5675
|
+
const providerMetadata = {
|
|
5676
|
+
[providerOptionsName]: {
|
|
5677
|
+
responseId,
|
|
5678
|
+
...serviceTier !== void 0 && { serviceTier }
|
|
5679
|
+
}
|
|
5680
|
+
};
|
|
5681
|
+
if (logprobs.length > 0) {
|
|
5682
|
+
providerMetadata[providerOptionsName].logprobs = logprobs;
|
|
5683
|
+
}
|
|
5684
|
+
controller.enqueue({
|
|
5685
|
+
type: "finish",
|
|
5686
|
+
finishReason,
|
|
5687
|
+
usage: convertOpenAIResponsesUsage(usage),
|
|
5688
|
+
providerMetadata
|
|
5689
|
+
});
|
|
5690
|
+
}
|
|
5634
5691
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
5635
5692
|
ongoingAnnotations.push(value.annotation);
|
|
5636
5693
|
if (value.annotation.type === "url_citation") {
|
|
@@ -5694,6 +5751,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5694
5751
|
}
|
|
5695
5752
|
},
|
|
5696
5753
|
flush(controller) {
|
|
5754
|
+
if (finishEmitted) {
|
|
5755
|
+
return;
|
|
5756
|
+
}
|
|
5697
5757
|
const providerMetadata = {
|
|
5698
5758
|
[providerOptionsName]: {
|
|
5699
5759
|
responseId
|
|
@@ -5722,6 +5782,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5722
5782
|
function isTextDeltaChunk(chunk) {
|
|
5723
5783
|
return chunk.type === "response.output_text.delta";
|
|
5724
5784
|
}
|
|
5785
|
+
function isOutputTextDoneChunk(chunk) {
|
|
5786
|
+
return chunk.type === "response.output_text.done";
|
|
5787
|
+
}
|
|
5725
5788
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
5726
5789
|
return chunk.type === "response.output_item.done";
|
|
5727
5790
|
}
|