@zenning/openai 2.0.29 → 2.1.0
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 +40 -0
- package/dist/index.d.mts +86 -24
- package/dist/index.d.ts +86 -24
- package/dist/index.js +779 -688
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +743 -652
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +14 -13
- package/dist/internal/index.d.ts +14 -13
- package/dist/internal/index.js +785 -711
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +732 -658
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -18,20 +18,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
createOpenAI: () => createOpenAI,
|
|
24
24
|
openai: () => openai
|
|
25
25
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/openai-provider.ts
|
|
29
29
|
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
30
30
|
|
|
31
31
|
// src/chat/openai-chat-language-model.ts
|
|
32
|
-
var import_provider3 = require("@
|
|
33
|
-
var
|
|
34
|
-
var
|
|
32
|
+
var import_provider3 = require("@zenning/provider");
|
|
33
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
34
|
+
var import_v43 = require("zod/v4");
|
|
35
35
|
|
|
36
36
|
// src/openai-error.ts
|
|
37
37
|
var import_v4 = require("zod/v4");
|
|
@@ -53,7 +53,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// src/chat/convert-to-openai-chat-messages.ts
|
|
56
|
-
var import_provider = require("@
|
|
56
|
+
var import_provider = require("@zenning/provider");
|
|
57
57
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
58
58
|
function convertToOpenAIChatMessages({
|
|
59
59
|
prompt,
|
|
@@ -351,99 +351,7 @@ var openaiProviderOptions = import_v42.z.object({
|
|
|
351
351
|
});
|
|
352
352
|
|
|
353
353
|
// src/chat/openai-chat-prepare-tools.ts
|
|
354
|
-
var import_provider2 = require("@
|
|
355
|
-
|
|
356
|
-
// src/tool/file-search.ts
|
|
357
|
-
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
358
|
-
var import_v43 = require("zod/v4");
|
|
359
|
-
var comparisonFilterSchema = import_v43.z.object({
|
|
360
|
-
key: import_v43.z.string(),
|
|
361
|
-
type: import_v43.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
362
|
-
value: import_v43.z.union([import_v43.z.string(), import_v43.z.number(), import_v43.z.boolean()])
|
|
363
|
-
});
|
|
364
|
-
var compoundFilterSchema = import_v43.z.object({
|
|
365
|
-
type: import_v43.z.enum(["and", "or"]),
|
|
366
|
-
filters: import_v43.z.array(
|
|
367
|
-
import_v43.z.union([comparisonFilterSchema, import_v43.z.lazy(() => compoundFilterSchema)])
|
|
368
|
-
)
|
|
369
|
-
});
|
|
370
|
-
var filtersSchema = import_v43.z.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
371
|
-
var fileSearchArgsSchema = import_v43.z.object({
|
|
372
|
-
vectorStoreIds: import_v43.z.array(import_v43.z.string()).optional(),
|
|
373
|
-
maxNumResults: import_v43.z.number().optional(),
|
|
374
|
-
ranking: import_v43.z.object({
|
|
375
|
-
ranker: import_v43.z.enum(["auto", "default-2024-08-21"]).optional()
|
|
376
|
-
}).optional(),
|
|
377
|
-
filters: filtersSchema.optional()
|
|
378
|
-
});
|
|
379
|
-
var fileSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
|
|
380
|
-
id: "openai.file_search",
|
|
381
|
-
name: "file_search",
|
|
382
|
-
inputSchema: import_v43.z.object({
|
|
383
|
-
query: import_v43.z.string().optional()
|
|
384
|
-
})
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// src/tool/web-search-preview.ts
|
|
388
|
-
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
389
|
-
var import_v44 = require("zod/v4");
|
|
390
|
-
var webSearchPreviewArgsSchema = import_v44.z.object({
|
|
391
|
-
/**
|
|
392
|
-
* Search context size to use for the web search.
|
|
393
|
-
* - high: Most comprehensive context, highest cost, slower response
|
|
394
|
-
* - medium: Balanced context, cost, and latency (default)
|
|
395
|
-
* - low: Least context, lowest cost, fastest response
|
|
396
|
-
*/
|
|
397
|
-
searchContextSize: import_v44.z.enum(["low", "medium", "high"]).optional(),
|
|
398
|
-
/**
|
|
399
|
-
* User location information to provide geographically relevant search results.
|
|
400
|
-
*/
|
|
401
|
-
userLocation: import_v44.z.object({
|
|
402
|
-
/**
|
|
403
|
-
* Type of location (always 'approximate')
|
|
404
|
-
*/
|
|
405
|
-
type: import_v44.z.literal("approximate"),
|
|
406
|
-
/**
|
|
407
|
-
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
408
|
-
*/
|
|
409
|
-
country: import_v44.z.string().optional(),
|
|
410
|
-
/**
|
|
411
|
-
* City name (free text, e.g., 'Minneapolis')
|
|
412
|
-
*/
|
|
413
|
-
city: import_v44.z.string().optional(),
|
|
414
|
-
/**
|
|
415
|
-
* Region name (free text, e.g., 'Minnesota')
|
|
416
|
-
*/
|
|
417
|
-
region: import_v44.z.string().optional(),
|
|
418
|
-
/**
|
|
419
|
-
* IANA timezone (e.g., 'America/Chicago')
|
|
420
|
-
*/
|
|
421
|
-
timezone: import_v44.z.string().optional()
|
|
422
|
-
}).optional()
|
|
423
|
-
});
|
|
424
|
-
var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFactory)({
|
|
425
|
-
id: "openai.web_search_preview",
|
|
426
|
-
name: "web_search_preview",
|
|
427
|
-
inputSchema: import_v44.z.object({
|
|
428
|
-
action: import_v44.z.discriminatedUnion("type", [
|
|
429
|
-
import_v44.z.object({
|
|
430
|
-
type: import_v44.z.literal("search"),
|
|
431
|
-
query: import_v44.z.string().nullish()
|
|
432
|
-
}),
|
|
433
|
-
import_v44.z.object({
|
|
434
|
-
type: import_v44.z.literal("open_page"),
|
|
435
|
-
url: import_v44.z.string()
|
|
436
|
-
}),
|
|
437
|
-
import_v44.z.object({
|
|
438
|
-
type: import_v44.z.literal("find"),
|
|
439
|
-
url: import_v44.z.string(),
|
|
440
|
-
pattern: import_v44.z.string()
|
|
441
|
-
})
|
|
442
|
-
]).nullish()
|
|
443
|
-
})
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
// src/chat/openai-chat-prepare-tools.ts
|
|
354
|
+
var import_provider2 = require("@zenning/provider");
|
|
447
355
|
function prepareChatTools({
|
|
448
356
|
tools,
|
|
449
357
|
toolChoice,
|
|
@@ -469,33 +377,6 @@ function prepareChatTools({
|
|
|
469
377
|
}
|
|
470
378
|
});
|
|
471
379
|
break;
|
|
472
|
-
case "provider-defined":
|
|
473
|
-
switch (tool.id) {
|
|
474
|
-
case "openai.file_search": {
|
|
475
|
-
const args = fileSearchArgsSchema.parse(tool.args);
|
|
476
|
-
openaiTools2.push({
|
|
477
|
-
type: "file_search",
|
|
478
|
-
vector_store_ids: args.vectorStoreIds,
|
|
479
|
-
max_num_results: args.maxNumResults,
|
|
480
|
-
ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
|
|
481
|
-
filters: args.filters
|
|
482
|
-
});
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
case "openai.web_search_preview": {
|
|
486
|
-
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
487
|
-
openaiTools2.push({
|
|
488
|
-
type: "web_search_preview",
|
|
489
|
-
search_context_size: args.searchContextSize,
|
|
490
|
-
user_location: args.userLocation
|
|
491
|
-
});
|
|
492
|
-
break;
|
|
493
|
-
}
|
|
494
|
-
default:
|
|
495
|
-
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
496
|
-
break;
|
|
497
|
-
}
|
|
498
|
-
break;
|
|
499
380
|
default:
|
|
500
381
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
501
382
|
break;
|
|
@@ -560,7 +441,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
560
441
|
}) {
|
|
561
442
|
var _a, _b, _c, _d;
|
|
562
443
|
const warnings = [];
|
|
563
|
-
const openaiOptions = (_a = await (0,
|
|
444
|
+
const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
564
445
|
provider: "openai",
|
|
565
446
|
providerOptions,
|
|
566
447
|
schema: openaiProviderOptions
|
|
@@ -739,15 +620,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
739
620
|
responseHeaders,
|
|
740
621
|
value: response,
|
|
741
622
|
rawValue: rawResponse
|
|
742
|
-
} = await (0,
|
|
623
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
743
624
|
url: this.config.url({
|
|
744
625
|
path: "/chat/completions",
|
|
745
626
|
modelId: this.modelId
|
|
746
627
|
}),
|
|
747
|
-
headers: (0,
|
|
628
|
+
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
|
|
748
629
|
body,
|
|
749
630
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
750
|
-
successfulResponseHandler: (0,
|
|
631
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
751
632
|
openaiChatResponseSchema
|
|
752
633
|
),
|
|
753
634
|
abortSignal: options.abortSignal,
|
|
@@ -762,7 +643,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
762
643
|
for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
|
|
763
644
|
content.push({
|
|
764
645
|
type: "tool-call",
|
|
765
|
-
toolCallId: (_b = toolCall.id) != null ? _b : (0,
|
|
646
|
+
toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils3.generateId)(),
|
|
766
647
|
toolName: toolCall.function.name,
|
|
767
648
|
input: toolCall.function.arguments
|
|
768
649
|
});
|
|
@@ -771,7 +652,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
771
652
|
content.push({
|
|
772
653
|
type: "source",
|
|
773
654
|
sourceType: "url",
|
|
774
|
-
id: (0,
|
|
655
|
+
id: (0, import_provider_utils3.generateId)(),
|
|
775
656
|
url: annotation.url,
|
|
776
657
|
title: annotation.title
|
|
777
658
|
});
|
|
@@ -817,15 +698,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
817
698
|
include_usage: true
|
|
818
699
|
}
|
|
819
700
|
};
|
|
820
|
-
const { responseHeaders, value: response } = await (0,
|
|
701
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
|
|
821
702
|
url: this.config.url({
|
|
822
703
|
path: "/chat/completions",
|
|
823
704
|
modelId: this.modelId
|
|
824
705
|
}),
|
|
825
|
-
headers: (0,
|
|
706
|
+
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
|
|
826
707
|
body,
|
|
827
708
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
828
|
-
successfulResponseHandler: (0,
|
|
709
|
+
successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
|
|
829
710
|
openaiChatChunkSchema
|
|
830
711
|
),
|
|
831
712
|
abortSignal: options.abortSignal,
|
|
@@ -950,14 +831,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
950
831
|
delta: toolCall2.function.arguments
|
|
951
832
|
});
|
|
952
833
|
}
|
|
953
|
-
if ((0,
|
|
834
|
+
if ((0, import_provider_utils3.isParsableJson)(toolCall2.function.arguments)) {
|
|
954
835
|
controller.enqueue({
|
|
955
836
|
type: "tool-input-end",
|
|
956
837
|
id: toolCall2.id
|
|
957
838
|
});
|
|
958
839
|
controller.enqueue({
|
|
959
840
|
type: "tool-call",
|
|
960
|
-
toolCallId: (_q = toolCall2.id) != null ? _q : (0,
|
|
841
|
+
toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils3.generateId)(),
|
|
961
842
|
toolName: toolCall2.function.name,
|
|
962
843
|
input: toolCall2.function.arguments
|
|
963
844
|
});
|
|
@@ -978,14 +859,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
978
859
|
id: toolCall.id,
|
|
979
860
|
delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
|
|
980
861
|
});
|
|
981
|
-
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && (0,
|
|
862
|
+
if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && (0, import_provider_utils3.isParsableJson)(toolCall.function.arguments)) {
|
|
982
863
|
controller.enqueue({
|
|
983
864
|
type: "tool-input-end",
|
|
984
865
|
id: toolCall.id
|
|
985
866
|
});
|
|
986
867
|
controller.enqueue({
|
|
987
868
|
type: "tool-call",
|
|
988
|
-
toolCallId: (_x = toolCall.id) != null ? _x : (0,
|
|
869
|
+
toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils3.generateId)(),
|
|
989
870
|
toolName: toolCall.function.name,
|
|
990
871
|
input: toolCall.function.arguments
|
|
991
872
|
});
|
|
@@ -998,7 +879,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
998
879
|
controller.enqueue({
|
|
999
880
|
type: "source",
|
|
1000
881
|
sourceType: "url",
|
|
1001
|
-
id: (0,
|
|
882
|
+
id: (0, import_provider_utils3.generateId)(),
|
|
1002
883
|
url: annotation.url,
|
|
1003
884
|
title: annotation.title
|
|
1004
885
|
});
|
|
@@ -1023,115 +904,115 @@ var OpenAIChatLanguageModel = class {
|
|
|
1023
904
|
};
|
|
1024
905
|
}
|
|
1025
906
|
};
|
|
1026
|
-
var openaiTokenUsageSchema =
|
|
1027
|
-
prompt_tokens:
|
|
1028
|
-
completion_tokens:
|
|
1029
|
-
total_tokens:
|
|
1030
|
-
prompt_tokens_details:
|
|
1031
|
-
cached_tokens:
|
|
907
|
+
var openaiTokenUsageSchema = import_v43.z.object({
|
|
908
|
+
prompt_tokens: import_v43.z.number().nullish(),
|
|
909
|
+
completion_tokens: import_v43.z.number().nullish(),
|
|
910
|
+
total_tokens: import_v43.z.number().nullish(),
|
|
911
|
+
prompt_tokens_details: import_v43.z.object({
|
|
912
|
+
cached_tokens: import_v43.z.number().nullish()
|
|
1032
913
|
}).nullish(),
|
|
1033
|
-
completion_tokens_details:
|
|
1034
|
-
reasoning_tokens:
|
|
1035
|
-
accepted_prediction_tokens:
|
|
1036
|
-
rejected_prediction_tokens:
|
|
914
|
+
completion_tokens_details: import_v43.z.object({
|
|
915
|
+
reasoning_tokens: import_v43.z.number().nullish(),
|
|
916
|
+
accepted_prediction_tokens: import_v43.z.number().nullish(),
|
|
917
|
+
rejected_prediction_tokens: import_v43.z.number().nullish()
|
|
1037
918
|
}).nullish()
|
|
1038
919
|
}).nullish();
|
|
1039
|
-
var openaiChatResponseSchema =
|
|
1040
|
-
id:
|
|
1041
|
-
created:
|
|
1042
|
-
model:
|
|
1043
|
-
choices:
|
|
1044
|
-
|
|
1045
|
-
message:
|
|
1046
|
-
role:
|
|
1047
|
-
content:
|
|
1048
|
-
tool_calls:
|
|
1049
|
-
|
|
1050
|
-
id:
|
|
1051
|
-
type:
|
|
1052
|
-
function:
|
|
1053
|
-
name:
|
|
1054
|
-
arguments:
|
|
920
|
+
var openaiChatResponseSchema = import_v43.z.object({
|
|
921
|
+
id: import_v43.z.string().nullish(),
|
|
922
|
+
created: import_v43.z.number().nullish(),
|
|
923
|
+
model: import_v43.z.string().nullish(),
|
|
924
|
+
choices: import_v43.z.array(
|
|
925
|
+
import_v43.z.object({
|
|
926
|
+
message: import_v43.z.object({
|
|
927
|
+
role: import_v43.z.literal("assistant").nullish(),
|
|
928
|
+
content: import_v43.z.string().nullish(),
|
|
929
|
+
tool_calls: import_v43.z.array(
|
|
930
|
+
import_v43.z.object({
|
|
931
|
+
id: import_v43.z.string().nullish(),
|
|
932
|
+
type: import_v43.z.literal("function"),
|
|
933
|
+
function: import_v43.z.object({
|
|
934
|
+
name: import_v43.z.string(),
|
|
935
|
+
arguments: import_v43.z.string()
|
|
1055
936
|
})
|
|
1056
937
|
})
|
|
1057
938
|
).nullish(),
|
|
1058
|
-
annotations:
|
|
1059
|
-
|
|
1060
|
-
type:
|
|
1061
|
-
start_index:
|
|
1062
|
-
end_index:
|
|
1063
|
-
url:
|
|
1064
|
-
title:
|
|
939
|
+
annotations: import_v43.z.array(
|
|
940
|
+
import_v43.z.object({
|
|
941
|
+
type: import_v43.z.literal("url_citation"),
|
|
942
|
+
start_index: import_v43.z.number(),
|
|
943
|
+
end_index: import_v43.z.number(),
|
|
944
|
+
url: import_v43.z.string(),
|
|
945
|
+
title: import_v43.z.string()
|
|
1065
946
|
})
|
|
1066
947
|
).nullish()
|
|
1067
948
|
}),
|
|
1068
|
-
index:
|
|
1069
|
-
logprobs:
|
|
1070
|
-
content:
|
|
1071
|
-
|
|
1072
|
-
token:
|
|
1073
|
-
logprob:
|
|
1074
|
-
top_logprobs:
|
|
1075
|
-
|
|
1076
|
-
token:
|
|
1077
|
-
logprob:
|
|
949
|
+
index: import_v43.z.number(),
|
|
950
|
+
logprobs: import_v43.z.object({
|
|
951
|
+
content: import_v43.z.array(
|
|
952
|
+
import_v43.z.object({
|
|
953
|
+
token: import_v43.z.string(),
|
|
954
|
+
logprob: import_v43.z.number(),
|
|
955
|
+
top_logprobs: import_v43.z.array(
|
|
956
|
+
import_v43.z.object({
|
|
957
|
+
token: import_v43.z.string(),
|
|
958
|
+
logprob: import_v43.z.number()
|
|
1078
959
|
})
|
|
1079
960
|
)
|
|
1080
961
|
})
|
|
1081
962
|
).nullish()
|
|
1082
963
|
}).nullish(),
|
|
1083
|
-
finish_reason:
|
|
964
|
+
finish_reason: import_v43.z.string().nullish()
|
|
1084
965
|
})
|
|
1085
966
|
),
|
|
1086
967
|
usage: openaiTokenUsageSchema
|
|
1087
968
|
});
|
|
1088
|
-
var openaiChatChunkSchema =
|
|
1089
|
-
|
|
1090
|
-
id:
|
|
1091
|
-
created:
|
|
1092
|
-
model:
|
|
1093
|
-
choices:
|
|
1094
|
-
|
|
1095
|
-
delta:
|
|
1096
|
-
role:
|
|
1097
|
-
content:
|
|
1098
|
-
tool_calls:
|
|
1099
|
-
|
|
1100
|
-
index:
|
|
1101
|
-
id:
|
|
1102
|
-
type:
|
|
1103
|
-
function:
|
|
1104
|
-
name:
|
|
1105
|
-
arguments:
|
|
969
|
+
var openaiChatChunkSchema = import_v43.z.union([
|
|
970
|
+
import_v43.z.object({
|
|
971
|
+
id: import_v43.z.string().nullish(),
|
|
972
|
+
created: import_v43.z.number().nullish(),
|
|
973
|
+
model: import_v43.z.string().nullish(),
|
|
974
|
+
choices: import_v43.z.array(
|
|
975
|
+
import_v43.z.object({
|
|
976
|
+
delta: import_v43.z.object({
|
|
977
|
+
role: import_v43.z.enum(["assistant"]).nullish(),
|
|
978
|
+
content: import_v43.z.string().nullish(),
|
|
979
|
+
tool_calls: import_v43.z.array(
|
|
980
|
+
import_v43.z.object({
|
|
981
|
+
index: import_v43.z.number(),
|
|
982
|
+
id: import_v43.z.string().nullish(),
|
|
983
|
+
type: import_v43.z.literal("function").nullish(),
|
|
984
|
+
function: import_v43.z.object({
|
|
985
|
+
name: import_v43.z.string().nullish(),
|
|
986
|
+
arguments: import_v43.z.string().nullish()
|
|
1106
987
|
})
|
|
1107
988
|
})
|
|
1108
989
|
).nullish(),
|
|
1109
|
-
annotations:
|
|
1110
|
-
|
|
1111
|
-
type:
|
|
1112
|
-
start_index:
|
|
1113
|
-
end_index:
|
|
1114
|
-
url:
|
|
1115
|
-
title:
|
|
990
|
+
annotations: import_v43.z.array(
|
|
991
|
+
import_v43.z.object({
|
|
992
|
+
type: import_v43.z.literal("url_citation"),
|
|
993
|
+
start_index: import_v43.z.number(),
|
|
994
|
+
end_index: import_v43.z.number(),
|
|
995
|
+
url: import_v43.z.string(),
|
|
996
|
+
title: import_v43.z.string()
|
|
1116
997
|
})
|
|
1117
998
|
).nullish()
|
|
1118
999
|
}).nullish(),
|
|
1119
|
-
logprobs:
|
|
1120
|
-
content:
|
|
1121
|
-
|
|
1122
|
-
token:
|
|
1123
|
-
logprob:
|
|
1124
|
-
top_logprobs:
|
|
1125
|
-
|
|
1126
|
-
token:
|
|
1127
|
-
logprob:
|
|
1000
|
+
logprobs: import_v43.z.object({
|
|
1001
|
+
content: import_v43.z.array(
|
|
1002
|
+
import_v43.z.object({
|
|
1003
|
+
token: import_v43.z.string(),
|
|
1004
|
+
logprob: import_v43.z.number(),
|
|
1005
|
+
top_logprobs: import_v43.z.array(
|
|
1006
|
+
import_v43.z.object({
|
|
1007
|
+
token: import_v43.z.string(),
|
|
1008
|
+
logprob: import_v43.z.number()
|
|
1128
1009
|
})
|
|
1129
1010
|
)
|
|
1130
1011
|
})
|
|
1131
1012
|
).nullish()
|
|
1132
1013
|
}).nullish(),
|
|
1133
|
-
finish_reason:
|
|
1134
|
-
index:
|
|
1014
|
+
finish_reason: import_v43.z.string().nullish(),
|
|
1015
|
+
index: import_v43.z.number()
|
|
1135
1016
|
})
|
|
1136
1017
|
),
|
|
1137
1018
|
usage: openaiTokenUsageSchema
|
|
@@ -1188,11 +1069,11 @@ var reasoningModels = {
|
|
|
1188
1069
|
};
|
|
1189
1070
|
|
|
1190
1071
|
// src/completion/openai-completion-language-model.ts
|
|
1191
|
-
var
|
|
1192
|
-
var
|
|
1072
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1073
|
+
var import_v45 = require("zod/v4");
|
|
1193
1074
|
|
|
1194
1075
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1195
|
-
var import_provider4 = require("@
|
|
1076
|
+
var import_provider4 = require("@zenning/provider");
|
|
1196
1077
|
function convertToOpenAICompletionPrompt({
|
|
1197
1078
|
prompt,
|
|
1198
1079
|
user = "user",
|
|
@@ -1297,12 +1178,12 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1297
1178
|
}
|
|
1298
1179
|
|
|
1299
1180
|
// src/completion/openai-completion-options.ts
|
|
1300
|
-
var
|
|
1301
|
-
var openaiCompletionProviderOptions =
|
|
1181
|
+
var import_v44 = require("zod/v4");
|
|
1182
|
+
var openaiCompletionProviderOptions = import_v44.z.object({
|
|
1302
1183
|
/**
|
|
1303
1184
|
Echo back the prompt in addition to the completion.
|
|
1304
1185
|
*/
|
|
1305
|
-
echo:
|
|
1186
|
+
echo: import_v44.z.boolean().optional(),
|
|
1306
1187
|
/**
|
|
1307
1188
|
Modify the likelihood of specified tokens appearing in the completion.
|
|
1308
1189
|
|
|
@@ -1317,16 +1198,16 @@ var openaiCompletionProviderOptions = import_v46.z.object({
|
|
|
1317
1198
|
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1318
1199
|
token from being generated.
|
|
1319
1200
|
*/
|
|
1320
|
-
logitBias:
|
|
1201
|
+
logitBias: import_v44.z.record(import_v44.z.string(), import_v44.z.number()).optional(),
|
|
1321
1202
|
/**
|
|
1322
1203
|
The suffix that comes after a completion of inserted text.
|
|
1323
1204
|
*/
|
|
1324
|
-
suffix:
|
|
1205
|
+
suffix: import_v44.z.string().optional(),
|
|
1325
1206
|
/**
|
|
1326
1207
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
1327
1208
|
monitor and detect abuse. Learn more.
|
|
1328
1209
|
*/
|
|
1329
|
-
user:
|
|
1210
|
+
user: import_v44.z.string().optional(),
|
|
1330
1211
|
/**
|
|
1331
1212
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1332
1213
|
the response size and can slow down response times. However, it can
|
|
@@ -1336,7 +1217,7 @@ var openaiCompletionProviderOptions = import_v46.z.object({
|
|
|
1336
1217
|
Setting to a number will return the log probabilities of the top n
|
|
1337
1218
|
tokens that were generated.
|
|
1338
1219
|
*/
|
|
1339
|
-
logprobs:
|
|
1220
|
+
logprobs: import_v44.z.union([import_v44.z.boolean(), import_v44.z.number()]).optional()
|
|
1340
1221
|
});
|
|
1341
1222
|
|
|
1342
1223
|
// src/completion/openai-completion-language-model.ts
|
|
@@ -1372,12 +1253,12 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1372
1253
|
}) {
|
|
1373
1254
|
const warnings = [];
|
|
1374
1255
|
const openaiOptions = {
|
|
1375
|
-
...await (0,
|
|
1256
|
+
...await (0, import_provider_utils4.parseProviderOptions)({
|
|
1376
1257
|
provider: "openai",
|
|
1377
1258
|
providerOptions,
|
|
1378
1259
|
schema: openaiCompletionProviderOptions
|
|
1379
1260
|
}),
|
|
1380
|
-
...await (0,
|
|
1261
|
+
...await (0, import_provider_utils4.parseProviderOptions)({
|
|
1381
1262
|
provider: this.providerOptionsName,
|
|
1382
1263
|
providerOptions,
|
|
1383
1264
|
schema: openaiCompletionProviderOptions
|
|
@@ -1433,15 +1314,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1433
1314
|
responseHeaders,
|
|
1434
1315
|
value: response,
|
|
1435
1316
|
rawValue: rawResponse
|
|
1436
|
-
} = await (0,
|
|
1317
|
+
} = await (0, import_provider_utils4.postJsonToApi)({
|
|
1437
1318
|
url: this.config.url({
|
|
1438
1319
|
path: "/completions",
|
|
1439
1320
|
modelId: this.modelId
|
|
1440
1321
|
}),
|
|
1441
|
-
headers: (0,
|
|
1322
|
+
headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
|
|
1442
1323
|
body: args,
|
|
1443
1324
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1444
|
-
successfulResponseHandler: (0,
|
|
1325
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
1445
1326
|
openaiCompletionResponseSchema
|
|
1446
1327
|
),
|
|
1447
1328
|
abortSignal: options.abortSignal,
|
|
@@ -1479,15 +1360,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1479
1360
|
include_usage: true
|
|
1480
1361
|
}
|
|
1481
1362
|
};
|
|
1482
|
-
const { responseHeaders, value: response } = await (0,
|
|
1363
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
1483
1364
|
url: this.config.url({
|
|
1484
1365
|
path: "/completions",
|
|
1485
1366
|
modelId: this.modelId
|
|
1486
1367
|
}),
|
|
1487
|
-
headers: (0,
|
|
1368
|
+
headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
|
|
1488
1369
|
body,
|
|
1489
1370
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1490
|
-
successfulResponseHandler: (0,
|
|
1371
|
+
successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
|
|
1491
1372
|
openaiCompletionChunkSchema
|
|
1492
1373
|
),
|
|
1493
1374
|
abortSignal: options.abortSignal,
|
|
@@ -1568,42 +1449,42 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1568
1449
|
};
|
|
1569
1450
|
}
|
|
1570
1451
|
};
|
|
1571
|
-
var usageSchema =
|
|
1572
|
-
prompt_tokens:
|
|
1573
|
-
completion_tokens:
|
|
1574
|
-
total_tokens:
|
|
1452
|
+
var usageSchema = import_v45.z.object({
|
|
1453
|
+
prompt_tokens: import_v45.z.number(),
|
|
1454
|
+
completion_tokens: import_v45.z.number(),
|
|
1455
|
+
total_tokens: import_v45.z.number()
|
|
1575
1456
|
});
|
|
1576
|
-
var openaiCompletionResponseSchema =
|
|
1577
|
-
id:
|
|
1578
|
-
created:
|
|
1579
|
-
model:
|
|
1580
|
-
choices:
|
|
1581
|
-
|
|
1582
|
-
text:
|
|
1583
|
-
finish_reason:
|
|
1584
|
-
logprobs:
|
|
1585
|
-
tokens:
|
|
1586
|
-
token_logprobs:
|
|
1587
|
-
top_logprobs:
|
|
1457
|
+
var openaiCompletionResponseSchema = import_v45.z.object({
|
|
1458
|
+
id: import_v45.z.string().nullish(),
|
|
1459
|
+
created: import_v45.z.number().nullish(),
|
|
1460
|
+
model: import_v45.z.string().nullish(),
|
|
1461
|
+
choices: import_v45.z.array(
|
|
1462
|
+
import_v45.z.object({
|
|
1463
|
+
text: import_v45.z.string(),
|
|
1464
|
+
finish_reason: import_v45.z.string(),
|
|
1465
|
+
logprobs: import_v45.z.object({
|
|
1466
|
+
tokens: import_v45.z.array(import_v45.z.string()),
|
|
1467
|
+
token_logprobs: import_v45.z.array(import_v45.z.number()),
|
|
1468
|
+
top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
|
|
1588
1469
|
}).nullish()
|
|
1589
1470
|
})
|
|
1590
1471
|
),
|
|
1591
1472
|
usage: usageSchema.nullish()
|
|
1592
1473
|
});
|
|
1593
|
-
var openaiCompletionChunkSchema =
|
|
1594
|
-
|
|
1595
|
-
id:
|
|
1596
|
-
created:
|
|
1597
|
-
model:
|
|
1598
|
-
choices:
|
|
1599
|
-
|
|
1600
|
-
text:
|
|
1601
|
-
finish_reason:
|
|
1602
|
-
index:
|
|
1603
|
-
logprobs:
|
|
1604
|
-
tokens:
|
|
1605
|
-
token_logprobs:
|
|
1606
|
-
top_logprobs:
|
|
1474
|
+
var openaiCompletionChunkSchema = import_v45.z.union([
|
|
1475
|
+
import_v45.z.object({
|
|
1476
|
+
id: import_v45.z.string().nullish(),
|
|
1477
|
+
created: import_v45.z.number().nullish(),
|
|
1478
|
+
model: import_v45.z.string().nullish(),
|
|
1479
|
+
choices: import_v45.z.array(
|
|
1480
|
+
import_v45.z.object({
|
|
1481
|
+
text: import_v45.z.string(),
|
|
1482
|
+
finish_reason: import_v45.z.string().nullish(),
|
|
1483
|
+
index: import_v45.z.number(),
|
|
1484
|
+
logprobs: import_v45.z.object({
|
|
1485
|
+
tokens: import_v45.z.array(import_v45.z.string()),
|
|
1486
|
+
token_logprobs: import_v45.z.array(import_v45.z.number()),
|
|
1487
|
+
top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
|
|
1607
1488
|
}).nullish()
|
|
1608
1489
|
})
|
|
1609
1490
|
),
|
|
@@ -1613,23 +1494,23 @@ var openaiCompletionChunkSchema = import_v47.z.union([
|
|
|
1613
1494
|
]);
|
|
1614
1495
|
|
|
1615
1496
|
// src/embedding/openai-embedding-model.ts
|
|
1616
|
-
var import_provider5 = require("@
|
|
1617
|
-
var
|
|
1618
|
-
var
|
|
1497
|
+
var import_provider5 = require("@zenning/provider");
|
|
1498
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1499
|
+
var import_v47 = require("zod/v4");
|
|
1619
1500
|
|
|
1620
1501
|
// src/embedding/openai-embedding-options.ts
|
|
1621
|
-
var
|
|
1622
|
-
var openaiEmbeddingProviderOptions =
|
|
1502
|
+
var import_v46 = require("zod/v4");
|
|
1503
|
+
var openaiEmbeddingProviderOptions = import_v46.z.object({
|
|
1623
1504
|
/**
|
|
1624
1505
|
The number of dimensions the resulting output embeddings should have.
|
|
1625
1506
|
Only supported in text-embedding-3 and later models.
|
|
1626
1507
|
*/
|
|
1627
|
-
dimensions:
|
|
1508
|
+
dimensions: import_v46.z.number().optional(),
|
|
1628
1509
|
/**
|
|
1629
1510
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
1630
1511
|
monitor and detect abuse. Learn more.
|
|
1631
1512
|
*/
|
|
1632
|
-
user:
|
|
1513
|
+
user: import_v46.z.string().optional()
|
|
1633
1514
|
});
|
|
1634
1515
|
|
|
1635
1516
|
// src/embedding/openai-embedding-model.ts
|
|
@@ -1659,7 +1540,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1659
1540
|
values
|
|
1660
1541
|
});
|
|
1661
1542
|
}
|
|
1662
|
-
const openaiOptions = (_a = await (0,
|
|
1543
|
+
const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
1663
1544
|
provider: "openai",
|
|
1664
1545
|
providerOptions,
|
|
1665
1546
|
schema: openaiEmbeddingProviderOptions
|
|
@@ -1668,12 +1549,12 @@ var OpenAIEmbeddingModel = class {
|
|
|
1668
1549
|
responseHeaders,
|
|
1669
1550
|
value: response,
|
|
1670
1551
|
rawValue
|
|
1671
|
-
} = await (0,
|
|
1552
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
1672
1553
|
url: this.config.url({
|
|
1673
1554
|
path: "/embeddings",
|
|
1674
1555
|
modelId: this.modelId
|
|
1675
1556
|
}),
|
|
1676
|
-
headers: (0,
|
|
1557
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), headers),
|
|
1677
1558
|
body: {
|
|
1678
1559
|
model: this.modelId,
|
|
1679
1560
|
input: values,
|
|
@@ -1682,7 +1563,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1682
1563
|
user: openaiOptions.user
|
|
1683
1564
|
},
|
|
1684
1565
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1685
|
-
successfulResponseHandler: (0,
|
|
1566
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
1686
1567
|
openaiTextEmbeddingResponseSchema
|
|
1687
1568
|
),
|
|
1688
1569
|
abortSignal,
|
|
@@ -1695,14 +1576,14 @@ var OpenAIEmbeddingModel = class {
|
|
|
1695
1576
|
};
|
|
1696
1577
|
}
|
|
1697
1578
|
};
|
|
1698
|
-
var openaiTextEmbeddingResponseSchema =
|
|
1699
|
-
data:
|
|
1700
|
-
usage:
|
|
1579
|
+
var openaiTextEmbeddingResponseSchema = import_v47.z.object({
|
|
1580
|
+
data: import_v47.z.array(import_v47.z.object({ embedding: import_v47.z.array(import_v47.z.number()) })),
|
|
1581
|
+
usage: import_v47.z.object({ prompt_tokens: import_v47.z.number() }).nullish()
|
|
1701
1582
|
});
|
|
1702
1583
|
|
|
1703
1584
|
// src/image/openai-image-model.ts
|
|
1704
|
-
var
|
|
1705
|
-
var
|
|
1585
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1586
|
+
var import_v48 = require("zod/v4");
|
|
1706
1587
|
|
|
1707
1588
|
// src/image/openai-image-options.ts
|
|
1708
1589
|
var modelMaxImagesPerCall = {
|
|
@@ -1749,12 +1630,12 @@ var OpenAIImageModel = class {
|
|
|
1749
1630
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
1750
1631
|
}
|
|
1751
1632
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1752
|
-
const { value: response, responseHeaders } = await (0,
|
|
1633
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
|
|
1753
1634
|
url: this.config.url({
|
|
1754
1635
|
path: "/images/generations",
|
|
1755
1636
|
modelId: this.modelId
|
|
1756
1637
|
}),
|
|
1757
|
-
headers: (0,
|
|
1638
|
+
headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), headers),
|
|
1758
1639
|
body: {
|
|
1759
1640
|
model: this.modelId,
|
|
1760
1641
|
prompt,
|
|
@@ -1764,7 +1645,7 @@ var OpenAIImageModel = class {
|
|
|
1764
1645
|
...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1765
1646
|
},
|
|
1766
1647
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1767
|
-
successfulResponseHandler: (0,
|
|
1648
|
+
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
1768
1649
|
openaiImageResponseSchema
|
|
1769
1650
|
),
|
|
1770
1651
|
abortSignal,
|
|
@@ -1790,36 +1671,36 @@ var OpenAIImageModel = class {
|
|
|
1790
1671
|
};
|
|
1791
1672
|
}
|
|
1792
1673
|
};
|
|
1793
|
-
var openaiImageResponseSchema =
|
|
1794
|
-
data:
|
|
1795
|
-
|
|
1674
|
+
var openaiImageResponseSchema = import_v48.z.object({
|
|
1675
|
+
data: import_v48.z.array(
|
|
1676
|
+
import_v48.z.object({ b64_json: import_v48.z.string(), revised_prompt: import_v48.z.string().optional() })
|
|
1796
1677
|
)
|
|
1797
1678
|
});
|
|
1798
1679
|
|
|
1799
1680
|
// src/tool/code-interpreter.ts
|
|
1800
|
-
var
|
|
1801
|
-
var
|
|
1802
|
-
var codeInterpreterInputSchema =
|
|
1803
|
-
code:
|
|
1804
|
-
containerId:
|
|
1681
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1682
|
+
var import_v49 = require("zod/v4");
|
|
1683
|
+
var codeInterpreterInputSchema = import_v49.z.object({
|
|
1684
|
+
code: import_v49.z.string().nullish(),
|
|
1685
|
+
containerId: import_v49.z.string()
|
|
1805
1686
|
});
|
|
1806
|
-
var codeInterpreterOutputSchema =
|
|
1807
|
-
outputs:
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1687
|
+
var codeInterpreterOutputSchema = import_v49.z.object({
|
|
1688
|
+
outputs: import_v49.z.array(
|
|
1689
|
+
import_v49.z.discriminatedUnion("type", [
|
|
1690
|
+
import_v49.z.object({ type: import_v49.z.literal("logs"), logs: import_v49.z.string() }),
|
|
1691
|
+
import_v49.z.object({ type: import_v49.z.literal("image"), url: import_v49.z.string() })
|
|
1811
1692
|
])
|
|
1812
1693
|
).nullish()
|
|
1813
1694
|
});
|
|
1814
|
-
var codeInterpreterArgsSchema =
|
|
1815
|
-
container:
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
fileIds:
|
|
1695
|
+
var codeInterpreterArgsSchema = import_v49.z.object({
|
|
1696
|
+
container: import_v49.z.union([
|
|
1697
|
+
import_v49.z.string(),
|
|
1698
|
+
import_v49.z.object({
|
|
1699
|
+
fileIds: import_v49.z.array(import_v49.z.string()).optional()
|
|
1819
1700
|
})
|
|
1820
1701
|
]).optional()
|
|
1821
1702
|
});
|
|
1822
|
-
var codeInterpreterToolFactory = (0,
|
|
1703
|
+
var codeInterpreterToolFactory = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
1823
1704
|
id: "openai.code_interpreter",
|
|
1824
1705
|
name: "code_interpreter",
|
|
1825
1706
|
inputSchema: codeInterpreterInputSchema,
|
|
@@ -1829,6 +1710,78 @@ var codeInterpreter = (args = {}) => {
|
|
|
1829
1710
|
return codeInterpreterToolFactory(args);
|
|
1830
1711
|
};
|
|
1831
1712
|
|
|
1713
|
+
// src/tool/file-search.ts
|
|
1714
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1715
|
+
var import_v410 = require("zod/v4");
|
|
1716
|
+
var comparisonFilterSchema = import_v410.z.object({
|
|
1717
|
+
key: import_v410.z.string(),
|
|
1718
|
+
type: import_v410.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
1719
|
+
value: import_v410.z.union([import_v410.z.string(), import_v410.z.number(), import_v410.z.boolean()])
|
|
1720
|
+
});
|
|
1721
|
+
var compoundFilterSchema = import_v410.z.object({
|
|
1722
|
+
type: import_v410.z.enum(["and", "or"]),
|
|
1723
|
+
filters: import_v410.z.array(
|
|
1724
|
+
import_v410.z.union([comparisonFilterSchema, import_v410.z.lazy(() => compoundFilterSchema)])
|
|
1725
|
+
)
|
|
1726
|
+
});
|
|
1727
|
+
var fileSearchArgsSchema = import_v410.z.object({
|
|
1728
|
+
vectorStoreIds: import_v410.z.array(import_v410.z.string()),
|
|
1729
|
+
maxNumResults: import_v410.z.number().optional(),
|
|
1730
|
+
ranking: import_v410.z.object({
|
|
1731
|
+
ranker: import_v410.z.string().optional(),
|
|
1732
|
+
scoreThreshold: import_v410.z.number().optional()
|
|
1733
|
+
}).optional(),
|
|
1734
|
+
filters: import_v410.z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1735
|
+
});
|
|
1736
|
+
var fileSearchOutputSchema = import_v410.z.object({
|
|
1737
|
+
queries: import_v410.z.array(import_v410.z.string()),
|
|
1738
|
+
results: import_v410.z.array(
|
|
1739
|
+
import_v410.z.object({
|
|
1740
|
+
attributes: import_v410.z.record(import_v410.z.string(), import_v410.z.unknown()),
|
|
1741
|
+
fileId: import_v410.z.string(),
|
|
1742
|
+
filename: import_v410.z.string(),
|
|
1743
|
+
score: import_v410.z.number(),
|
|
1744
|
+
text: import_v410.z.string()
|
|
1745
|
+
})
|
|
1746
|
+
).nullable()
|
|
1747
|
+
});
|
|
1748
|
+
var fileSearch = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
1749
|
+
id: "openai.file_search",
|
|
1750
|
+
name: "file_search",
|
|
1751
|
+
inputSchema: import_v410.z.object({}),
|
|
1752
|
+
outputSchema: fileSearchOutputSchema
|
|
1753
|
+
});
|
|
1754
|
+
|
|
1755
|
+
// src/tool/image-generation.ts
|
|
1756
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1757
|
+
var import_v411 = require("zod/v4");
|
|
1758
|
+
var imageGenerationArgsSchema = import_v411.z.object({
|
|
1759
|
+
background: import_v411.z.enum(["auto", "opaque", "transparent"]).optional(),
|
|
1760
|
+
inputFidelity: import_v411.z.enum(["low", "high"]).optional(),
|
|
1761
|
+
inputImageMask: import_v411.z.object({
|
|
1762
|
+
fileId: import_v411.z.string().optional(),
|
|
1763
|
+
imageUrl: import_v411.z.string().optional()
|
|
1764
|
+
}).optional(),
|
|
1765
|
+
model: import_v411.z.string().optional(),
|
|
1766
|
+
moderation: import_v411.z.enum(["auto"]).optional(),
|
|
1767
|
+
outputCompression: import_v411.z.number().int().min(0).max(100).optional(),
|
|
1768
|
+
outputFormat: import_v411.z.enum(["png", "jpeg", "webp"]).optional(),
|
|
1769
|
+
quality: import_v411.z.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1770
|
+
size: import_v411.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1771
|
+
}).strict();
|
|
1772
|
+
var imageGenerationOutputSchema = import_v411.z.object({
|
|
1773
|
+
result: import_v411.z.string()
|
|
1774
|
+
});
|
|
1775
|
+
var imageGenerationToolFactory = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
1776
|
+
id: "openai.image_generation",
|
|
1777
|
+
name: "image_generation",
|
|
1778
|
+
inputSchema: import_v411.z.object({}),
|
|
1779
|
+
outputSchema: imageGenerationOutputSchema
|
|
1780
|
+
});
|
|
1781
|
+
var imageGeneration = (args = {}) => {
|
|
1782
|
+
return imageGenerationToolFactory(args);
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1832
1785
|
// src/tool/web-search.ts
|
|
1833
1786
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1834
1787
|
var import_v412 = require("zod/v4");
|
|
@@ -1870,6 +1823,65 @@ var webSearch = (args = {}) => {
|
|
|
1870
1823
|
return webSearchToolFactory(args);
|
|
1871
1824
|
};
|
|
1872
1825
|
|
|
1826
|
+
// src/tool/web-search-preview.ts
|
|
1827
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1828
|
+
var import_v413 = require("zod/v4");
|
|
1829
|
+
var webSearchPreviewArgsSchema = import_v413.z.object({
|
|
1830
|
+
/**
|
|
1831
|
+
* Search context size to use for the web search.
|
|
1832
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
1833
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
1834
|
+
* - low: Least context, lowest cost, fastest response
|
|
1835
|
+
*/
|
|
1836
|
+
searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
|
|
1837
|
+
/**
|
|
1838
|
+
* User location information to provide geographically relevant search results.
|
|
1839
|
+
*/
|
|
1840
|
+
userLocation: import_v413.z.object({
|
|
1841
|
+
/**
|
|
1842
|
+
* Type of location (always 'approximate')
|
|
1843
|
+
*/
|
|
1844
|
+
type: import_v413.z.literal("approximate"),
|
|
1845
|
+
/**
|
|
1846
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
1847
|
+
*/
|
|
1848
|
+
country: import_v413.z.string().optional(),
|
|
1849
|
+
/**
|
|
1850
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
1851
|
+
*/
|
|
1852
|
+
city: import_v413.z.string().optional(),
|
|
1853
|
+
/**
|
|
1854
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
1855
|
+
*/
|
|
1856
|
+
region: import_v413.z.string().optional(),
|
|
1857
|
+
/**
|
|
1858
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
1859
|
+
*/
|
|
1860
|
+
timezone: import_v413.z.string().optional()
|
|
1861
|
+
}).optional()
|
|
1862
|
+
});
|
|
1863
|
+
var webSearchPreview = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1864
|
+
id: "openai.web_search_preview",
|
|
1865
|
+
name: "web_search_preview",
|
|
1866
|
+
inputSchema: import_v413.z.object({
|
|
1867
|
+
action: import_v413.z.discriminatedUnion("type", [
|
|
1868
|
+
import_v413.z.object({
|
|
1869
|
+
type: import_v413.z.literal("search"),
|
|
1870
|
+
query: import_v413.z.string().nullish()
|
|
1871
|
+
}),
|
|
1872
|
+
import_v413.z.object({
|
|
1873
|
+
type: import_v413.z.literal("open_page"),
|
|
1874
|
+
url: import_v413.z.string()
|
|
1875
|
+
}),
|
|
1876
|
+
import_v413.z.object({
|
|
1877
|
+
type: import_v413.z.literal("find"),
|
|
1878
|
+
url: import_v413.z.string(),
|
|
1879
|
+
pattern: import_v413.z.string()
|
|
1880
|
+
})
|
|
1881
|
+
]).nullish()
|
|
1882
|
+
})
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1873
1885
|
// src/openai-tools.ts
|
|
1874
1886
|
var openaiTools = {
|
|
1875
1887
|
/**
|
|
@@ -1895,6 +1907,20 @@ var openaiTools = {
|
|
|
1895
1907
|
* @param filters - The filters to use for the file search.
|
|
1896
1908
|
*/
|
|
1897
1909
|
fileSearch,
|
|
1910
|
+
/**
|
|
1911
|
+
* The image generation tool allows you to generate images using a text prompt,
|
|
1912
|
+
* and optionally image inputs. It leverages the GPT Image model,
|
|
1913
|
+
* and automatically optimizes text inputs for improved performance.
|
|
1914
|
+
*
|
|
1915
|
+
* Must have name `image_generation`.
|
|
1916
|
+
*
|
|
1917
|
+
* @param size - Image dimensions (e.g., 1024x1024, 1024x1536)
|
|
1918
|
+
* @param quality - Rendering quality (e.g. low, medium, high)
|
|
1919
|
+
* @param format - File output format
|
|
1920
|
+
* @param compression - Compression level (0-100%) for JPEG and WebP formats
|
|
1921
|
+
* @param background - Transparent or opaque
|
|
1922
|
+
*/
|
|
1923
|
+
imageGeneration,
|
|
1898
1924
|
/**
|
|
1899
1925
|
* Web search allows models to access up-to-date information from the internet
|
|
1900
1926
|
* and provide answers with sourced citations.
|
|
@@ -1921,37 +1947,37 @@ var openaiTools = {
|
|
|
1921
1947
|
};
|
|
1922
1948
|
|
|
1923
1949
|
// src/responses/openai-responses-language-model.ts
|
|
1924
|
-
var import_provider8 = require("@
|
|
1950
|
+
var import_provider8 = require("@zenning/provider");
|
|
1925
1951
|
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1926
|
-
var
|
|
1952
|
+
var import_v415 = require("zod/v4");
|
|
1927
1953
|
|
|
1928
|
-
// src/responses/convert-to-openai-responses-
|
|
1929
|
-
var import_provider6 = require("@
|
|
1930
|
-
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1931
|
-
var import_v413 = require("zod/v4");
|
|
1954
|
+
// src/responses/convert-to-openai-responses-input.ts
|
|
1955
|
+
var import_provider6 = require("@zenning/provider");
|
|
1932
1956
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1957
|
+
var import_v414 = require("zod/v4");
|
|
1933
1958
|
function isFileId(data, prefixes) {
|
|
1934
1959
|
if (!prefixes) return false;
|
|
1935
1960
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
1936
1961
|
}
|
|
1937
|
-
async function
|
|
1962
|
+
async function convertToOpenAIResponsesInput({
|
|
1938
1963
|
prompt,
|
|
1939
1964
|
systemMessageMode,
|
|
1940
|
-
fileIdPrefixes
|
|
1965
|
+
fileIdPrefixes,
|
|
1966
|
+
store
|
|
1941
1967
|
}) {
|
|
1942
1968
|
var _a, _b, _c, _d, _e, _f;
|
|
1943
|
-
const
|
|
1969
|
+
const input = [];
|
|
1944
1970
|
const warnings = [];
|
|
1945
1971
|
for (const { role, content } of prompt) {
|
|
1946
1972
|
switch (role) {
|
|
1947
1973
|
case "system": {
|
|
1948
1974
|
switch (systemMessageMode) {
|
|
1949
1975
|
case "system": {
|
|
1950
|
-
|
|
1976
|
+
input.push({ role: "system", content });
|
|
1951
1977
|
break;
|
|
1952
1978
|
}
|
|
1953
1979
|
case "developer": {
|
|
1954
|
-
|
|
1980
|
+
input.push({ role: "developer", content });
|
|
1955
1981
|
break;
|
|
1956
1982
|
}
|
|
1957
1983
|
case "remove": {
|
|
@@ -1971,7 +1997,7 @@ async function convertToOpenAIResponsesMessages({
|
|
|
1971
1997
|
break;
|
|
1972
1998
|
}
|
|
1973
1999
|
case "user": {
|
|
1974
|
-
|
|
2000
|
+
input.push({
|
|
1975
2001
|
role: "user",
|
|
1976
2002
|
content: content.map((part, index) => {
|
|
1977
2003
|
var _a2, _b2, _c2;
|
|
@@ -2016,10 +2042,11 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2016
2042
|
}
|
|
2017
2043
|
case "assistant": {
|
|
2018
2044
|
const reasoningMessages = {};
|
|
2045
|
+
const toolCallParts = {};
|
|
2019
2046
|
for (const part of content) {
|
|
2020
2047
|
switch (part.type) {
|
|
2021
2048
|
case "text": {
|
|
2022
|
-
|
|
2049
|
+
input.push({
|
|
2023
2050
|
role: "assistant",
|
|
2024
2051
|
content: [{ type: "output_text", text: part.text }],
|
|
2025
2052
|
id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
|
|
@@ -2027,10 +2054,11 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2027
2054
|
break;
|
|
2028
2055
|
}
|
|
2029
2056
|
case "tool-call": {
|
|
2057
|
+
toolCallParts[part.toolCallId] = part;
|
|
2030
2058
|
if (part.providerExecuted) {
|
|
2031
2059
|
break;
|
|
2032
2060
|
}
|
|
2033
|
-
|
|
2061
|
+
input.push({
|
|
2034
2062
|
type: "function_call",
|
|
2035
2063
|
call_id: part.toolCallId,
|
|
2036
2064
|
name: part.toolName,
|
|
@@ -2039,15 +2067,20 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2039
2067
|
});
|
|
2040
2068
|
break;
|
|
2041
2069
|
}
|
|
2070
|
+
// assistant tool result parts are from provider-executed tools:
|
|
2042
2071
|
case "tool-result": {
|
|
2043
|
-
|
|
2044
|
-
type: "
|
|
2045
|
-
|
|
2046
|
-
|
|
2072
|
+
if (store) {
|
|
2073
|
+
input.push({ type: "item_reference", id: part.toolCallId });
|
|
2074
|
+
} else {
|
|
2075
|
+
warnings.push({
|
|
2076
|
+
type: "other",
|
|
2077
|
+
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2047
2080
|
break;
|
|
2048
2081
|
}
|
|
2049
2082
|
case "reasoning": {
|
|
2050
|
-
const providerOptions = await (0,
|
|
2083
|
+
const providerOptions = await (0, import_provider_utils12.parseProviderOptions)({
|
|
2051
2084
|
provider: "openai",
|
|
2052
2085
|
providerOptions: part.providerOptions,
|
|
2053
2086
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
@@ -2071,7 +2104,7 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2071
2104
|
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2072
2105
|
summary: summaryParts
|
|
2073
2106
|
};
|
|
2074
|
-
|
|
2107
|
+
input.push(reasoningMessages[reasoningId]);
|
|
2075
2108
|
} else {
|
|
2076
2109
|
existingReasoningMessage.summary.push(...summaryParts);
|
|
2077
2110
|
}
|
|
@@ -2102,7 +2135,7 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2102
2135
|
contentValue = JSON.stringify(output.value);
|
|
2103
2136
|
break;
|
|
2104
2137
|
}
|
|
2105
|
-
|
|
2138
|
+
input.push({
|
|
2106
2139
|
type: "function_call_output",
|
|
2107
2140
|
call_id: part.toolCallId,
|
|
2108
2141
|
output: contentValue
|
|
@@ -2116,11 +2149,11 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2116
2149
|
}
|
|
2117
2150
|
}
|
|
2118
2151
|
}
|
|
2119
|
-
return {
|
|
2152
|
+
return { input, warnings };
|
|
2120
2153
|
}
|
|
2121
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2122
|
-
itemId:
|
|
2123
|
-
reasoningEncryptedContent:
|
|
2154
|
+
var openaiResponsesReasoningProviderOptionsSchema = import_v414.z.object({
|
|
2155
|
+
itemId: import_v414.z.string().nullish(),
|
|
2156
|
+
reasoningEncryptedContent: import_v414.z.string().nullish()
|
|
2124
2157
|
});
|
|
2125
2158
|
|
|
2126
2159
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2142,7 +2175,7 @@ function mapOpenAIResponseFinishReason({
|
|
|
2142
2175
|
}
|
|
2143
2176
|
|
|
2144
2177
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2145
|
-
var import_provider7 = require("@
|
|
2178
|
+
var import_provider7 = require("@zenning/provider");
|
|
2146
2179
|
function prepareResponsesTools({
|
|
2147
2180
|
tools,
|
|
2148
2181
|
toolChoice,
|
|
@@ -2173,7 +2206,10 @@ function prepareResponsesTools({
|
|
|
2173
2206
|
type: "file_search",
|
|
2174
2207
|
vector_store_ids: args.vectorStoreIds,
|
|
2175
2208
|
max_num_results: args.maxNumResults,
|
|
2176
|
-
ranking_options: args.ranking ? {
|
|
2209
|
+
ranking_options: args.ranking ? {
|
|
2210
|
+
ranker: args.ranking.ranker,
|
|
2211
|
+
score_threshold: args.ranking.scoreThreshold
|
|
2212
|
+
} : void 0,
|
|
2177
2213
|
filters: args.filters
|
|
2178
2214
|
});
|
|
2179
2215
|
break;
|
|
@@ -2205,8 +2241,23 @@ function prepareResponsesTools({
|
|
|
2205
2241
|
});
|
|
2206
2242
|
break;
|
|
2207
2243
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2244
|
+
case "openai.image_generation": {
|
|
2245
|
+
const args = imageGenerationArgsSchema.parse(tool.args);
|
|
2246
|
+
openaiTools2.push({
|
|
2247
|
+
type: "image_generation",
|
|
2248
|
+
background: args.background,
|
|
2249
|
+
input_fidelity: args.inputFidelity,
|
|
2250
|
+
input_image_mask: args.inputImageMask ? {
|
|
2251
|
+
file_id: args.inputImageMask.fileId,
|
|
2252
|
+
image_url: args.inputImageMask.imageUrl
|
|
2253
|
+
} : void 0,
|
|
2254
|
+
model: args.model,
|
|
2255
|
+
size: args.size,
|
|
2256
|
+
quality: args.quality,
|
|
2257
|
+
moderation: args.moderation,
|
|
2258
|
+
output_format: args.outputFormat,
|
|
2259
|
+
output_compression: args.outputCompression
|
|
2260
|
+
});
|
|
2210
2261
|
break;
|
|
2211
2262
|
}
|
|
2212
2263
|
}
|
|
@@ -2229,7 +2280,7 @@ function prepareResponsesTools({
|
|
|
2229
2280
|
case "tool":
|
|
2230
2281
|
return {
|
|
2231
2282
|
tools: openaiTools2,
|
|
2232
|
-
toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
2283
|
+
toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
2233
2284
|
toolWarnings
|
|
2234
2285
|
};
|
|
2235
2286
|
default: {
|
|
@@ -2242,47 +2293,66 @@ function prepareResponsesTools({
|
|
|
2242
2293
|
}
|
|
2243
2294
|
|
|
2244
2295
|
// src/responses/openai-responses-language-model.ts
|
|
2245
|
-
var webSearchCallItem =
|
|
2246
|
-
type:
|
|
2247
|
-
id:
|
|
2248
|
-
status:
|
|
2249
|
-
action:
|
|
2250
|
-
|
|
2251
|
-
type:
|
|
2252
|
-
query:
|
|
2296
|
+
var webSearchCallItem = import_v415.z.object({
|
|
2297
|
+
type: import_v415.z.literal("web_search_call"),
|
|
2298
|
+
id: import_v415.z.string(),
|
|
2299
|
+
status: import_v415.z.string(),
|
|
2300
|
+
action: import_v415.z.discriminatedUnion("type", [
|
|
2301
|
+
import_v415.z.object({
|
|
2302
|
+
type: import_v415.z.literal("search"),
|
|
2303
|
+
query: import_v415.z.string().nullish()
|
|
2253
2304
|
}),
|
|
2254
|
-
|
|
2255
|
-
type:
|
|
2256
|
-
url:
|
|
2305
|
+
import_v415.z.object({
|
|
2306
|
+
type: import_v415.z.literal("open_page"),
|
|
2307
|
+
url: import_v415.z.string()
|
|
2257
2308
|
}),
|
|
2258
|
-
|
|
2259
|
-
type:
|
|
2260
|
-
url:
|
|
2261
|
-
pattern:
|
|
2309
|
+
import_v415.z.object({
|
|
2310
|
+
type: import_v415.z.literal("find"),
|
|
2311
|
+
url: import_v415.z.string(),
|
|
2312
|
+
pattern: import_v415.z.string()
|
|
2262
2313
|
})
|
|
2263
2314
|
]).nullish()
|
|
2264
2315
|
});
|
|
2265
|
-
var
|
|
2266
|
-
type:
|
|
2267
|
-
id:
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2316
|
+
var fileSearchCallItem = import_v415.z.object({
|
|
2317
|
+
type: import_v415.z.literal("file_search_call"),
|
|
2318
|
+
id: import_v415.z.string(),
|
|
2319
|
+
queries: import_v415.z.array(import_v415.z.string()),
|
|
2320
|
+
results: import_v415.z.array(
|
|
2321
|
+
import_v415.z.object({
|
|
2322
|
+
attributes: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()),
|
|
2323
|
+
file_id: import_v415.z.string(),
|
|
2324
|
+
filename: import_v415.z.string(),
|
|
2325
|
+
score: import_v415.z.number(),
|
|
2326
|
+
text: import_v415.z.string()
|
|
2327
|
+
})
|
|
2328
|
+
).nullish()
|
|
2329
|
+
});
|
|
2330
|
+
var codeInterpreterCallItem = import_v415.z.object({
|
|
2331
|
+
type: import_v415.z.literal("code_interpreter_call"),
|
|
2332
|
+
id: import_v415.z.string(),
|
|
2333
|
+
code: import_v415.z.string().nullable(),
|
|
2334
|
+
container_id: import_v415.z.string(),
|
|
2335
|
+
outputs: import_v415.z.array(
|
|
2336
|
+
import_v415.z.discriminatedUnion("type", [
|
|
2337
|
+
import_v415.z.object({ type: import_v415.z.literal("logs"), logs: import_v415.z.string() }),
|
|
2338
|
+
import_v415.z.object({ type: import_v415.z.literal("image"), url: import_v415.z.string() })
|
|
2274
2339
|
])
|
|
2275
2340
|
).nullable()
|
|
2276
2341
|
});
|
|
2342
|
+
var imageGenerationCallItem = import_v415.z.object({
|
|
2343
|
+
type: import_v415.z.literal("image_generation_call"),
|
|
2344
|
+
id: import_v415.z.string(),
|
|
2345
|
+
result: import_v415.z.string()
|
|
2346
|
+
});
|
|
2277
2347
|
var TOP_LOGPROBS_MAX = 20;
|
|
2278
|
-
var LOGPROBS_SCHEMA =
|
|
2279
|
-
|
|
2280
|
-
token:
|
|
2281
|
-
logprob:
|
|
2282
|
-
top_logprobs:
|
|
2283
|
-
|
|
2284
|
-
token:
|
|
2285
|
-
logprob:
|
|
2348
|
+
var LOGPROBS_SCHEMA = import_v415.z.array(
|
|
2349
|
+
import_v415.z.object({
|
|
2350
|
+
token: import_v415.z.string(),
|
|
2351
|
+
logprob: import_v415.z.number(),
|
|
2352
|
+
top_logprobs: import_v415.z.array(
|
|
2353
|
+
import_v415.z.object({
|
|
2354
|
+
token: import_v415.z.string(),
|
|
2355
|
+
logprob: import_v415.z.number()
|
|
2286
2356
|
})
|
|
2287
2357
|
)
|
|
2288
2358
|
})
|
|
@@ -2339,32 +2409,44 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2339
2409
|
if (stopSequences != null) {
|
|
2340
2410
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
2341
2411
|
}
|
|
2342
|
-
const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
|
|
2343
|
-
prompt,
|
|
2344
|
-
systemMessageMode: modelConfig.systemMessageMode,
|
|
2345
|
-
fileIdPrefixes: this.config.fileIdPrefixes
|
|
2346
|
-
});
|
|
2347
|
-
warnings.push(...messageWarnings);
|
|
2348
2412
|
const openaiOptions = await (0, import_provider_utils13.parseProviderOptions)({
|
|
2349
2413
|
provider: "openai",
|
|
2350
2414
|
providerOptions,
|
|
2351
2415
|
schema: openaiResponsesProviderOptionsSchema
|
|
2352
2416
|
});
|
|
2353
|
-
const
|
|
2417
|
+
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
2418
|
+
prompt,
|
|
2419
|
+
systemMessageMode: modelConfig.systemMessageMode,
|
|
2420
|
+
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
2421
|
+
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
|
|
2422
|
+
});
|
|
2423
|
+
warnings.push(...inputWarnings);
|
|
2424
|
+
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
2354
2425
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
2426
|
+
function addInclude(key) {
|
|
2427
|
+
include = include != null ? [...include, key] : [key];
|
|
2428
|
+
}
|
|
2429
|
+
function hasOpenAITool(id) {
|
|
2430
|
+
return (tools == null ? void 0 : tools.find(
|
|
2431
|
+
(tool) => tool.type === "provider-defined" && tool.id === id
|
|
2432
|
+
)) != null;
|
|
2433
|
+
}
|
|
2355
2434
|
const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
|
|
2356
|
-
|
|
2357
|
-
|
|
2435
|
+
if (topLogprobs) {
|
|
2436
|
+
addInclude("message.output_text.logprobs");
|
|
2437
|
+
}
|
|
2438
|
+
const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
|
|
2358
2439
|
(tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
2359
|
-
)) == null ? void 0 : _b.name;
|
|
2360
|
-
include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
|
|
2361
|
-
const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
|
|
2362
|
-
(tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
|
|
2363
2440
|
)) == null ? void 0 : _c.name;
|
|
2364
|
-
|
|
2441
|
+
if (webSearchToolName) {
|
|
2442
|
+
addInclude("web_search_call.action.sources");
|
|
2443
|
+
}
|
|
2444
|
+
if (hasOpenAITool("openai.code_interpreter")) {
|
|
2445
|
+
addInclude("code_interpreter_call.outputs");
|
|
2446
|
+
}
|
|
2365
2447
|
const baseArgs = {
|
|
2366
2448
|
model: this.modelId,
|
|
2367
|
-
input
|
|
2449
|
+
input,
|
|
2368
2450
|
temperature,
|
|
2369
2451
|
top_p: topP,
|
|
2370
2452
|
max_output_tokens: maxOutputTokens,
|
|
@@ -2385,6 +2467,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2385
2467
|
}
|
|
2386
2468
|
},
|
|
2387
2469
|
// provider options:
|
|
2470
|
+
max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
|
|
2388
2471
|
metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
|
|
2389
2472
|
parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
|
|
2390
2473
|
previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
|
|
@@ -2480,7 +2563,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2480
2563
|
};
|
|
2481
2564
|
}
|
|
2482
2565
|
async doGenerate(options) {
|
|
2483
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2566
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2484
2567
|
const {
|
|
2485
2568
|
args: body,
|
|
2486
2569
|
warnings,
|
|
@@ -2500,96 +2583,82 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2500
2583
|
body,
|
|
2501
2584
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2502
2585
|
successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
|
|
2503
|
-
|
|
2504
|
-
id:
|
|
2505
|
-
created_at:
|
|
2506
|
-
error:
|
|
2507
|
-
code:
|
|
2508
|
-
message:
|
|
2586
|
+
import_v415.z.object({
|
|
2587
|
+
id: import_v415.z.string(),
|
|
2588
|
+
created_at: import_v415.z.number(),
|
|
2589
|
+
error: import_v415.z.object({
|
|
2590
|
+
code: import_v415.z.string(),
|
|
2591
|
+
message: import_v415.z.string()
|
|
2509
2592
|
}).nullish(),
|
|
2510
|
-
model:
|
|
2511
|
-
output:
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
type:
|
|
2515
|
-
role:
|
|
2516
|
-
id:
|
|
2517
|
-
content:
|
|
2518
|
-
|
|
2519
|
-
type:
|
|
2520
|
-
text:
|
|
2593
|
+
model: import_v415.z.string(),
|
|
2594
|
+
output: import_v415.z.array(
|
|
2595
|
+
import_v415.z.discriminatedUnion("type", [
|
|
2596
|
+
import_v415.z.object({
|
|
2597
|
+
type: import_v415.z.literal("message"),
|
|
2598
|
+
role: import_v415.z.literal("assistant"),
|
|
2599
|
+
id: import_v415.z.string(),
|
|
2600
|
+
content: import_v415.z.array(
|
|
2601
|
+
import_v415.z.object({
|
|
2602
|
+
type: import_v415.z.literal("output_text"),
|
|
2603
|
+
text: import_v415.z.string(),
|
|
2521
2604
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2522
|
-
annotations:
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
type:
|
|
2526
|
-
start_index:
|
|
2527
|
-
end_index:
|
|
2528
|
-
url:
|
|
2529
|
-
title:
|
|
2605
|
+
annotations: import_v415.z.array(
|
|
2606
|
+
import_v415.z.discriminatedUnion("type", [
|
|
2607
|
+
import_v415.z.object({
|
|
2608
|
+
type: import_v415.z.literal("url_citation"),
|
|
2609
|
+
start_index: import_v415.z.number(),
|
|
2610
|
+
end_index: import_v415.z.number(),
|
|
2611
|
+
url: import_v415.z.string(),
|
|
2612
|
+
title: import_v415.z.string()
|
|
2530
2613
|
}),
|
|
2531
|
-
|
|
2532
|
-
type:
|
|
2533
|
-
file_id:
|
|
2534
|
-
filename:
|
|
2535
|
-
index:
|
|
2536
|
-
start_index:
|
|
2537
|
-
end_index:
|
|
2538
|
-
quote:
|
|
2614
|
+
import_v415.z.object({
|
|
2615
|
+
type: import_v415.z.literal("file_citation"),
|
|
2616
|
+
file_id: import_v415.z.string(),
|
|
2617
|
+
filename: import_v415.z.string().nullish(),
|
|
2618
|
+
index: import_v415.z.number().nullish(),
|
|
2619
|
+
start_index: import_v415.z.number().nullish(),
|
|
2620
|
+
end_index: import_v415.z.number().nullish(),
|
|
2621
|
+
quote: import_v415.z.string().nullish()
|
|
2539
2622
|
}),
|
|
2540
|
-
|
|
2541
|
-
type:
|
|
2623
|
+
import_v415.z.object({
|
|
2624
|
+
type: import_v415.z.literal("container_file_citation")
|
|
2542
2625
|
})
|
|
2543
2626
|
])
|
|
2544
2627
|
)
|
|
2545
2628
|
})
|
|
2546
2629
|
)
|
|
2547
2630
|
}),
|
|
2631
|
+
webSearchCallItem,
|
|
2632
|
+
fileSearchCallItem,
|
|
2548
2633
|
codeInterpreterCallItem,
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2634
|
+
imageGenerationCallItem,
|
|
2635
|
+
import_v415.z.object({
|
|
2636
|
+
type: import_v415.z.literal("function_call"),
|
|
2637
|
+
call_id: import_v415.z.string(),
|
|
2638
|
+
name: import_v415.z.string(),
|
|
2639
|
+
arguments: import_v415.z.string(),
|
|
2640
|
+
id: import_v415.z.string()
|
|
2555
2641
|
}),
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
status: import_v414.z.string().optional()
|
|
2642
|
+
import_v415.z.object({
|
|
2643
|
+
type: import_v415.z.literal("computer_call"),
|
|
2644
|
+
id: import_v415.z.string(),
|
|
2645
|
+
status: import_v415.z.string().optional()
|
|
2561
2646
|
}),
|
|
2562
|
-
|
|
2563
|
-
type:
|
|
2564
|
-
id:
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
file_id: import_v414.z.string(),
|
|
2571
|
-
filename: import_v414.z.string(),
|
|
2572
|
-
score: import_v414.z.number(),
|
|
2573
|
-
text: import_v414.z.string()
|
|
2574
|
-
})
|
|
2575
|
-
})
|
|
2576
|
-
).nullish()
|
|
2577
|
-
}),
|
|
2578
|
-
import_v414.z.object({
|
|
2579
|
-
type: import_v414.z.literal("reasoning"),
|
|
2580
|
-
id: import_v414.z.string(),
|
|
2581
|
-
encrypted_content: import_v414.z.string().nullish(),
|
|
2582
|
-
summary: import_v414.z.array(
|
|
2583
|
-
import_v414.z.object({
|
|
2584
|
-
type: import_v414.z.literal("summary_text"),
|
|
2585
|
-
text: import_v414.z.string()
|
|
2647
|
+
import_v415.z.object({
|
|
2648
|
+
type: import_v415.z.literal("reasoning"),
|
|
2649
|
+
id: import_v415.z.string(),
|
|
2650
|
+
encrypted_content: import_v415.z.string().nullish(),
|
|
2651
|
+
summary: import_v415.z.array(
|
|
2652
|
+
import_v415.z.object({
|
|
2653
|
+
type: import_v415.z.literal("summary_text"),
|
|
2654
|
+
text: import_v415.z.string()
|
|
2586
2655
|
})
|
|
2587
2656
|
)
|
|
2588
2657
|
})
|
|
2589
2658
|
])
|
|
2590
2659
|
),
|
|
2591
|
-
service_tier:
|
|
2592
|
-
incomplete_details:
|
|
2660
|
+
service_tier: import_v415.z.string().nullish(),
|
|
2661
|
+
incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullable(),
|
|
2593
2662
|
usage: usageSchema2
|
|
2594
2663
|
})
|
|
2595
2664
|
),
|
|
@@ -2630,6 +2699,25 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2630
2699
|
}
|
|
2631
2700
|
break;
|
|
2632
2701
|
}
|
|
2702
|
+
case "image_generation_call": {
|
|
2703
|
+
content.push({
|
|
2704
|
+
type: "tool-call",
|
|
2705
|
+
toolCallId: part.id,
|
|
2706
|
+
toolName: "image_generation",
|
|
2707
|
+
input: "{}",
|
|
2708
|
+
providerExecuted: true
|
|
2709
|
+
});
|
|
2710
|
+
content.push({
|
|
2711
|
+
type: "tool-result",
|
|
2712
|
+
toolCallId: part.id,
|
|
2713
|
+
toolName: "image_generation",
|
|
2714
|
+
result: {
|
|
2715
|
+
result: part.result
|
|
2716
|
+
},
|
|
2717
|
+
providerExecuted: true
|
|
2718
|
+
});
|
|
2719
|
+
break;
|
|
2720
|
+
}
|
|
2633
2721
|
case "message": {
|
|
2634
2722
|
for (const contentPart of part.content) {
|
|
2635
2723
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
@@ -2660,7 +2748,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2660
2748
|
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils13.generateId)(),
|
|
2661
2749
|
mediaType: "text/plain",
|
|
2662
2750
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
2663
|
-
filename: (_l = annotation.filename) != null ? _l : annotation.file_id
|
|
2751
|
+
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
2752
|
+
fileId: annotation.file_id,
|
|
2753
|
+
startIndex: (_m = annotation.start_index) != null ? _m : void 0,
|
|
2754
|
+
endIndex: (_n = annotation.end_index) != null ? _n : void 0
|
|
2664
2755
|
});
|
|
2665
2756
|
}
|
|
2666
2757
|
}
|
|
@@ -2724,7 +2815,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2724
2815
|
type: "tool-call",
|
|
2725
2816
|
toolCallId: part.id,
|
|
2726
2817
|
toolName: "file_search",
|
|
2727
|
-
input: "",
|
|
2818
|
+
input: "{}",
|
|
2728
2819
|
providerExecuted: true
|
|
2729
2820
|
});
|
|
2730
2821
|
content.push({
|
|
@@ -2732,10 +2823,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2732
2823
|
toolCallId: part.id,
|
|
2733
2824
|
toolName: "file_search",
|
|
2734
2825
|
result: {
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2826
|
+
queries: part.queries,
|
|
2827
|
+
results: (_p = (_o = part.results) == null ? void 0 : _o.map((result) => ({
|
|
2828
|
+
attributes: result.attributes,
|
|
2829
|
+
fileId: result.file_id,
|
|
2830
|
+
filename: result.filename,
|
|
2831
|
+
score: result.score,
|
|
2832
|
+
text: result.text
|
|
2833
|
+
}))) != null ? _p : null
|
|
2739
2834
|
},
|
|
2740
2835
|
providerExecuted: true
|
|
2741
2836
|
});
|
|
@@ -2777,15 +2872,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2777
2872
|
return {
|
|
2778
2873
|
content,
|
|
2779
2874
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2780
|
-
finishReason: (
|
|
2875
|
+
finishReason: (_q = response.incomplete_details) == null ? void 0 : _q.reason,
|
|
2781
2876
|
hasFunctionCall
|
|
2782
2877
|
}),
|
|
2783
2878
|
usage: {
|
|
2784
2879
|
inputTokens: response.usage.input_tokens,
|
|
2785
2880
|
outputTokens: response.usage.output_tokens,
|
|
2786
2881
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2787
|
-
reasoningTokens: (
|
|
2788
|
-
cachedInputTokens: (
|
|
2882
|
+
reasoningTokens: (_s = (_r = response.usage.output_tokens_details) == null ? void 0 : _r.reasoning_tokens) != null ? _s : void 0,
|
|
2883
|
+
cachedInputTokens: (_u = (_t = response.usage.input_tokens_details) == null ? void 0 : _t.cached_tokens) != null ? _u : void 0
|
|
2789
2884
|
},
|
|
2790
2885
|
request: { body },
|
|
2791
2886
|
response: {
|
|
@@ -2842,7 +2937,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2842
2937
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2843
2938
|
},
|
|
2844
2939
|
transform(chunk, controller) {
|
|
2845
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2940
|
+
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;
|
|
2846
2941
|
if (options.includeRawChunks) {
|
|
2847
2942
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2848
2943
|
}
|
|
@@ -2884,14 +2979,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2884
2979
|
toolName: "computer_use"
|
|
2885
2980
|
});
|
|
2886
2981
|
} else if (value.item.type === "file_search_call") {
|
|
2887
|
-
|
|
2982
|
+
controller.enqueue({
|
|
2983
|
+
type: "tool-call",
|
|
2984
|
+
toolCallId: value.item.id,
|
|
2888
2985
|
toolName: "file_search",
|
|
2889
|
-
|
|
2890
|
-
|
|
2986
|
+
input: "{}",
|
|
2987
|
+
providerExecuted: true
|
|
2988
|
+
});
|
|
2989
|
+
} else if (value.item.type === "image_generation_call") {
|
|
2891
2990
|
controller.enqueue({
|
|
2892
|
-
type: "tool-
|
|
2893
|
-
|
|
2894
|
-
toolName: "
|
|
2991
|
+
type: "tool-call",
|
|
2992
|
+
toolCallId: value.item.id,
|
|
2993
|
+
toolName: "image_generation",
|
|
2994
|
+
input: "{}",
|
|
2995
|
+
providerExecuted: true
|
|
2895
2996
|
});
|
|
2896
2997
|
} else if (value.item.type === "message") {
|
|
2897
2998
|
controller.enqueue({
|
|
@@ -2983,26 +3084,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2983
3084
|
});
|
|
2984
3085
|
} else if (value.item.type === "file_search_call") {
|
|
2985
3086
|
ongoingToolCalls[value.output_index] = void 0;
|
|
2986
|
-
controller.enqueue({
|
|
2987
|
-
type: "tool-input-end",
|
|
2988
|
-
id: value.item.id
|
|
2989
|
-
});
|
|
2990
|
-
controller.enqueue({
|
|
2991
|
-
type: "tool-call",
|
|
2992
|
-
toolCallId: value.item.id,
|
|
2993
|
-
toolName: "file_search",
|
|
2994
|
-
input: "",
|
|
2995
|
-
providerExecuted: true
|
|
2996
|
-
});
|
|
2997
3087
|
controller.enqueue({
|
|
2998
3088
|
type: "tool-result",
|
|
2999
3089
|
toolCallId: value.item.id,
|
|
3000
3090
|
toolName: "file_search",
|
|
3001
3091
|
result: {
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3092
|
+
queries: value.item.queries,
|
|
3093
|
+
results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
|
|
3094
|
+
attributes: result.attributes,
|
|
3095
|
+
fileId: result.file_id,
|
|
3096
|
+
filename: result.filename,
|
|
3097
|
+
score: result.score,
|
|
3098
|
+
text: result.text
|
|
3099
|
+
}))) != null ? _c : null
|
|
3006
3100
|
},
|
|
3007
3101
|
providerExecuted: true
|
|
3008
3102
|
});
|
|
@@ -3026,6 +3120,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3026
3120
|
},
|
|
3027
3121
|
providerExecuted: true
|
|
3028
3122
|
});
|
|
3123
|
+
} else if (value.item.type === "image_generation_call") {
|
|
3124
|
+
controller.enqueue({
|
|
3125
|
+
type: "tool-result",
|
|
3126
|
+
toolCallId: value.item.id,
|
|
3127
|
+
toolName: "image_generation",
|
|
3128
|
+
result: {
|
|
3129
|
+
result: value.item.result
|
|
3130
|
+
},
|
|
3131
|
+
providerExecuted: true
|
|
3132
|
+
});
|
|
3029
3133
|
} else if (value.item.type === "message") {
|
|
3030
3134
|
controller.enqueue({
|
|
3031
3135
|
type: "text-end",
|
|
@@ -3040,7 +3144,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3040
3144
|
providerMetadata: {
|
|
3041
3145
|
openai: {
|
|
3042
3146
|
itemId: value.item.id,
|
|
3043
|
-
reasoningEncryptedContent: (
|
|
3147
|
+
reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
|
|
3044
3148
|
}
|
|
3045
3149
|
}
|
|
3046
3150
|
});
|
|
@@ -3070,12 +3174,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3070
3174
|
id: value.item_id,
|
|
3071
3175
|
delta: value.delta
|
|
3072
3176
|
});
|
|
3073
|
-
if (((
|
|
3177
|
+
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
3074
3178
|
logprobs.push(value.logprobs);
|
|
3075
3179
|
}
|
|
3076
3180
|
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
3077
3181
|
if (value.summary_index > 0) {
|
|
3078
|
-
(
|
|
3182
|
+
(_g = activeReasoning[value.item_id]) == null ? void 0 : _g.summaryParts.push(
|
|
3079
3183
|
value.summary_index
|
|
3080
3184
|
);
|
|
3081
3185
|
controller.enqueue({
|
|
@@ -3084,7 +3188,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3084
3188
|
providerMetadata: {
|
|
3085
3189
|
openai: {
|
|
3086
3190
|
itemId: value.item_id,
|
|
3087
|
-
reasoningEncryptedContent: (
|
|
3191
|
+
reasoningEncryptedContent: (_i = (_h = activeReasoning[value.item_id]) == null ? void 0 : _h.encryptedContent) != null ? _i : null
|
|
3088
3192
|
}
|
|
3089
3193
|
}
|
|
3090
3194
|
});
|
|
@@ -3102,14 +3206,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3102
3206
|
});
|
|
3103
3207
|
} else if (isResponseFinishedChunk(value)) {
|
|
3104
3208
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3105
|
-
finishReason: (
|
|
3209
|
+
finishReason: (_j = value.response.incomplete_details) == null ? void 0 : _j.reason,
|
|
3106
3210
|
hasFunctionCall
|
|
3107
3211
|
});
|
|
3108
3212
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3109
3213
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3110
3214
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3111
|
-
usage.reasoningTokens = (
|
|
3112
|
-
usage.cachedInputTokens = (
|
|
3215
|
+
usage.reasoningTokens = (_l = (_k = value.response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0;
|
|
3216
|
+
usage.cachedInputTokens = (_n = (_m = value.response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0;
|
|
3113
3217
|
if (typeof value.response.service_tier === "string") {
|
|
3114
3218
|
serviceTier = value.response.service_tier;
|
|
3115
3219
|
}
|
|
@@ -3118,7 +3222,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3118
3222
|
controller.enqueue({
|
|
3119
3223
|
type: "source",
|
|
3120
3224
|
sourceType: "url",
|
|
3121
|
-
id: (
|
|
3225
|
+
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils13.generateId)(),
|
|
3122
3226
|
url: value.annotation.url,
|
|
3123
3227
|
title: value.annotation.title
|
|
3124
3228
|
});
|
|
@@ -3126,10 +3230,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3126
3230
|
controller.enqueue({
|
|
3127
3231
|
type: "source",
|
|
3128
3232
|
sourceType: "document",
|
|
3129
|
-
id: (
|
|
3233
|
+
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils13.generateId)(),
|
|
3130
3234
|
mediaType: "text/plain",
|
|
3131
|
-
title: (
|
|
3132
|
-
filename: (
|
|
3235
|
+
title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
|
|
3236
|
+
filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id,
|
|
3237
|
+
fileId: value.annotation.file_id,
|
|
3238
|
+
startIndex: (_x = value.annotation.start_index) != null ? _x : void 0,
|
|
3239
|
+
endIndex: (_y = value.annotation.end_index) != null ? _y : void 0
|
|
3133
3240
|
});
|
|
3134
3241
|
}
|
|
3135
3242
|
} else if (isErrorChunk(value)) {
|
|
@@ -3162,177 +3269,155 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3162
3269
|
};
|
|
3163
3270
|
}
|
|
3164
3271
|
};
|
|
3165
|
-
var usageSchema2 =
|
|
3166
|
-
input_tokens:
|
|
3167
|
-
input_tokens_details:
|
|
3168
|
-
output_tokens:
|
|
3169
|
-
output_tokens_details:
|
|
3272
|
+
var usageSchema2 = import_v415.z.object({
|
|
3273
|
+
input_tokens: import_v415.z.number(),
|
|
3274
|
+
input_tokens_details: import_v415.z.object({ cached_tokens: import_v415.z.number().nullish() }).nullish(),
|
|
3275
|
+
output_tokens: import_v415.z.number(),
|
|
3276
|
+
output_tokens_details: import_v415.z.object({ reasoning_tokens: import_v415.z.number().nullish() }).nullish()
|
|
3170
3277
|
});
|
|
3171
|
-
var textDeltaChunkSchema =
|
|
3172
|
-
type:
|
|
3173
|
-
item_id:
|
|
3174
|
-
delta:
|
|
3278
|
+
var textDeltaChunkSchema = import_v415.z.object({
|
|
3279
|
+
type: import_v415.z.literal("response.output_text.delta"),
|
|
3280
|
+
item_id: import_v415.z.string(),
|
|
3281
|
+
delta: import_v415.z.string(),
|
|
3175
3282
|
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3176
3283
|
});
|
|
3177
|
-
var errorChunkSchema =
|
|
3178
|
-
type:
|
|
3179
|
-
code:
|
|
3180
|
-
message:
|
|
3181
|
-
param:
|
|
3182
|
-
sequence_number:
|
|
3284
|
+
var errorChunkSchema = import_v415.z.object({
|
|
3285
|
+
type: import_v415.z.literal("error"),
|
|
3286
|
+
code: import_v415.z.string(),
|
|
3287
|
+
message: import_v415.z.string(),
|
|
3288
|
+
param: import_v415.z.string().nullish(),
|
|
3289
|
+
sequence_number: import_v415.z.number()
|
|
3183
3290
|
});
|
|
3184
|
-
var responseFinishedChunkSchema =
|
|
3185
|
-
type:
|
|
3186
|
-
response:
|
|
3187
|
-
incomplete_details:
|
|
3291
|
+
var responseFinishedChunkSchema = import_v415.z.object({
|
|
3292
|
+
type: import_v415.z.enum(["response.completed", "response.incomplete"]),
|
|
3293
|
+
response: import_v415.z.object({
|
|
3294
|
+
incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
|
|
3188
3295
|
usage: usageSchema2,
|
|
3189
|
-
service_tier:
|
|
3296
|
+
service_tier: import_v415.z.string().nullish()
|
|
3190
3297
|
})
|
|
3191
3298
|
});
|
|
3192
|
-
var responseCreatedChunkSchema =
|
|
3193
|
-
type:
|
|
3194
|
-
response:
|
|
3195
|
-
id:
|
|
3196
|
-
created_at:
|
|
3197
|
-
model:
|
|
3198
|
-
service_tier:
|
|
3299
|
+
var responseCreatedChunkSchema = import_v415.z.object({
|
|
3300
|
+
type: import_v415.z.literal("response.created"),
|
|
3301
|
+
response: import_v415.z.object({
|
|
3302
|
+
id: import_v415.z.string(),
|
|
3303
|
+
created_at: import_v415.z.number(),
|
|
3304
|
+
model: import_v415.z.string(),
|
|
3305
|
+
service_tier: import_v415.z.string().nullish()
|
|
3199
3306
|
})
|
|
3200
3307
|
});
|
|
3201
|
-
var responseOutputItemAddedSchema =
|
|
3202
|
-
type:
|
|
3203
|
-
output_index:
|
|
3204
|
-
item:
|
|
3205
|
-
|
|
3206
|
-
type:
|
|
3207
|
-
id:
|
|
3308
|
+
var responseOutputItemAddedSchema = import_v415.z.object({
|
|
3309
|
+
type: import_v415.z.literal("response.output_item.added"),
|
|
3310
|
+
output_index: import_v415.z.number(),
|
|
3311
|
+
item: import_v415.z.discriminatedUnion("type", [
|
|
3312
|
+
import_v415.z.object({
|
|
3313
|
+
type: import_v415.z.literal("message"),
|
|
3314
|
+
id: import_v415.z.string()
|
|
3208
3315
|
}),
|
|
3209
|
-
|
|
3210
|
-
type:
|
|
3211
|
-
id:
|
|
3212
|
-
encrypted_content:
|
|
3316
|
+
import_v415.z.object({
|
|
3317
|
+
type: import_v415.z.literal("reasoning"),
|
|
3318
|
+
id: import_v415.z.string(),
|
|
3319
|
+
encrypted_content: import_v415.z.string().nullish()
|
|
3213
3320
|
}),
|
|
3214
|
-
|
|
3215
|
-
type:
|
|
3216
|
-
id:
|
|
3217
|
-
call_id:
|
|
3218
|
-
name:
|
|
3219
|
-
arguments:
|
|
3321
|
+
import_v415.z.object({
|
|
3322
|
+
type: import_v415.z.literal("function_call"),
|
|
3323
|
+
id: import_v415.z.string(),
|
|
3324
|
+
call_id: import_v415.z.string(),
|
|
3325
|
+
name: import_v415.z.string(),
|
|
3326
|
+
arguments: import_v415.z.string()
|
|
3220
3327
|
}),
|
|
3221
|
-
|
|
3222
|
-
type:
|
|
3223
|
-
id:
|
|
3224
|
-
status:
|
|
3225
|
-
action:
|
|
3226
|
-
type:
|
|
3227
|
-
query:
|
|
3328
|
+
import_v415.z.object({
|
|
3329
|
+
type: import_v415.z.literal("web_search_call"),
|
|
3330
|
+
id: import_v415.z.string(),
|
|
3331
|
+
status: import_v415.z.string(),
|
|
3332
|
+
action: import_v415.z.object({
|
|
3333
|
+
type: import_v415.z.literal("search"),
|
|
3334
|
+
query: import_v415.z.string().optional()
|
|
3228
3335
|
}).nullish()
|
|
3229
3336
|
}),
|
|
3230
|
-
|
|
3231
|
-
type:
|
|
3232
|
-
id:
|
|
3233
|
-
status:
|
|
3337
|
+
import_v415.z.object({
|
|
3338
|
+
type: import_v415.z.literal("computer_call"),
|
|
3339
|
+
id: import_v415.z.string(),
|
|
3340
|
+
status: import_v415.z.string()
|
|
3234
3341
|
}),
|
|
3235
|
-
|
|
3236
|
-
type:
|
|
3237
|
-
id:
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
attributes: import_v414.z.object({
|
|
3243
|
-
file_id: import_v414.z.string(),
|
|
3244
|
-
filename: import_v414.z.string(),
|
|
3245
|
-
score: import_v414.z.number(),
|
|
3246
|
-
text: import_v414.z.string()
|
|
3247
|
-
})
|
|
3248
|
-
})
|
|
3249
|
-
).optional()
|
|
3342
|
+
import_v415.z.object({
|
|
3343
|
+
type: import_v415.z.literal("file_search_call"),
|
|
3344
|
+
id: import_v415.z.string()
|
|
3345
|
+
}),
|
|
3346
|
+
import_v415.z.object({
|
|
3347
|
+
type: import_v415.z.literal("image_generation_call"),
|
|
3348
|
+
id: import_v415.z.string()
|
|
3250
3349
|
})
|
|
3251
3350
|
])
|
|
3252
3351
|
});
|
|
3253
|
-
var responseOutputItemDoneSchema =
|
|
3254
|
-
type:
|
|
3255
|
-
output_index:
|
|
3256
|
-
item:
|
|
3257
|
-
|
|
3258
|
-
type:
|
|
3259
|
-
id:
|
|
3352
|
+
var responseOutputItemDoneSchema = import_v415.z.object({
|
|
3353
|
+
type: import_v415.z.literal("response.output_item.done"),
|
|
3354
|
+
output_index: import_v415.z.number(),
|
|
3355
|
+
item: import_v415.z.discriminatedUnion("type", [
|
|
3356
|
+
import_v415.z.object({
|
|
3357
|
+
type: import_v415.z.literal("message"),
|
|
3358
|
+
id: import_v415.z.string()
|
|
3260
3359
|
}),
|
|
3261
|
-
|
|
3262
|
-
type:
|
|
3263
|
-
id:
|
|
3264
|
-
encrypted_content:
|
|
3360
|
+
import_v415.z.object({
|
|
3361
|
+
type: import_v415.z.literal("reasoning"),
|
|
3362
|
+
id: import_v415.z.string(),
|
|
3363
|
+
encrypted_content: import_v415.z.string().nullish()
|
|
3265
3364
|
}),
|
|
3266
|
-
|
|
3267
|
-
type:
|
|
3268
|
-
id:
|
|
3269
|
-
call_id:
|
|
3270
|
-
name:
|
|
3271
|
-
arguments:
|
|
3272
|
-
status:
|
|
3365
|
+
import_v415.z.object({
|
|
3366
|
+
type: import_v415.z.literal("function_call"),
|
|
3367
|
+
id: import_v415.z.string(),
|
|
3368
|
+
call_id: import_v415.z.string(),
|
|
3369
|
+
name: import_v415.z.string(),
|
|
3370
|
+
arguments: import_v415.z.string(),
|
|
3371
|
+
status: import_v415.z.literal("completed")
|
|
3273
3372
|
}),
|
|
3274
3373
|
codeInterpreterCallItem,
|
|
3374
|
+
imageGenerationCallItem,
|
|
3275
3375
|
webSearchCallItem,
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
import_v414.z.object({
|
|
3282
|
-
type: import_v414.z.literal("file_search_call"),
|
|
3283
|
-
id: import_v414.z.string(),
|
|
3284
|
-
status: import_v414.z.literal("completed"),
|
|
3285
|
-
queries: import_v414.z.array(import_v414.z.string()).nullish(),
|
|
3286
|
-
results: import_v414.z.array(
|
|
3287
|
-
import_v414.z.object({
|
|
3288
|
-
attributes: import_v414.z.object({
|
|
3289
|
-
file_id: import_v414.z.string(),
|
|
3290
|
-
filename: import_v414.z.string(),
|
|
3291
|
-
score: import_v414.z.number(),
|
|
3292
|
-
text: import_v414.z.string()
|
|
3293
|
-
})
|
|
3294
|
-
})
|
|
3295
|
-
).nullish()
|
|
3376
|
+
fileSearchCallItem,
|
|
3377
|
+
import_v415.z.object({
|
|
3378
|
+
type: import_v415.z.literal("computer_call"),
|
|
3379
|
+
id: import_v415.z.string(),
|
|
3380
|
+
status: import_v415.z.literal("completed")
|
|
3296
3381
|
})
|
|
3297
3382
|
])
|
|
3298
3383
|
});
|
|
3299
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
3300
|
-
type:
|
|
3301
|
-
item_id:
|
|
3302
|
-
output_index:
|
|
3303
|
-
delta:
|
|
3384
|
+
var responseFunctionCallArgumentsDeltaSchema = import_v415.z.object({
|
|
3385
|
+
type: import_v415.z.literal("response.function_call_arguments.delta"),
|
|
3386
|
+
item_id: import_v415.z.string(),
|
|
3387
|
+
output_index: import_v415.z.number(),
|
|
3388
|
+
delta: import_v415.z.string()
|
|
3304
3389
|
});
|
|
3305
|
-
var responseAnnotationAddedSchema =
|
|
3306
|
-
type:
|
|
3307
|
-
annotation:
|
|
3308
|
-
|
|
3309
|
-
type:
|
|
3310
|
-
url:
|
|
3311
|
-
title:
|
|
3390
|
+
var responseAnnotationAddedSchema = import_v415.z.object({
|
|
3391
|
+
type: import_v415.z.literal("response.output_text.annotation.added"),
|
|
3392
|
+
annotation: import_v415.z.discriminatedUnion("type", [
|
|
3393
|
+
import_v415.z.object({
|
|
3394
|
+
type: import_v415.z.literal("url_citation"),
|
|
3395
|
+
url: import_v415.z.string(),
|
|
3396
|
+
title: import_v415.z.string()
|
|
3312
3397
|
}),
|
|
3313
|
-
|
|
3314
|
-
type:
|
|
3315
|
-
file_id:
|
|
3316
|
-
filename:
|
|
3317
|
-
index:
|
|
3318
|
-
start_index:
|
|
3319
|
-
end_index:
|
|
3320
|
-
quote:
|
|
3398
|
+
import_v415.z.object({
|
|
3399
|
+
type: import_v415.z.literal("file_citation"),
|
|
3400
|
+
file_id: import_v415.z.string(),
|
|
3401
|
+
filename: import_v415.z.string().nullish(),
|
|
3402
|
+
index: import_v415.z.number().nullish(),
|
|
3403
|
+
start_index: import_v415.z.number().nullish(),
|
|
3404
|
+
end_index: import_v415.z.number().nullish(),
|
|
3405
|
+
quote: import_v415.z.string().nullish()
|
|
3321
3406
|
})
|
|
3322
3407
|
])
|
|
3323
3408
|
});
|
|
3324
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
3325
|
-
type:
|
|
3326
|
-
item_id:
|
|
3327
|
-
summary_index:
|
|
3409
|
+
var responseReasoningSummaryPartAddedSchema = import_v415.z.object({
|
|
3410
|
+
type: import_v415.z.literal("response.reasoning_summary_part.added"),
|
|
3411
|
+
item_id: import_v415.z.string(),
|
|
3412
|
+
summary_index: import_v415.z.number()
|
|
3328
3413
|
});
|
|
3329
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
3330
|
-
type:
|
|
3331
|
-
item_id:
|
|
3332
|
-
summary_index:
|
|
3333
|
-
delta:
|
|
3414
|
+
var responseReasoningSummaryTextDeltaSchema = import_v415.z.object({
|
|
3415
|
+
type: import_v415.z.literal("response.reasoning_summary_text.delta"),
|
|
3416
|
+
item_id: import_v415.z.string(),
|
|
3417
|
+
summary_index: import_v415.z.number(),
|
|
3418
|
+
delta: import_v415.z.string()
|
|
3334
3419
|
});
|
|
3335
|
-
var openaiResponsesChunkSchema =
|
|
3420
|
+
var openaiResponsesChunkSchema = import_v415.z.union([
|
|
3336
3421
|
textDeltaChunkSchema,
|
|
3337
3422
|
responseFinishedChunkSchema,
|
|
3338
3423
|
responseCreatedChunkSchema,
|
|
@@ -3343,7 +3428,7 @@ var openaiResponsesChunkSchema = import_v414.z.union([
|
|
|
3343
3428
|
responseReasoningSummaryPartAddedSchema,
|
|
3344
3429
|
responseReasoningSummaryTextDeltaSchema,
|
|
3345
3430
|
errorChunkSchema,
|
|
3346
|
-
|
|
3431
|
+
import_v415.z.object({ type: import_v415.z.string() }).loose()
|
|
3347
3432
|
// fallback for unknown chunks
|
|
3348
3433
|
]);
|
|
3349
3434
|
function isTextDeltaChunk(chunk) {
|
|
@@ -3416,27 +3501,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
3416
3501
|
isReasoningModel: false
|
|
3417
3502
|
};
|
|
3418
3503
|
}
|
|
3419
|
-
var openaiResponsesProviderOptionsSchema =
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
previousResponseId: import_v414.z.string().nullish(),
|
|
3423
|
-
store: import_v414.z.boolean().nullish(),
|
|
3424
|
-
user: import_v414.z.string().nullish(),
|
|
3425
|
-
reasoningEffort: import_v414.z.string().nullish(),
|
|
3426
|
-
strictJsonSchema: import_v414.z.boolean().nullish(),
|
|
3427
|
-
instructions: import_v414.z.string().nullish(),
|
|
3428
|
-
reasoningSummary: import_v414.z.string().nullish(),
|
|
3429
|
-
serviceTier: import_v414.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
3430
|
-
include: import_v414.z.array(
|
|
3431
|
-
import_v414.z.enum([
|
|
3504
|
+
var openaiResponsesProviderOptionsSchema = import_v415.z.object({
|
|
3505
|
+
include: import_v415.z.array(
|
|
3506
|
+
import_v415.z.enum([
|
|
3432
3507
|
"reasoning.encrypted_content",
|
|
3433
3508
|
"file_search_call.results",
|
|
3434
3509
|
"message.output_text.logprobs"
|
|
3435
3510
|
])
|
|
3436
3511
|
).nullish(),
|
|
3437
|
-
|
|
3438
|
-
promptCacheKey: import_v414.z.string().nullish(),
|
|
3439
|
-
safetyIdentifier: import_v414.z.string().nullish(),
|
|
3512
|
+
instructions: import_v415.z.string().nullish(),
|
|
3440
3513
|
/**
|
|
3441
3514
|
* Return the log probabilities of the tokens.
|
|
3442
3515
|
*
|
|
@@ -3449,15 +3522,33 @@ var openaiResponsesProviderOptionsSchema = import_v414.z.object({
|
|
|
3449
3522
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3450
3523
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3451
3524
|
*/
|
|
3452
|
-
logprobs:
|
|
3525
|
+
logprobs: import_v415.z.union([import_v415.z.boolean(), import_v415.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3526
|
+
/**
|
|
3527
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3528
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3529
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
3530
|
+
*/
|
|
3531
|
+
maxToolCalls: import_v415.z.number().nullish(),
|
|
3532
|
+
metadata: import_v415.z.any().nullish(),
|
|
3533
|
+
parallelToolCalls: import_v415.z.boolean().nullish(),
|
|
3534
|
+
previousResponseId: import_v415.z.string().nullish(),
|
|
3535
|
+
promptCacheKey: import_v415.z.string().nullish(),
|
|
3536
|
+
reasoningEffort: import_v415.z.string().nullish(),
|
|
3537
|
+
reasoningSummary: import_v415.z.string().nullish(),
|
|
3538
|
+
safetyIdentifier: import_v415.z.string().nullish(),
|
|
3539
|
+
serviceTier: import_v415.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
3540
|
+
store: import_v415.z.boolean().nullish(),
|
|
3541
|
+
strictJsonSchema: import_v415.z.boolean().nullish(),
|
|
3542
|
+
textVerbosity: import_v415.z.enum(["low", "medium", "high"]).nullish(),
|
|
3543
|
+
user: import_v415.z.string().nullish()
|
|
3453
3544
|
});
|
|
3454
3545
|
|
|
3455
3546
|
// src/speech/openai-speech-model.ts
|
|
3456
3547
|
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
3457
|
-
var
|
|
3458
|
-
var OpenAIProviderOptionsSchema =
|
|
3459
|
-
instructions:
|
|
3460
|
-
speed:
|
|
3548
|
+
var import_v416 = require("zod/v4");
|
|
3549
|
+
var OpenAIProviderOptionsSchema = import_v416.z.object({
|
|
3550
|
+
instructions: import_v416.z.string().nullish(),
|
|
3551
|
+
speed: import_v416.z.number().min(0.25).max(4).default(1).nullish()
|
|
3461
3552
|
});
|
|
3462
3553
|
var OpenAISpeechModel = class {
|
|
3463
3554
|
constructor(modelId, config) {
|
|
@@ -3561,33 +3652,33 @@ var OpenAISpeechModel = class {
|
|
|
3561
3652
|
|
|
3562
3653
|
// src/transcription/openai-transcription-model.ts
|
|
3563
3654
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
3564
|
-
var
|
|
3655
|
+
var import_v418 = require("zod/v4");
|
|
3565
3656
|
|
|
3566
3657
|
// src/transcription/openai-transcription-options.ts
|
|
3567
|
-
var
|
|
3568
|
-
var openAITranscriptionProviderOptions =
|
|
3658
|
+
var import_v417 = require("zod/v4");
|
|
3659
|
+
var openAITranscriptionProviderOptions = import_v417.z.object({
|
|
3569
3660
|
/**
|
|
3570
3661
|
* Additional information to include in the transcription response.
|
|
3571
3662
|
*/
|
|
3572
|
-
include:
|
|
3663
|
+
include: import_v417.z.array(import_v417.z.string()).optional(),
|
|
3573
3664
|
/**
|
|
3574
3665
|
* The language of the input audio in ISO-639-1 format.
|
|
3575
3666
|
*/
|
|
3576
|
-
language:
|
|
3667
|
+
language: import_v417.z.string().optional(),
|
|
3577
3668
|
/**
|
|
3578
3669
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
3579
3670
|
*/
|
|
3580
|
-
prompt:
|
|
3671
|
+
prompt: import_v417.z.string().optional(),
|
|
3581
3672
|
/**
|
|
3582
3673
|
* The sampling temperature, between 0 and 1.
|
|
3583
3674
|
* @default 0
|
|
3584
3675
|
*/
|
|
3585
|
-
temperature:
|
|
3676
|
+
temperature: import_v417.z.number().min(0).max(1).default(0).optional(),
|
|
3586
3677
|
/**
|
|
3587
3678
|
* The timestamp granularities to populate for this transcription.
|
|
3588
3679
|
* @default ['segment']
|
|
3589
3680
|
*/
|
|
3590
|
-
timestampGranularities:
|
|
3681
|
+
timestampGranularities: import_v417.z.array(import_v417.z.enum(["word", "segment"])).default(["segment"]).optional()
|
|
3591
3682
|
});
|
|
3592
3683
|
|
|
3593
3684
|
// src/transcription/openai-transcription-model.ts
|
|
@@ -3756,29 +3847,29 @@ var OpenAITranscriptionModel = class {
|
|
|
3756
3847
|
};
|
|
3757
3848
|
}
|
|
3758
3849
|
};
|
|
3759
|
-
var openaiTranscriptionResponseSchema =
|
|
3760
|
-
text:
|
|
3761
|
-
language:
|
|
3762
|
-
duration:
|
|
3763
|
-
words:
|
|
3764
|
-
|
|
3765
|
-
word:
|
|
3766
|
-
start:
|
|
3767
|
-
end:
|
|
3850
|
+
var openaiTranscriptionResponseSchema = import_v418.z.object({
|
|
3851
|
+
text: import_v418.z.string(),
|
|
3852
|
+
language: import_v418.z.string().nullish(),
|
|
3853
|
+
duration: import_v418.z.number().nullish(),
|
|
3854
|
+
words: import_v418.z.array(
|
|
3855
|
+
import_v418.z.object({
|
|
3856
|
+
word: import_v418.z.string(),
|
|
3857
|
+
start: import_v418.z.number(),
|
|
3858
|
+
end: import_v418.z.number()
|
|
3768
3859
|
})
|
|
3769
3860
|
).nullish(),
|
|
3770
|
-
segments:
|
|
3771
|
-
|
|
3772
|
-
id:
|
|
3773
|
-
seek:
|
|
3774
|
-
start:
|
|
3775
|
-
end:
|
|
3776
|
-
text:
|
|
3777
|
-
tokens:
|
|
3778
|
-
temperature:
|
|
3779
|
-
avg_logprob:
|
|
3780
|
-
compression_ratio:
|
|
3781
|
-
no_speech_prob:
|
|
3861
|
+
segments: import_v418.z.array(
|
|
3862
|
+
import_v418.z.object({
|
|
3863
|
+
id: import_v418.z.number(),
|
|
3864
|
+
seek: import_v418.z.number(),
|
|
3865
|
+
start: import_v418.z.number(),
|
|
3866
|
+
end: import_v418.z.number(),
|
|
3867
|
+
text: import_v418.z.string(),
|
|
3868
|
+
tokens: import_v418.z.array(import_v418.z.number()),
|
|
3869
|
+
temperature: import_v418.z.number(),
|
|
3870
|
+
avg_logprob: import_v418.z.number(),
|
|
3871
|
+
compression_ratio: import_v418.z.number(),
|
|
3872
|
+
no_speech_prob: import_v418.z.number()
|
|
3782
3873
|
})
|
|
3783
3874
|
).nullish()
|
|
3784
3875
|
});
|