@zenning/openai 3.0.27 → 3.0.28
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 +6 -0
- package/dist/index.js +60 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -11
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +59 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +59 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -3280,6 +3280,13 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3280
3280
|
output_index: import_v416.z.number(),
|
|
3281
3281
|
diff: import_v416.z.string()
|
|
3282
3282
|
}),
|
|
3283
|
+
import_v416.z.object({
|
|
3284
|
+
type: import_v416.z.literal("response.output_text.done"),
|
|
3285
|
+
item_id: import_v416.z.string(),
|
|
3286
|
+
output_index: import_v416.z.number(),
|
|
3287
|
+
content_index: import_v416.z.number(),
|
|
3288
|
+
text: import_v416.z.string()
|
|
3289
|
+
}),
|
|
3283
3290
|
import_v416.z.object({
|
|
3284
3291
|
type: import_v416.z.literal("error"),
|
|
3285
3292
|
sequence_number: import_v416.z.number(),
|
|
@@ -4996,6 +5003,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4996
5003
|
let hasFunctionCall = false;
|
|
4997
5004
|
const activeReasoning = {};
|
|
4998
5005
|
let serviceTier;
|
|
5006
|
+
const textEndEmitted = /* @__PURE__ */ new Set();
|
|
5007
|
+
let finishEmitted = false;
|
|
4999
5008
|
return {
|
|
5000
5009
|
stream: response.pipeThrough(
|
|
5001
5010
|
new TransformStream({
|
|
@@ -5168,20 +5177,36 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5168
5177
|
}
|
|
5169
5178
|
});
|
|
5170
5179
|
}
|
|
5180
|
+
} else if (isOutputTextDoneChunk(value)) {
|
|
5181
|
+
textEndEmitted.add(value.item_id);
|
|
5182
|
+
controller.enqueue({
|
|
5183
|
+
type: "text-end",
|
|
5184
|
+
id: value.item_id,
|
|
5185
|
+
providerMetadata: {
|
|
5186
|
+
[providerOptionsName]: {
|
|
5187
|
+
itemId: value.item_id,
|
|
5188
|
+
...ongoingAnnotations.length > 0 && {
|
|
5189
|
+
annotations: ongoingAnnotations
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
}
|
|
5193
|
+
});
|
|
5171
5194
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
5172
5195
|
if (value.item.type === "message") {
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5196
|
+
if (!textEndEmitted.has(value.item.id)) {
|
|
5197
|
+
controller.enqueue({
|
|
5198
|
+
type: "text-end",
|
|
5199
|
+
id: value.item.id,
|
|
5200
|
+
providerMetadata: {
|
|
5201
|
+
[providerOptionsName]: {
|
|
5202
|
+
itemId: value.item.id,
|
|
5203
|
+
...ongoingAnnotations.length > 0 && {
|
|
5204
|
+
annotations: ongoingAnnotations
|
|
5205
|
+
}
|
|
5181
5206
|
}
|
|
5182
5207
|
}
|
|
5183
|
-
}
|
|
5184
|
-
}
|
|
5208
|
+
});
|
|
5209
|
+
}
|
|
5185
5210
|
} else if (value.item.type === "function_call") {
|
|
5186
5211
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5187
5212
|
hasFunctionCall = true;
|
|
@@ -5584,6 +5609,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5584
5609
|
if (typeof value.response.service_tier === "string") {
|
|
5585
5610
|
serviceTier = value.response.service_tier;
|
|
5586
5611
|
}
|
|
5612
|
+
if (!finishEmitted) {
|
|
5613
|
+
finishEmitted = true;
|
|
5614
|
+
const providerMetadata = {
|
|
5615
|
+
[providerOptionsName]: {
|
|
5616
|
+
responseId,
|
|
5617
|
+
...serviceTier !== void 0 && { serviceTier }
|
|
5618
|
+
}
|
|
5619
|
+
};
|
|
5620
|
+
if (logprobs.length > 0) {
|
|
5621
|
+
providerMetadata[providerOptionsName].logprobs = logprobs;
|
|
5622
|
+
}
|
|
5623
|
+
controller.enqueue({
|
|
5624
|
+
type: "finish",
|
|
5625
|
+
finishReason,
|
|
5626
|
+
usage: convertOpenAIResponsesUsage(usage),
|
|
5627
|
+
providerMetadata
|
|
5628
|
+
});
|
|
5629
|
+
}
|
|
5587
5630
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
5588
5631
|
ongoingAnnotations.push(value.annotation);
|
|
5589
5632
|
if (value.annotation.type === "url_citation") {
|
|
@@ -5647,6 +5690,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5647
5690
|
}
|
|
5648
5691
|
},
|
|
5649
5692
|
flush(controller) {
|
|
5693
|
+
if (finishEmitted) {
|
|
5694
|
+
return;
|
|
5695
|
+
}
|
|
5650
5696
|
const providerMetadata = {
|
|
5651
5697
|
[providerOptionsName]: {
|
|
5652
5698
|
responseId
|
|
@@ -5675,6 +5721,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5675
5721
|
function isTextDeltaChunk(chunk) {
|
|
5676
5722
|
return chunk.type === "response.output_text.delta";
|
|
5677
5723
|
}
|
|
5724
|
+
function isOutputTextDoneChunk(chunk) {
|
|
5725
|
+
return chunk.type === "response.output_text.done";
|
|
5726
|
+
}
|
|
5678
5727
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
5679
5728
|
return chunk.type === "response.output_item.done";
|
|
5680
5729
|
}
|