@ai-sdk/openai 3.0.0-beta.50 → 3.0.0-beta.51
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 +103 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +102 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +102 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -2640,6 +2640,20 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2640
2640
|
start_index: import_v416.z.number().nullish(),
|
|
2641
2641
|
end_index: import_v416.z.number().nullish(),
|
|
2642
2642
|
quote: import_v416.z.string().nullish()
|
|
2643
|
+
}),
|
|
2644
|
+
import_v416.z.object({
|
|
2645
|
+
type: import_v416.z.literal("container_file_citation"),
|
|
2646
|
+
container_id: import_v416.z.string(),
|
|
2647
|
+
file_id: import_v416.z.string(),
|
|
2648
|
+
filename: import_v416.z.string().nullish(),
|
|
2649
|
+
start_index: import_v416.z.number().nullish(),
|
|
2650
|
+
end_index: import_v416.z.number().nullish(),
|
|
2651
|
+
index: import_v416.z.number().nullish()
|
|
2652
|
+
}),
|
|
2653
|
+
import_v416.z.object({
|
|
2654
|
+
type: import_v416.z.literal("file_path"),
|
|
2655
|
+
file_id: import_v416.z.string(),
|
|
2656
|
+
index: import_v416.z.number().nullish()
|
|
2643
2657
|
})
|
|
2644
2658
|
])
|
|
2645
2659
|
}),
|
|
@@ -2725,7 +2739,18 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2725
2739
|
quote: import_v416.z.string().nullish()
|
|
2726
2740
|
}),
|
|
2727
2741
|
import_v416.z.object({
|
|
2728
|
-
type: import_v416.z.literal("container_file_citation")
|
|
2742
|
+
type: import_v416.z.literal("container_file_citation"),
|
|
2743
|
+
container_id: import_v416.z.string(),
|
|
2744
|
+
file_id: import_v416.z.string(),
|
|
2745
|
+
filename: import_v416.z.string().nullish(),
|
|
2746
|
+
start_index: import_v416.z.number().nullish(),
|
|
2747
|
+
end_index: import_v416.z.number().nullish(),
|
|
2748
|
+
index: import_v416.z.number().nullish()
|
|
2749
|
+
}),
|
|
2750
|
+
import_v416.z.object({
|
|
2751
|
+
type: import_v416.z.literal("file_path"),
|
|
2752
|
+
file_id: import_v416.z.string(),
|
|
2753
|
+
index: import_v416.z.number().nullish()
|
|
2729
2754
|
})
|
|
2730
2755
|
])
|
|
2731
2756
|
)
|
|
@@ -3307,7 +3332,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3307
3332
|
};
|
|
3308
3333
|
}
|
|
3309
3334
|
async doGenerate(options) {
|
|
3310
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
3335
|
+
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, _y, _z, _A, _B;
|
|
3311
3336
|
const {
|
|
3312
3337
|
args: body,
|
|
3313
3338
|
warnings,
|
|
@@ -3405,13 +3430,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3405
3430
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
3406
3431
|
logprobs.push(contentPart.logprobs);
|
|
3407
3432
|
}
|
|
3433
|
+
const providerMetadata2 = {
|
|
3434
|
+
itemId: part.id,
|
|
3435
|
+
...contentPart.annotations.length > 0 && {
|
|
3436
|
+
annotations: contentPart.annotations
|
|
3437
|
+
}
|
|
3438
|
+
};
|
|
3408
3439
|
content.push({
|
|
3409
3440
|
type: "text",
|
|
3410
3441
|
text: contentPart.text,
|
|
3411
3442
|
providerMetadata: {
|
|
3412
|
-
openai:
|
|
3413
|
-
itemId: part.id
|
|
3414
|
-
}
|
|
3443
|
+
openai: providerMetadata2
|
|
3415
3444
|
}
|
|
3416
3445
|
});
|
|
3417
3446
|
for (const annotation of contentPart.annotations) {
|
|
@@ -3439,6 +3468,37 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3439
3468
|
}
|
|
3440
3469
|
} : {}
|
|
3441
3470
|
});
|
|
3471
|
+
} else if (annotation.type === "container_file_citation") {
|
|
3472
|
+
content.push({
|
|
3473
|
+
type: "source",
|
|
3474
|
+
sourceType: "document",
|
|
3475
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils24.generateId)(),
|
|
3476
|
+
mediaType: "text/plain",
|
|
3477
|
+
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
3478
|
+
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
3479
|
+
providerMetadata: {
|
|
3480
|
+
openai: {
|
|
3481
|
+
fileId: annotation.file_id,
|
|
3482
|
+
containerId: annotation.container_id,
|
|
3483
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
});
|
|
3487
|
+
} else if (annotation.type === "file_path") {
|
|
3488
|
+
content.push({
|
|
3489
|
+
type: "source",
|
|
3490
|
+
sourceType: "document",
|
|
3491
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils24.generateId)(),
|
|
3492
|
+
mediaType: "application/octet-stream",
|
|
3493
|
+
title: annotation.file_id,
|
|
3494
|
+
filename: annotation.file_id,
|
|
3495
|
+
providerMetadata: {
|
|
3496
|
+
openai: {
|
|
3497
|
+
fileId: annotation.file_id,
|
|
3498
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
});
|
|
3442
3502
|
}
|
|
3443
3503
|
}
|
|
3444
3504
|
}
|
|
@@ -3508,13 +3568,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3508
3568
|
toolName: "file_search",
|
|
3509
3569
|
result: {
|
|
3510
3570
|
queries: part.queries,
|
|
3511
|
-
results: (
|
|
3571
|
+
results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
|
|
3512
3572
|
attributes: result.attributes,
|
|
3513
3573
|
fileId: result.file_id,
|
|
3514
3574
|
filename: result.filename,
|
|
3515
3575
|
score: result.score,
|
|
3516
3576
|
text: result.text
|
|
3517
|
-
}))) != null ?
|
|
3577
|
+
}))) != null ? _w : null
|
|
3518
3578
|
}
|
|
3519
3579
|
});
|
|
3520
3580
|
break;
|
|
@@ -3554,15 +3614,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3554
3614
|
return {
|
|
3555
3615
|
content,
|
|
3556
3616
|
finishReason: mapOpenAIResponseFinishReason({
|
|
3557
|
-
finishReason: (
|
|
3617
|
+
finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
|
|
3558
3618
|
hasFunctionCall
|
|
3559
3619
|
}),
|
|
3560
3620
|
usage: {
|
|
3561
3621
|
inputTokens: response.usage.input_tokens,
|
|
3562
3622
|
outputTokens: response.usage.output_tokens,
|
|
3563
3623
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
3564
|
-
reasoningTokens: (
|
|
3565
|
-
cachedInputTokens: (
|
|
3624
|
+
reasoningTokens: (_z = (_y = response.usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
|
|
3625
|
+
cachedInputTokens: (_B = (_A = response.usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
|
|
3566
3626
|
},
|
|
3567
3627
|
request: { body },
|
|
3568
3628
|
response: {
|
|
@@ -3620,7 +3680,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3620
3680
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3621
3681
|
},
|
|
3622
3682
|
transform(chunk, controller) {
|
|
3623
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3683
|
+
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, _y, _z, _A, _B, _C, _D, _E;
|
|
3624
3684
|
if (options.includeRawChunks) {
|
|
3625
3685
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3626
3686
|
}
|
|
@@ -4025,6 +4085,37 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4025
4085
|
}
|
|
4026
4086
|
} : {}
|
|
4027
4087
|
});
|
|
4088
|
+
} else if (value.annotation.type === "container_file_citation") {
|
|
4089
|
+
controller.enqueue({
|
|
4090
|
+
type: "source",
|
|
4091
|
+
sourceType: "document",
|
|
4092
|
+
id: (_y = (_x = (_w = self.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : (0, import_provider_utils24.generateId)(),
|
|
4093
|
+
mediaType: "text/plain",
|
|
4094
|
+
title: (_A = (_z = value.annotation.filename) != null ? _z : value.annotation.file_id) != null ? _A : "Document",
|
|
4095
|
+
filename: (_B = value.annotation.filename) != null ? _B : value.annotation.file_id,
|
|
4096
|
+
providerMetadata: {
|
|
4097
|
+
openai: {
|
|
4098
|
+
fileId: value.annotation.file_id,
|
|
4099
|
+
containerId: value.annotation.container_id,
|
|
4100
|
+
...value.annotation.index != null ? { index: value.annotation.index } : {}
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
});
|
|
4104
|
+
} else if (value.annotation.type === "file_path") {
|
|
4105
|
+
controller.enqueue({
|
|
4106
|
+
type: "source",
|
|
4107
|
+
sourceType: "document",
|
|
4108
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : (0, import_provider_utils24.generateId)(),
|
|
4109
|
+
mediaType: "application/octet-stream",
|
|
4110
|
+
title: value.annotation.file_id,
|
|
4111
|
+
filename: value.annotation.file_id,
|
|
4112
|
+
providerMetadata: {
|
|
4113
|
+
openai: {
|
|
4114
|
+
fileId: value.annotation.file_id,
|
|
4115
|
+
...value.annotation.index != null ? { index: value.annotation.index } : {}
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
});
|
|
4028
4119
|
}
|
|
4029
4120
|
} else if (isErrorChunk(value)) {
|
|
4030
4121
|
controller.enqueue({ type: "error", error: value });
|
|
@@ -4486,7 +4577,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4486
4577
|
};
|
|
4487
4578
|
|
|
4488
4579
|
// src/version.ts
|
|
4489
|
-
var VERSION = true ? "3.0.0-beta.
|
|
4580
|
+
var VERSION = true ? "3.0.0-beta.51" : "0.0.0-test";
|
|
4490
4581
|
|
|
4491
4582
|
// src/openai-provider.ts
|
|
4492
4583
|
function createOpenAI(options = {}) {
|