@ai-sdk/openai 2.0.0-alpha.11 → 2.0.0-alpha.13
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 +18 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +27 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +27 -0
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -676,6 +676,9 @@ var OpenAIChatLanguageModel = class {
|
|
|
676
676
|
},
|
|
677
677
|
transform(chunk, controller) {
|
|
678
678
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
679
|
+
if (options.includeRawChunks) {
|
|
680
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
681
|
+
}
|
|
679
682
|
if (!chunk.success) {
|
|
680
683
|
finishReason = "error";
|
|
681
684
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -1255,6 +1258,9 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1255
1258
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1256
1259
|
},
|
|
1257
1260
|
transform(chunk, controller) {
|
|
1261
|
+
if (options.includeRawChunks) {
|
|
1262
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1263
|
+
}
|
|
1258
1264
|
if (!chunk.success) {
|
|
1259
1265
|
finishReason = "error";
|
|
1260
1266
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -2346,6 +2352,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2346
2352
|
let responseId = null;
|
|
2347
2353
|
const ongoingToolCalls = {};
|
|
2348
2354
|
let hasToolCalls = false;
|
|
2355
|
+
let lastReasoningSummaryIndex = null;
|
|
2349
2356
|
return {
|
|
2350
2357
|
stream: response.pipeThrough(
|
|
2351
2358
|
new TransformStream({
|
|
@@ -2354,6 +2361,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2354
2361
|
},
|
|
2355
2362
|
transform(chunk, controller) {
|
|
2356
2363
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2364
|
+
if (options.includeRawChunks) {
|
|
2365
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2366
|
+
}
|
|
2357
2367
|
if (!chunk.success) {
|
|
2358
2368
|
finishReason = "error";
|
|
2359
2369
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -2399,10 +2409,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2399
2409
|
text: value.delta
|
|
2400
2410
|
});
|
|
2401
2411
|
} else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
|
|
2412
|
+
if (lastReasoningSummaryIndex !== null && value.summary_index !== lastReasoningSummaryIndex) {
|
|
2413
|
+
controller.enqueue({ type: "reasoning-part-finish" });
|
|
2414
|
+
}
|
|
2415
|
+
lastReasoningSummaryIndex = value.summary_index;
|
|
2402
2416
|
controller.enqueue({
|
|
2403
2417
|
type: "reasoning",
|
|
2404
2418
|
text: value.delta
|
|
2405
2419
|
});
|
|
2420
|
+
} else if (isResponseReasoningSummaryPartDoneChunk(value)) {
|
|
2421
|
+
controller.enqueue({ type: "reasoning-part-finish" });
|
|
2406
2422
|
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
|
|
2407
2423
|
ongoingToolCalls[value.output_index] = void 0;
|
|
2408
2424
|
hasToolCalls = true;
|
|
@@ -2531,6 +2547,13 @@ var responseReasoningSummaryTextDeltaSchema = import_zod12.z.object({
|
|
|
2531
2547
|
summary_index: import_zod12.z.number(),
|
|
2532
2548
|
delta: import_zod12.z.string()
|
|
2533
2549
|
});
|
|
2550
|
+
var responseReasoningSummaryPartDoneSchema = import_zod12.z.object({
|
|
2551
|
+
type: import_zod12.z.literal("response.reasoning_summary_part.done"),
|
|
2552
|
+
item_id: import_zod12.z.string(),
|
|
2553
|
+
output_index: import_zod12.z.number(),
|
|
2554
|
+
summary_index: import_zod12.z.number(),
|
|
2555
|
+
part: import_zod12.z.unknown().nullish()
|
|
2556
|
+
});
|
|
2534
2557
|
var openaiResponsesChunkSchema = import_zod12.z.union([
|
|
2535
2558
|
textDeltaChunkSchema,
|
|
2536
2559
|
responseFinishedChunkSchema,
|
|
@@ -2540,6 +2563,7 @@ var openaiResponsesChunkSchema = import_zod12.z.union([
|
|
|
2540
2563
|
responseOutputItemAddedSchema,
|
|
2541
2564
|
responseAnnotationAddedSchema,
|
|
2542
2565
|
responseReasoningSummaryTextDeltaSchema,
|
|
2566
|
+
responseReasoningSummaryPartDoneSchema,
|
|
2543
2567
|
import_zod12.z.object({ type: import_zod12.z.string() }).passthrough()
|
|
2544
2568
|
// fallback for unknown chunks
|
|
2545
2569
|
]);
|
|
@@ -2567,6 +2591,9 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
2567
2591
|
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
2568
2592
|
return chunk.type === "response.reasoning_summary_text.delta";
|
|
2569
2593
|
}
|
|
2594
|
+
function isResponseReasoningSummaryPartDoneChunk(chunk) {
|
|
2595
|
+
return chunk.type === "response.reasoning_summary_part.done";
|
|
2596
|
+
}
|
|
2570
2597
|
function getResponsesModelConfig(modelId) {
|
|
2571
2598
|
if (modelId.startsWith("o")) {
|
|
2572
2599
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|