@zenning/openai 3.0.26 → 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/LICENSE +13 -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 +21 -21
package/dist/index.mjs
CHANGED
|
@@ -3357,6 +3357,13 @@ var openaiResponsesChunkSchema = lazySchema17(
|
|
|
3357
3357
|
output_index: z19.number(),
|
|
3358
3358
|
diff: z19.string()
|
|
3359
3359
|
}),
|
|
3360
|
+
z19.object({
|
|
3361
|
+
type: z19.literal("response.output_text.done"),
|
|
3362
|
+
item_id: z19.string(),
|
|
3363
|
+
output_index: z19.number(),
|
|
3364
|
+
content_index: z19.number(),
|
|
3365
|
+
text: z19.string()
|
|
3366
|
+
}),
|
|
3360
3367
|
z19.object({
|
|
3361
3368
|
type: z19.literal("error"),
|
|
3362
3369
|
sequence_number: z19.number(),
|
|
@@ -4783,6 +4790,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4783
4790
|
let hasFunctionCall = false;
|
|
4784
4791
|
const activeReasoning = {};
|
|
4785
4792
|
let serviceTier;
|
|
4793
|
+
const textEndEmitted = /* @__PURE__ */ new Set();
|
|
4794
|
+
let finishEmitted = false;
|
|
4786
4795
|
return {
|
|
4787
4796
|
stream: response.pipeThrough(
|
|
4788
4797
|
new TransformStream({
|
|
@@ -4955,20 +4964,36 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4955
4964
|
}
|
|
4956
4965
|
});
|
|
4957
4966
|
}
|
|
4967
|
+
} else if (isOutputTextDoneChunk(value)) {
|
|
4968
|
+
textEndEmitted.add(value.item_id);
|
|
4969
|
+
controller.enqueue({
|
|
4970
|
+
type: "text-end",
|
|
4971
|
+
id: value.item_id,
|
|
4972
|
+
providerMetadata: {
|
|
4973
|
+
[providerOptionsName]: {
|
|
4974
|
+
itemId: value.item_id,
|
|
4975
|
+
...ongoingAnnotations.length > 0 && {
|
|
4976
|
+
annotations: ongoingAnnotations
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4980
|
+
});
|
|
4958
4981
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
4959
4982
|
if (value.item.type === "message") {
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4983
|
+
if (!textEndEmitted.has(value.item.id)) {
|
|
4984
|
+
controller.enqueue({
|
|
4985
|
+
type: "text-end",
|
|
4986
|
+
id: value.item.id,
|
|
4987
|
+
providerMetadata: {
|
|
4988
|
+
[providerOptionsName]: {
|
|
4989
|
+
itemId: value.item.id,
|
|
4990
|
+
...ongoingAnnotations.length > 0 && {
|
|
4991
|
+
annotations: ongoingAnnotations
|
|
4992
|
+
}
|
|
4968
4993
|
}
|
|
4969
4994
|
}
|
|
4970
|
-
}
|
|
4971
|
-
}
|
|
4995
|
+
});
|
|
4996
|
+
}
|
|
4972
4997
|
} else if (value.item.type === "function_call") {
|
|
4973
4998
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4974
4999
|
hasFunctionCall = true;
|
|
@@ -5371,6 +5396,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5371
5396
|
if (typeof value.response.service_tier === "string") {
|
|
5372
5397
|
serviceTier = value.response.service_tier;
|
|
5373
5398
|
}
|
|
5399
|
+
if (!finishEmitted) {
|
|
5400
|
+
finishEmitted = true;
|
|
5401
|
+
const providerMetadata = {
|
|
5402
|
+
[providerOptionsName]: {
|
|
5403
|
+
responseId,
|
|
5404
|
+
...serviceTier !== void 0 && { serviceTier }
|
|
5405
|
+
}
|
|
5406
|
+
};
|
|
5407
|
+
if (logprobs.length > 0) {
|
|
5408
|
+
providerMetadata[providerOptionsName].logprobs = logprobs;
|
|
5409
|
+
}
|
|
5410
|
+
controller.enqueue({
|
|
5411
|
+
type: "finish",
|
|
5412
|
+
finishReason,
|
|
5413
|
+
usage: convertOpenAIResponsesUsage(usage),
|
|
5414
|
+
providerMetadata
|
|
5415
|
+
});
|
|
5416
|
+
}
|
|
5374
5417
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
5375
5418
|
ongoingAnnotations.push(value.annotation);
|
|
5376
5419
|
if (value.annotation.type === "url_citation") {
|
|
@@ -5434,6 +5477,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5434
5477
|
}
|
|
5435
5478
|
},
|
|
5436
5479
|
flush(controller) {
|
|
5480
|
+
if (finishEmitted) {
|
|
5481
|
+
return;
|
|
5482
|
+
}
|
|
5437
5483
|
const providerMetadata = {
|
|
5438
5484
|
[providerOptionsName]: {
|
|
5439
5485
|
responseId
|
|
@@ -5462,6 +5508,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5462
5508
|
function isTextDeltaChunk(chunk) {
|
|
5463
5509
|
return chunk.type === "response.output_text.delta";
|
|
5464
5510
|
}
|
|
5511
|
+
function isOutputTextDoneChunk(chunk) {
|
|
5512
|
+
return chunk.type === "response.output_text.done";
|
|
5513
|
+
}
|
|
5465
5514
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
5466
5515
|
return chunk.type === "response.output_item.done";
|
|
5467
5516
|
}
|
|
@@ -5888,7 +5937,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5888
5937
|
};
|
|
5889
5938
|
|
|
5890
5939
|
// src/version.ts
|
|
5891
|
-
var VERSION = true ? "3.0.
|
|
5940
|
+
var VERSION = true ? "3.0.28" : "0.0.0-test";
|
|
5892
5941
|
|
|
5893
5942
|
// src/openai-provider.ts
|
|
5894
5943
|
function createOpenAI(options = {}) {
|