@ai-sdk/openai 2.0.25 → 2.0.26
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 +7 -0
- package/dist/index.d.mts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +371 -320
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +340 -289
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +310 -263
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +298 -251
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -2149,8 +2149,8 @@ var OpenAISpeechModel = class {
|
|
|
2149
2149
|
|
|
2150
2150
|
// src/responses/openai-responses-language-model.ts
|
|
2151
2151
|
var import_provider8 = require("@ai-sdk/provider");
|
|
2152
|
-
var
|
|
2153
|
-
var
|
|
2152
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2153
|
+
var import_v417 = require("zod/v4");
|
|
2154
2154
|
|
|
2155
2155
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
2156
2156
|
var import_provider6 = require("@ai-sdk/provider");
|
|
@@ -2353,18 +2353,18 @@ var openaiResponsesReasoningProviderOptionsSchema = import_v414.z.object({
|
|
|
2353
2353
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
2354
2354
|
function mapOpenAIResponseFinishReason({
|
|
2355
2355
|
finishReason,
|
|
2356
|
-
|
|
2356
|
+
hasFunctionCall
|
|
2357
2357
|
}) {
|
|
2358
2358
|
switch (finishReason) {
|
|
2359
2359
|
case void 0:
|
|
2360
2360
|
case null:
|
|
2361
|
-
return
|
|
2361
|
+
return hasFunctionCall ? "tool-calls" : "stop";
|
|
2362
2362
|
case "max_output_tokens":
|
|
2363
2363
|
return "length";
|
|
2364
2364
|
case "content_filter":
|
|
2365
2365
|
return "content-filter";
|
|
2366
2366
|
default:
|
|
2367
|
-
return
|
|
2367
|
+
return hasFunctionCall ? "tool-calls" : "unknown";
|
|
2368
2368
|
}
|
|
2369
2369
|
}
|
|
2370
2370
|
|
|
@@ -2388,6 +2388,44 @@ var codeInterpreter = (0, import_provider_utils13.createProviderDefinedToolFacto
|
|
|
2388
2388
|
inputSchema: import_v415.z.object({})
|
|
2389
2389
|
});
|
|
2390
2390
|
|
|
2391
|
+
// src/tool/web-search.ts
|
|
2392
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2393
|
+
var import_v416 = require("zod/v4");
|
|
2394
|
+
var webSearchArgsSchema = import_v416.z.object({
|
|
2395
|
+
filters: import_v416.z.object({
|
|
2396
|
+
allowedDomains: import_v416.z.array(import_v416.z.string()).optional()
|
|
2397
|
+
}).optional(),
|
|
2398
|
+
searchContextSize: import_v416.z.enum(["low", "medium", "high"]).optional(),
|
|
2399
|
+
userLocation: import_v416.z.object({
|
|
2400
|
+
type: import_v416.z.literal("approximate"),
|
|
2401
|
+
country: import_v416.z.string().optional(),
|
|
2402
|
+
city: import_v416.z.string().optional(),
|
|
2403
|
+
region: import_v416.z.string().optional(),
|
|
2404
|
+
timezone: import_v416.z.string().optional()
|
|
2405
|
+
}).optional()
|
|
2406
|
+
});
|
|
2407
|
+
var factory = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2408
|
+
id: "openai.web_search",
|
|
2409
|
+
name: "web_search",
|
|
2410
|
+
inputSchema: import_v416.z.object({
|
|
2411
|
+
action: import_v416.z.discriminatedUnion("type", [
|
|
2412
|
+
import_v416.z.object({
|
|
2413
|
+
type: import_v416.z.literal("search"),
|
|
2414
|
+
query: import_v416.z.string().nullish()
|
|
2415
|
+
}),
|
|
2416
|
+
import_v416.z.object({
|
|
2417
|
+
type: import_v416.z.literal("open_page"),
|
|
2418
|
+
url: import_v416.z.string()
|
|
2419
|
+
}),
|
|
2420
|
+
import_v416.z.object({
|
|
2421
|
+
type: import_v416.z.literal("find"),
|
|
2422
|
+
url: import_v416.z.string(),
|
|
2423
|
+
pattern: import_v416.z.string()
|
|
2424
|
+
})
|
|
2425
|
+
]).nullish()
|
|
2426
|
+
})
|
|
2427
|
+
});
|
|
2428
|
+
|
|
2391
2429
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2392
2430
|
function prepareResponsesTools({
|
|
2393
2431
|
tools,
|
|
@@ -2433,6 +2471,16 @@ function prepareResponsesTools({
|
|
|
2433
2471
|
});
|
|
2434
2472
|
break;
|
|
2435
2473
|
}
|
|
2474
|
+
case "openai.web_search": {
|
|
2475
|
+
const args = webSearchArgsSchema.parse(tool.args);
|
|
2476
|
+
openaiTools.push({
|
|
2477
|
+
type: "web_search",
|
|
2478
|
+
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
2479
|
+
search_context_size: args.searchContextSize,
|
|
2480
|
+
user_location: args.userLocation
|
|
2481
|
+
});
|
|
2482
|
+
break;
|
|
2483
|
+
}
|
|
2436
2484
|
case "openai.code_interpreter": {
|
|
2437
2485
|
const args = codeInterpreterArgsSchema.parse(tool.args);
|
|
2438
2486
|
openaiTools.push({
|
|
@@ -2465,7 +2513,7 @@ function prepareResponsesTools({
|
|
|
2465
2513
|
case "tool":
|
|
2466
2514
|
return {
|
|
2467
2515
|
tools: openaiTools,
|
|
2468
|
-
toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
2516
|
+
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 },
|
|
2469
2517
|
toolWarnings
|
|
2470
2518
|
};
|
|
2471
2519
|
default: {
|
|
@@ -2478,35 +2526,35 @@ function prepareResponsesTools({
|
|
|
2478
2526
|
}
|
|
2479
2527
|
|
|
2480
2528
|
// src/responses/openai-responses-language-model.ts
|
|
2481
|
-
var webSearchCallItem =
|
|
2482
|
-
type:
|
|
2483
|
-
id:
|
|
2484
|
-
status:
|
|
2485
|
-
action:
|
|
2486
|
-
|
|
2487
|
-
type:
|
|
2488
|
-
query:
|
|
2529
|
+
var webSearchCallItem = import_v417.z.object({
|
|
2530
|
+
type: import_v417.z.literal("web_search_call"),
|
|
2531
|
+
id: import_v417.z.string(),
|
|
2532
|
+
status: import_v417.z.string(),
|
|
2533
|
+
action: import_v417.z.discriminatedUnion("type", [
|
|
2534
|
+
import_v417.z.object({
|
|
2535
|
+
type: import_v417.z.literal("search"),
|
|
2536
|
+
query: import_v417.z.string().nullish()
|
|
2489
2537
|
}),
|
|
2490
|
-
|
|
2491
|
-
type:
|
|
2492
|
-
url:
|
|
2538
|
+
import_v417.z.object({
|
|
2539
|
+
type: import_v417.z.literal("open_page"),
|
|
2540
|
+
url: import_v417.z.string()
|
|
2493
2541
|
}),
|
|
2494
|
-
|
|
2495
|
-
type:
|
|
2496
|
-
url:
|
|
2497
|
-
pattern:
|
|
2542
|
+
import_v417.z.object({
|
|
2543
|
+
type: import_v417.z.literal("find"),
|
|
2544
|
+
url: import_v417.z.string(),
|
|
2545
|
+
pattern: import_v417.z.string()
|
|
2498
2546
|
})
|
|
2499
2547
|
]).nullish()
|
|
2500
2548
|
});
|
|
2501
2549
|
var TOP_LOGPROBS_MAX = 20;
|
|
2502
|
-
var LOGPROBS_SCHEMA =
|
|
2503
|
-
|
|
2504
|
-
token:
|
|
2505
|
-
logprob:
|
|
2506
|
-
top_logprobs:
|
|
2507
|
-
|
|
2508
|
-
token:
|
|
2509
|
-
logprob:
|
|
2550
|
+
var LOGPROBS_SCHEMA = import_v417.z.array(
|
|
2551
|
+
import_v417.z.object({
|
|
2552
|
+
token: import_v417.z.string(),
|
|
2553
|
+
logprob: import_v417.z.number(),
|
|
2554
|
+
top_logprobs: import_v417.z.array(
|
|
2555
|
+
import_v417.z.object({
|
|
2556
|
+
token: import_v417.z.string(),
|
|
2557
|
+
logprob: import_v417.z.number()
|
|
2510
2558
|
})
|
|
2511
2559
|
)
|
|
2512
2560
|
})
|
|
@@ -2569,7 +2617,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2569
2617
|
fileIdPrefixes: this.config.fileIdPrefixes
|
|
2570
2618
|
});
|
|
2571
2619
|
warnings.push(...messageWarnings);
|
|
2572
|
-
const openaiOptions = await (0,
|
|
2620
|
+
const openaiOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2573
2621
|
provider: "openai",
|
|
2574
2622
|
providerOptions,
|
|
2575
2623
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -2704,98 +2752,98 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2704
2752
|
responseHeaders,
|
|
2705
2753
|
value: response,
|
|
2706
2754
|
rawValue: rawResponse
|
|
2707
|
-
} = await (0,
|
|
2755
|
+
} = await (0, import_provider_utils15.postJsonToApi)({
|
|
2708
2756
|
url,
|
|
2709
|
-
headers: (0,
|
|
2757
|
+
headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
|
|
2710
2758
|
body,
|
|
2711
2759
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2712
|
-
successfulResponseHandler: (0,
|
|
2713
|
-
|
|
2714
|
-
id:
|
|
2715
|
-
created_at:
|
|
2716
|
-
error:
|
|
2717
|
-
code:
|
|
2718
|
-
message:
|
|
2760
|
+
successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
|
|
2761
|
+
import_v417.z.object({
|
|
2762
|
+
id: import_v417.z.string(),
|
|
2763
|
+
created_at: import_v417.z.number(),
|
|
2764
|
+
error: import_v417.z.object({
|
|
2765
|
+
code: import_v417.z.string(),
|
|
2766
|
+
message: import_v417.z.string()
|
|
2719
2767
|
}).nullish(),
|
|
2720
|
-
model:
|
|
2721
|
-
output:
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
type:
|
|
2725
|
-
role:
|
|
2726
|
-
id:
|
|
2727
|
-
content:
|
|
2728
|
-
|
|
2729
|
-
type:
|
|
2730
|
-
text:
|
|
2768
|
+
model: import_v417.z.string(),
|
|
2769
|
+
output: import_v417.z.array(
|
|
2770
|
+
import_v417.z.discriminatedUnion("type", [
|
|
2771
|
+
import_v417.z.object({
|
|
2772
|
+
type: import_v417.z.literal("message"),
|
|
2773
|
+
role: import_v417.z.literal("assistant"),
|
|
2774
|
+
id: import_v417.z.string(),
|
|
2775
|
+
content: import_v417.z.array(
|
|
2776
|
+
import_v417.z.object({
|
|
2777
|
+
type: import_v417.z.literal("output_text"),
|
|
2778
|
+
text: import_v417.z.string(),
|
|
2731
2779
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2732
|
-
annotations:
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
type:
|
|
2736
|
-
start_index:
|
|
2737
|
-
end_index:
|
|
2738
|
-
url:
|
|
2739
|
-
title:
|
|
2780
|
+
annotations: import_v417.z.array(
|
|
2781
|
+
import_v417.z.discriminatedUnion("type", [
|
|
2782
|
+
import_v417.z.object({
|
|
2783
|
+
type: import_v417.z.literal("url_citation"),
|
|
2784
|
+
start_index: import_v417.z.number(),
|
|
2785
|
+
end_index: import_v417.z.number(),
|
|
2786
|
+
url: import_v417.z.string(),
|
|
2787
|
+
title: import_v417.z.string()
|
|
2740
2788
|
}),
|
|
2741
|
-
|
|
2742
|
-
type:
|
|
2743
|
-
file_id:
|
|
2744
|
-
filename:
|
|
2745
|
-
index:
|
|
2746
|
-
start_index:
|
|
2747
|
-
end_index:
|
|
2748
|
-
quote:
|
|
2789
|
+
import_v417.z.object({
|
|
2790
|
+
type: import_v417.z.literal("file_citation"),
|
|
2791
|
+
file_id: import_v417.z.string(),
|
|
2792
|
+
filename: import_v417.z.string().nullish(),
|
|
2793
|
+
index: import_v417.z.number().nullish(),
|
|
2794
|
+
start_index: import_v417.z.number().nullish(),
|
|
2795
|
+
end_index: import_v417.z.number().nullish(),
|
|
2796
|
+
quote: import_v417.z.string().nullish()
|
|
2749
2797
|
})
|
|
2750
2798
|
])
|
|
2751
2799
|
)
|
|
2752
2800
|
})
|
|
2753
2801
|
)
|
|
2754
2802
|
}),
|
|
2755
|
-
|
|
2756
|
-
type:
|
|
2757
|
-
call_id:
|
|
2758
|
-
name:
|
|
2759
|
-
arguments:
|
|
2760
|
-
id:
|
|
2803
|
+
import_v417.z.object({
|
|
2804
|
+
type: import_v417.z.literal("function_call"),
|
|
2805
|
+
call_id: import_v417.z.string(),
|
|
2806
|
+
name: import_v417.z.string(),
|
|
2807
|
+
arguments: import_v417.z.string(),
|
|
2808
|
+
id: import_v417.z.string()
|
|
2761
2809
|
}),
|
|
2762
2810
|
webSearchCallItem,
|
|
2763
|
-
|
|
2764
|
-
type:
|
|
2765
|
-
id:
|
|
2766
|
-
status:
|
|
2811
|
+
import_v417.z.object({
|
|
2812
|
+
type: import_v417.z.literal("computer_call"),
|
|
2813
|
+
id: import_v417.z.string(),
|
|
2814
|
+
status: import_v417.z.string().optional()
|
|
2767
2815
|
}),
|
|
2768
|
-
|
|
2769
|
-
type:
|
|
2770
|
-
id:
|
|
2771
|
-
status:
|
|
2772
|
-
queries:
|
|
2773
|
-
results:
|
|
2774
|
-
|
|
2775
|
-
attributes:
|
|
2776
|
-
file_id:
|
|
2777
|
-
filename:
|
|
2778
|
-
score:
|
|
2779
|
-
text:
|
|
2816
|
+
import_v417.z.object({
|
|
2817
|
+
type: import_v417.z.literal("file_search_call"),
|
|
2818
|
+
id: import_v417.z.string(),
|
|
2819
|
+
status: import_v417.z.string().optional(),
|
|
2820
|
+
queries: import_v417.z.array(import_v417.z.string()).nullish(),
|
|
2821
|
+
results: import_v417.z.array(
|
|
2822
|
+
import_v417.z.object({
|
|
2823
|
+
attributes: import_v417.z.object({
|
|
2824
|
+
file_id: import_v417.z.string(),
|
|
2825
|
+
filename: import_v417.z.string(),
|
|
2826
|
+
score: import_v417.z.number(),
|
|
2827
|
+
text: import_v417.z.string()
|
|
2780
2828
|
})
|
|
2781
2829
|
})
|
|
2782
2830
|
).nullish()
|
|
2783
2831
|
}),
|
|
2784
|
-
|
|
2785
|
-
type:
|
|
2786
|
-
id:
|
|
2787
|
-
encrypted_content:
|
|
2788
|
-
summary:
|
|
2789
|
-
|
|
2790
|
-
type:
|
|
2791
|
-
text:
|
|
2832
|
+
import_v417.z.object({
|
|
2833
|
+
type: import_v417.z.literal("reasoning"),
|
|
2834
|
+
id: import_v417.z.string(),
|
|
2835
|
+
encrypted_content: import_v417.z.string().nullish(),
|
|
2836
|
+
summary: import_v417.z.array(
|
|
2837
|
+
import_v417.z.object({
|
|
2838
|
+
type: import_v417.z.literal("summary_text"),
|
|
2839
|
+
text: import_v417.z.string()
|
|
2792
2840
|
})
|
|
2793
2841
|
)
|
|
2794
2842
|
})
|
|
2795
2843
|
])
|
|
2796
2844
|
),
|
|
2797
|
-
service_tier:
|
|
2798
|
-
incomplete_details:
|
|
2845
|
+
service_tier: import_v417.z.string().nullish(),
|
|
2846
|
+
incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullable(),
|
|
2799
2847
|
usage: usageSchema2
|
|
2800
2848
|
})
|
|
2801
2849
|
),
|
|
@@ -2815,6 +2863,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2815
2863
|
}
|
|
2816
2864
|
const content = [];
|
|
2817
2865
|
const logprobs = [];
|
|
2866
|
+
let hasFunctionCall = false;
|
|
2818
2867
|
for (const part of response.output) {
|
|
2819
2868
|
switch (part.type) {
|
|
2820
2869
|
case "reasoning": {
|
|
@@ -2854,7 +2903,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2854
2903
|
content.push({
|
|
2855
2904
|
type: "source",
|
|
2856
2905
|
sourceType: "url",
|
|
2857
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0,
|
|
2906
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils15.generateId)(),
|
|
2858
2907
|
url: annotation.url,
|
|
2859
2908
|
title: annotation.title
|
|
2860
2909
|
});
|
|
@@ -2862,7 +2911,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2862
2911
|
content.push({
|
|
2863
2912
|
type: "source",
|
|
2864
2913
|
sourceType: "document",
|
|
2865
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0,
|
|
2914
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils15.generateId)(),
|
|
2866
2915
|
mediaType: "text/plain",
|
|
2867
2916
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
2868
2917
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id
|
|
@@ -2873,6 +2922,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2873
2922
|
break;
|
|
2874
2923
|
}
|
|
2875
2924
|
case "function_call": {
|
|
2925
|
+
hasFunctionCall = true;
|
|
2876
2926
|
content.push({
|
|
2877
2927
|
type: "tool-call",
|
|
2878
2928
|
toolCallId: part.call_id,
|
|
@@ -2960,7 +3010,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2960
3010
|
content,
|
|
2961
3011
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2962
3012
|
finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
|
|
2963
|
-
|
|
3013
|
+
hasFunctionCall
|
|
2964
3014
|
}),
|
|
2965
3015
|
usage: {
|
|
2966
3016
|
inputTokens: response.usage.input_tokens,
|
|
@@ -2983,18 +3033,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2983
3033
|
}
|
|
2984
3034
|
async doStream(options) {
|
|
2985
3035
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2986
|
-
const { responseHeaders, value: response } = await (0,
|
|
3036
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
|
|
2987
3037
|
url: this.config.url({
|
|
2988
3038
|
path: "/responses",
|
|
2989
3039
|
modelId: this.modelId
|
|
2990
3040
|
}),
|
|
2991
|
-
headers: (0,
|
|
3041
|
+
headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
|
|
2992
3042
|
body: {
|
|
2993
3043
|
...body,
|
|
2994
3044
|
stream: true
|
|
2995
3045
|
},
|
|
2996
3046
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2997
|
-
successfulResponseHandler: (0,
|
|
3047
|
+
successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
|
|
2998
3048
|
openaiResponsesChunkSchema
|
|
2999
3049
|
),
|
|
3000
3050
|
abortSignal: options.abortSignal,
|
|
@@ -3010,7 +3060,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3010
3060
|
const logprobs = [];
|
|
3011
3061
|
let responseId = null;
|
|
3012
3062
|
const ongoingToolCalls = {};
|
|
3013
|
-
let
|
|
3063
|
+
let hasFunctionCall = false;
|
|
3014
3064
|
const activeReasoning = {};
|
|
3015
3065
|
let serviceTier;
|
|
3016
3066
|
return {
|
|
@@ -3100,7 +3150,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3100
3150
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
3101
3151
|
if (value.item.type === "function_call") {
|
|
3102
3152
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3103
|
-
|
|
3153
|
+
hasFunctionCall = true;
|
|
3104
3154
|
controller.enqueue({
|
|
3105
3155
|
type: "tool-input-end",
|
|
3106
3156
|
id: value.item.call_id
|
|
@@ -3118,7 +3168,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3118
3168
|
});
|
|
3119
3169
|
} else if (value.item.type === "web_search_call") {
|
|
3120
3170
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3121
|
-
hasToolCalls = true;
|
|
3122
3171
|
controller.enqueue({
|
|
3123
3172
|
type: "tool-input-end",
|
|
3124
3173
|
id: value.item.id
|
|
@@ -3126,20 +3175,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3126
3175
|
controller.enqueue({
|
|
3127
3176
|
type: "tool-call",
|
|
3128
3177
|
toolCallId: value.item.id,
|
|
3129
|
-
toolName: "
|
|
3178
|
+
toolName: "web_search",
|
|
3130
3179
|
input: JSON.stringify({ action: value.item.action }),
|
|
3131
3180
|
providerExecuted: true
|
|
3132
3181
|
});
|
|
3133
3182
|
controller.enqueue({
|
|
3134
3183
|
type: "tool-result",
|
|
3135
3184
|
toolCallId: value.item.id,
|
|
3136
|
-
toolName: "
|
|
3185
|
+
toolName: "web_search",
|
|
3137
3186
|
result: { status: value.item.status },
|
|
3138
3187
|
providerExecuted: true
|
|
3139
3188
|
});
|
|
3140
3189
|
} else if (value.item.type === "computer_call") {
|
|
3141
3190
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3142
|
-
hasToolCalls = true;
|
|
3143
3191
|
controller.enqueue({
|
|
3144
3192
|
type: "tool-input-end",
|
|
3145
3193
|
id: value.item.id
|
|
@@ -3163,7 +3211,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3163
3211
|
});
|
|
3164
3212
|
} else if (value.item.type === "file_search_call") {
|
|
3165
3213
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3166
|
-
hasToolCalls = true;
|
|
3167
3214
|
controller.enqueue({
|
|
3168
3215
|
type: "tool-input-end",
|
|
3169
3216
|
id: value.item.id
|
|
@@ -3264,7 +3311,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3264
3311
|
} else if (isResponseFinishedChunk(value)) {
|
|
3265
3312
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3266
3313
|
finishReason: (_h = value.response.incomplete_details) == null ? void 0 : _h.reason,
|
|
3267
|
-
|
|
3314
|
+
hasFunctionCall
|
|
3268
3315
|
});
|
|
3269
3316
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3270
3317
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
@@ -3279,7 +3326,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3279
3326
|
controller.enqueue({
|
|
3280
3327
|
type: "source",
|
|
3281
3328
|
sourceType: "url",
|
|
3282
|
-
id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0,
|
|
3329
|
+
id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils15.generateId)(),
|
|
3283
3330
|
url: value.annotation.url,
|
|
3284
3331
|
title: value.annotation.title
|
|
3285
3332
|
});
|
|
@@ -3287,7 +3334,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3287
3334
|
controller.enqueue({
|
|
3288
3335
|
type: "source",
|
|
3289
3336
|
sourceType: "document",
|
|
3290
|
-
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0,
|
|
3337
|
+
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils15.generateId)(),
|
|
3291
3338
|
mediaType: "text/plain",
|
|
3292
3339
|
title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
|
|
3293
3340
|
filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
|
|
@@ -3323,176 +3370,176 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3323
3370
|
};
|
|
3324
3371
|
}
|
|
3325
3372
|
};
|
|
3326
|
-
var usageSchema2 =
|
|
3327
|
-
input_tokens:
|
|
3328
|
-
input_tokens_details:
|
|
3329
|
-
output_tokens:
|
|
3330
|
-
output_tokens_details:
|
|
3373
|
+
var usageSchema2 = import_v417.z.object({
|
|
3374
|
+
input_tokens: import_v417.z.number(),
|
|
3375
|
+
input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
|
|
3376
|
+
output_tokens: import_v417.z.number(),
|
|
3377
|
+
output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
|
|
3331
3378
|
});
|
|
3332
|
-
var textDeltaChunkSchema =
|
|
3333
|
-
type:
|
|
3334
|
-
item_id:
|
|
3335
|
-
delta:
|
|
3379
|
+
var textDeltaChunkSchema = import_v417.z.object({
|
|
3380
|
+
type: import_v417.z.literal("response.output_text.delta"),
|
|
3381
|
+
item_id: import_v417.z.string(),
|
|
3382
|
+
delta: import_v417.z.string(),
|
|
3336
3383
|
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3337
3384
|
});
|
|
3338
|
-
var errorChunkSchema =
|
|
3339
|
-
type:
|
|
3340
|
-
code:
|
|
3341
|
-
message:
|
|
3342
|
-
param:
|
|
3343
|
-
sequence_number:
|
|
3385
|
+
var errorChunkSchema = import_v417.z.object({
|
|
3386
|
+
type: import_v417.z.literal("error"),
|
|
3387
|
+
code: import_v417.z.string(),
|
|
3388
|
+
message: import_v417.z.string(),
|
|
3389
|
+
param: import_v417.z.string().nullish(),
|
|
3390
|
+
sequence_number: import_v417.z.number()
|
|
3344
3391
|
});
|
|
3345
|
-
var responseFinishedChunkSchema =
|
|
3346
|
-
type:
|
|
3347
|
-
response:
|
|
3348
|
-
incomplete_details:
|
|
3392
|
+
var responseFinishedChunkSchema = import_v417.z.object({
|
|
3393
|
+
type: import_v417.z.enum(["response.completed", "response.incomplete"]),
|
|
3394
|
+
response: import_v417.z.object({
|
|
3395
|
+
incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
|
|
3349
3396
|
usage: usageSchema2,
|
|
3350
|
-
service_tier:
|
|
3397
|
+
service_tier: import_v417.z.string().nullish()
|
|
3351
3398
|
})
|
|
3352
3399
|
});
|
|
3353
|
-
var responseCreatedChunkSchema =
|
|
3354
|
-
type:
|
|
3355
|
-
response:
|
|
3356
|
-
id:
|
|
3357
|
-
created_at:
|
|
3358
|
-
model:
|
|
3359
|
-
service_tier:
|
|
3400
|
+
var responseCreatedChunkSchema = import_v417.z.object({
|
|
3401
|
+
type: import_v417.z.literal("response.created"),
|
|
3402
|
+
response: import_v417.z.object({
|
|
3403
|
+
id: import_v417.z.string(),
|
|
3404
|
+
created_at: import_v417.z.number(),
|
|
3405
|
+
model: import_v417.z.string(),
|
|
3406
|
+
service_tier: import_v417.z.string().nullish()
|
|
3360
3407
|
})
|
|
3361
3408
|
});
|
|
3362
|
-
var responseOutputItemAddedSchema =
|
|
3363
|
-
type:
|
|
3364
|
-
output_index:
|
|
3365
|
-
item:
|
|
3366
|
-
|
|
3367
|
-
type:
|
|
3368
|
-
id:
|
|
3409
|
+
var responseOutputItemAddedSchema = import_v417.z.object({
|
|
3410
|
+
type: import_v417.z.literal("response.output_item.added"),
|
|
3411
|
+
output_index: import_v417.z.number(),
|
|
3412
|
+
item: import_v417.z.discriminatedUnion("type", [
|
|
3413
|
+
import_v417.z.object({
|
|
3414
|
+
type: import_v417.z.literal("message"),
|
|
3415
|
+
id: import_v417.z.string()
|
|
3369
3416
|
}),
|
|
3370
|
-
|
|
3371
|
-
type:
|
|
3372
|
-
id:
|
|
3373
|
-
encrypted_content:
|
|
3417
|
+
import_v417.z.object({
|
|
3418
|
+
type: import_v417.z.literal("reasoning"),
|
|
3419
|
+
id: import_v417.z.string(),
|
|
3420
|
+
encrypted_content: import_v417.z.string().nullish()
|
|
3374
3421
|
}),
|
|
3375
|
-
|
|
3376
|
-
type:
|
|
3377
|
-
id:
|
|
3378
|
-
call_id:
|
|
3379
|
-
name:
|
|
3380
|
-
arguments:
|
|
3422
|
+
import_v417.z.object({
|
|
3423
|
+
type: import_v417.z.literal("function_call"),
|
|
3424
|
+
id: import_v417.z.string(),
|
|
3425
|
+
call_id: import_v417.z.string(),
|
|
3426
|
+
name: import_v417.z.string(),
|
|
3427
|
+
arguments: import_v417.z.string()
|
|
3381
3428
|
}),
|
|
3382
|
-
|
|
3383
|
-
type:
|
|
3384
|
-
id:
|
|
3385
|
-
status:
|
|
3386
|
-
action:
|
|
3387
|
-
type:
|
|
3388
|
-
query:
|
|
3429
|
+
import_v417.z.object({
|
|
3430
|
+
type: import_v417.z.literal("web_search_call"),
|
|
3431
|
+
id: import_v417.z.string(),
|
|
3432
|
+
status: import_v417.z.string(),
|
|
3433
|
+
action: import_v417.z.object({
|
|
3434
|
+
type: import_v417.z.literal("search"),
|
|
3435
|
+
query: import_v417.z.string().optional()
|
|
3389
3436
|
}).nullish()
|
|
3390
3437
|
}),
|
|
3391
|
-
|
|
3392
|
-
type:
|
|
3393
|
-
id:
|
|
3394
|
-
status:
|
|
3438
|
+
import_v417.z.object({
|
|
3439
|
+
type: import_v417.z.literal("computer_call"),
|
|
3440
|
+
id: import_v417.z.string(),
|
|
3441
|
+
status: import_v417.z.string()
|
|
3395
3442
|
}),
|
|
3396
|
-
|
|
3397
|
-
type:
|
|
3398
|
-
id:
|
|
3399
|
-
status:
|
|
3400
|
-
queries:
|
|
3401
|
-
results:
|
|
3402
|
-
|
|
3403
|
-
attributes:
|
|
3404
|
-
file_id:
|
|
3405
|
-
filename:
|
|
3406
|
-
score:
|
|
3407
|
-
text:
|
|
3443
|
+
import_v417.z.object({
|
|
3444
|
+
type: import_v417.z.literal("file_search_call"),
|
|
3445
|
+
id: import_v417.z.string(),
|
|
3446
|
+
status: import_v417.z.string(),
|
|
3447
|
+
queries: import_v417.z.array(import_v417.z.string()).nullish(),
|
|
3448
|
+
results: import_v417.z.array(
|
|
3449
|
+
import_v417.z.object({
|
|
3450
|
+
attributes: import_v417.z.object({
|
|
3451
|
+
file_id: import_v417.z.string(),
|
|
3452
|
+
filename: import_v417.z.string(),
|
|
3453
|
+
score: import_v417.z.number(),
|
|
3454
|
+
text: import_v417.z.string()
|
|
3408
3455
|
})
|
|
3409
3456
|
})
|
|
3410
3457
|
).optional()
|
|
3411
3458
|
})
|
|
3412
3459
|
])
|
|
3413
3460
|
});
|
|
3414
|
-
var responseOutputItemDoneSchema =
|
|
3415
|
-
type:
|
|
3416
|
-
output_index:
|
|
3417
|
-
item:
|
|
3418
|
-
|
|
3419
|
-
type:
|
|
3420
|
-
id:
|
|
3461
|
+
var responseOutputItemDoneSchema = import_v417.z.object({
|
|
3462
|
+
type: import_v417.z.literal("response.output_item.done"),
|
|
3463
|
+
output_index: import_v417.z.number(),
|
|
3464
|
+
item: import_v417.z.discriminatedUnion("type", [
|
|
3465
|
+
import_v417.z.object({
|
|
3466
|
+
type: import_v417.z.literal("message"),
|
|
3467
|
+
id: import_v417.z.string()
|
|
3421
3468
|
}),
|
|
3422
|
-
|
|
3423
|
-
type:
|
|
3424
|
-
id:
|
|
3425
|
-
encrypted_content:
|
|
3469
|
+
import_v417.z.object({
|
|
3470
|
+
type: import_v417.z.literal("reasoning"),
|
|
3471
|
+
id: import_v417.z.string(),
|
|
3472
|
+
encrypted_content: import_v417.z.string().nullish()
|
|
3426
3473
|
}),
|
|
3427
|
-
|
|
3428
|
-
type:
|
|
3429
|
-
id:
|
|
3430
|
-
call_id:
|
|
3431
|
-
name:
|
|
3432
|
-
arguments:
|
|
3433
|
-
status:
|
|
3474
|
+
import_v417.z.object({
|
|
3475
|
+
type: import_v417.z.literal("function_call"),
|
|
3476
|
+
id: import_v417.z.string(),
|
|
3477
|
+
call_id: import_v417.z.string(),
|
|
3478
|
+
name: import_v417.z.string(),
|
|
3479
|
+
arguments: import_v417.z.string(),
|
|
3480
|
+
status: import_v417.z.literal("completed")
|
|
3434
3481
|
}),
|
|
3435
3482
|
webSearchCallItem,
|
|
3436
|
-
|
|
3437
|
-
type:
|
|
3438
|
-
id:
|
|
3439
|
-
status:
|
|
3483
|
+
import_v417.z.object({
|
|
3484
|
+
type: import_v417.z.literal("computer_call"),
|
|
3485
|
+
id: import_v417.z.string(),
|
|
3486
|
+
status: import_v417.z.literal("completed")
|
|
3440
3487
|
}),
|
|
3441
|
-
|
|
3442
|
-
type:
|
|
3443
|
-
id:
|
|
3444
|
-
status:
|
|
3445
|
-
queries:
|
|
3446
|
-
results:
|
|
3447
|
-
|
|
3448
|
-
attributes:
|
|
3449
|
-
file_id:
|
|
3450
|
-
filename:
|
|
3451
|
-
score:
|
|
3452
|
-
text:
|
|
3488
|
+
import_v417.z.object({
|
|
3489
|
+
type: import_v417.z.literal("file_search_call"),
|
|
3490
|
+
id: import_v417.z.string(),
|
|
3491
|
+
status: import_v417.z.literal("completed"),
|
|
3492
|
+
queries: import_v417.z.array(import_v417.z.string()).nullish(),
|
|
3493
|
+
results: import_v417.z.array(
|
|
3494
|
+
import_v417.z.object({
|
|
3495
|
+
attributes: import_v417.z.object({
|
|
3496
|
+
file_id: import_v417.z.string(),
|
|
3497
|
+
filename: import_v417.z.string(),
|
|
3498
|
+
score: import_v417.z.number(),
|
|
3499
|
+
text: import_v417.z.string()
|
|
3453
3500
|
})
|
|
3454
3501
|
})
|
|
3455
3502
|
).nullish()
|
|
3456
3503
|
})
|
|
3457
3504
|
])
|
|
3458
3505
|
});
|
|
3459
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
3460
|
-
type:
|
|
3461
|
-
item_id:
|
|
3462
|
-
output_index:
|
|
3463
|
-
delta:
|
|
3506
|
+
var responseFunctionCallArgumentsDeltaSchema = import_v417.z.object({
|
|
3507
|
+
type: import_v417.z.literal("response.function_call_arguments.delta"),
|
|
3508
|
+
item_id: import_v417.z.string(),
|
|
3509
|
+
output_index: import_v417.z.number(),
|
|
3510
|
+
delta: import_v417.z.string()
|
|
3464
3511
|
});
|
|
3465
|
-
var responseAnnotationAddedSchema =
|
|
3466
|
-
type:
|
|
3467
|
-
annotation:
|
|
3468
|
-
|
|
3469
|
-
type:
|
|
3470
|
-
url:
|
|
3471
|
-
title:
|
|
3512
|
+
var responseAnnotationAddedSchema = import_v417.z.object({
|
|
3513
|
+
type: import_v417.z.literal("response.output_text.annotation.added"),
|
|
3514
|
+
annotation: import_v417.z.discriminatedUnion("type", [
|
|
3515
|
+
import_v417.z.object({
|
|
3516
|
+
type: import_v417.z.literal("url_citation"),
|
|
3517
|
+
url: import_v417.z.string(),
|
|
3518
|
+
title: import_v417.z.string()
|
|
3472
3519
|
}),
|
|
3473
|
-
|
|
3474
|
-
type:
|
|
3475
|
-
file_id:
|
|
3476
|
-
filename:
|
|
3477
|
-
index:
|
|
3478
|
-
start_index:
|
|
3479
|
-
end_index:
|
|
3480
|
-
quote:
|
|
3520
|
+
import_v417.z.object({
|
|
3521
|
+
type: import_v417.z.literal("file_citation"),
|
|
3522
|
+
file_id: import_v417.z.string(),
|
|
3523
|
+
filename: import_v417.z.string().nullish(),
|
|
3524
|
+
index: import_v417.z.number().nullish(),
|
|
3525
|
+
start_index: import_v417.z.number().nullish(),
|
|
3526
|
+
end_index: import_v417.z.number().nullish(),
|
|
3527
|
+
quote: import_v417.z.string().nullish()
|
|
3481
3528
|
})
|
|
3482
3529
|
])
|
|
3483
3530
|
});
|
|
3484
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
3485
|
-
type:
|
|
3486
|
-
item_id:
|
|
3487
|
-
summary_index:
|
|
3531
|
+
var responseReasoningSummaryPartAddedSchema = import_v417.z.object({
|
|
3532
|
+
type: import_v417.z.literal("response.reasoning_summary_part.added"),
|
|
3533
|
+
item_id: import_v417.z.string(),
|
|
3534
|
+
summary_index: import_v417.z.number()
|
|
3488
3535
|
});
|
|
3489
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
3490
|
-
type:
|
|
3491
|
-
item_id:
|
|
3492
|
-
summary_index:
|
|
3493
|
-
delta:
|
|
3536
|
+
var responseReasoningSummaryTextDeltaSchema = import_v417.z.object({
|
|
3537
|
+
type: import_v417.z.literal("response.reasoning_summary_text.delta"),
|
|
3538
|
+
item_id: import_v417.z.string(),
|
|
3539
|
+
summary_index: import_v417.z.number(),
|
|
3540
|
+
delta: import_v417.z.string()
|
|
3494
3541
|
});
|
|
3495
|
-
var openaiResponsesChunkSchema =
|
|
3542
|
+
var openaiResponsesChunkSchema = import_v417.z.union([
|
|
3496
3543
|
textDeltaChunkSchema,
|
|
3497
3544
|
responseFinishedChunkSchema,
|
|
3498
3545
|
responseCreatedChunkSchema,
|
|
@@ -3503,7 +3550,7 @@ var openaiResponsesChunkSchema = import_v416.z.union([
|
|
|
3503
3550
|
responseReasoningSummaryPartAddedSchema,
|
|
3504
3551
|
responseReasoningSummaryTextDeltaSchema,
|
|
3505
3552
|
errorChunkSchema,
|
|
3506
|
-
|
|
3553
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
3507
3554
|
// fallback for unknown chunks
|
|
3508
3555
|
]);
|
|
3509
3556
|
function isTextDeltaChunk(chunk) {
|
|
@@ -3576,27 +3623,27 @@ function getResponsesModelConfig(modelId) {
|
|
|
3576
3623
|
isReasoningModel: false
|
|
3577
3624
|
};
|
|
3578
3625
|
}
|
|
3579
|
-
var openaiResponsesProviderOptionsSchema =
|
|
3580
|
-
metadata:
|
|
3581
|
-
parallelToolCalls:
|
|
3582
|
-
previousResponseId:
|
|
3583
|
-
store:
|
|
3584
|
-
user:
|
|
3585
|
-
reasoningEffort:
|
|
3586
|
-
strictJsonSchema:
|
|
3587
|
-
instructions:
|
|
3588
|
-
reasoningSummary:
|
|
3589
|
-
serviceTier:
|
|
3590
|
-
include:
|
|
3591
|
-
|
|
3626
|
+
var openaiResponsesProviderOptionsSchema = import_v417.z.object({
|
|
3627
|
+
metadata: import_v417.z.any().nullish(),
|
|
3628
|
+
parallelToolCalls: import_v417.z.boolean().nullish(),
|
|
3629
|
+
previousResponseId: import_v417.z.string().nullish(),
|
|
3630
|
+
store: import_v417.z.boolean().nullish(),
|
|
3631
|
+
user: import_v417.z.string().nullish(),
|
|
3632
|
+
reasoningEffort: import_v417.z.string().nullish(),
|
|
3633
|
+
strictJsonSchema: import_v417.z.boolean().nullish(),
|
|
3634
|
+
instructions: import_v417.z.string().nullish(),
|
|
3635
|
+
reasoningSummary: import_v417.z.string().nullish(),
|
|
3636
|
+
serviceTier: import_v417.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
3637
|
+
include: import_v417.z.array(
|
|
3638
|
+
import_v417.z.enum([
|
|
3592
3639
|
"reasoning.encrypted_content",
|
|
3593
3640
|
"file_search_call.results",
|
|
3594
3641
|
"message.output_text.logprobs"
|
|
3595
3642
|
])
|
|
3596
3643
|
).nullish(),
|
|
3597
|
-
textVerbosity:
|
|
3598
|
-
promptCacheKey:
|
|
3599
|
-
safetyIdentifier:
|
|
3644
|
+
textVerbosity: import_v417.z.enum(["low", "medium", "high"]).nullish(),
|
|
3645
|
+
promptCacheKey: import_v417.z.string().nullish(),
|
|
3646
|
+
safetyIdentifier: import_v417.z.string().nullish(),
|
|
3600
3647
|
/**
|
|
3601
3648
|
* Return the log probabilities of the tokens.
|
|
3602
3649
|
*
|
|
@@ -3609,7 +3656,7 @@ var openaiResponsesProviderOptionsSchema = import_v416.z.object({
|
|
|
3609
3656
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3610
3657
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3611
3658
|
*/
|
|
3612
|
-
logprobs:
|
|
3659
|
+
logprobs: import_v417.z.union([import_v417.z.boolean(), import_v417.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
|
|
3613
3660
|
});
|
|
3614
3661
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3615
3662
|
0 && (module.exports = {
|