@ai-sdk/openai 2.0.26 → 2.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +57 -8
- package/dist/index.d.ts +57 -8
- package/dist/index.js +78 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -25
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +32 -24
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +32 -24
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.mjs
CHANGED
|
@@ -353,23 +353,11 @@ var compoundFilterSchema = z3.object({
|
|
|
353
353
|
});
|
|
354
354
|
var filtersSchema = z3.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
355
355
|
var fileSearchArgsSchema = z3.object({
|
|
356
|
-
/**
|
|
357
|
-
* List of vector store IDs to search through. If not provided, searches all available vector stores.
|
|
358
|
-
*/
|
|
359
356
|
vectorStoreIds: z3.array(z3.string()).optional(),
|
|
360
|
-
/**
|
|
361
|
-
* Maximum number of search results to return. Defaults to 10.
|
|
362
|
-
*/
|
|
363
357
|
maxNumResults: z3.number().optional(),
|
|
364
|
-
/**
|
|
365
|
-
* Ranking options for the search.
|
|
366
|
-
*/
|
|
367
358
|
ranking: z3.object({
|
|
368
359
|
ranker: z3.enum(["auto", "default-2024-08-21"]).optional()
|
|
369
360
|
}).optional(),
|
|
370
|
-
/**
|
|
371
|
-
* A filter to apply based on file attributes.
|
|
372
|
-
*/
|
|
373
361
|
filters: filtersSchema.optional()
|
|
374
362
|
});
|
|
375
363
|
var fileSearch = createProviderDefinedToolFactory({
|
|
@@ -2403,7 +2391,7 @@ var codeInterpreterArgsSchema = z15.object({
|
|
|
2403
2391
|
})
|
|
2404
2392
|
]).optional()
|
|
2405
2393
|
});
|
|
2406
|
-
var
|
|
2394
|
+
var codeInterpreterToolFactory = createProviderDefinedToolFactory3({
|
|
2407
2395
|
id: "openai.code_interpreter",
|
|
2408
2396
|
name: "code_interpreter",
|
|
2409
2397
|
inputSchema: z15.object({})
|
|
@@ -2425,7 +2413,7 @@ var webSearchArgsSchema = z16.object({
|
|
|
2425
2413
|
timezone: z16.string().optional()
|
|
2426
2414
|
}).optional()
|
|
2427
2415
|
});
|
|
2428
|
-
var
|
|
2416
|
+
var webSearchToolFactory = createProviderDefinedToolFactory4({
|
|
2429
2417
|
id: "openai.web_search",
|
|
2430
2418
|
name: "web_search",
|
|
2431
2419
|
inputSchema: z16.object({
|
|
@@ -2608,7 +2596,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2608
2596
|
toolChoice,
|
|
2609
2597
|
responseFormat
|
|
2610
2598
|
}) {
|
|
2611
|
-
var _a, _b;
|
|
2599
|
+
var _a, _b, _c;
|
|
2612
2600
|
const warnings = [];
|
|
2613
2601
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
2614
2602
|
if (topK != null) {
|
|
@@ -2644,8 +2632,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2644
2632
|
schema: openaiResponsesProviderOptionsSchema
|
|
2645
2633
|
});
|
|
2646
2634
|
const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
|
|
2635
|
+
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
2647
2636
|
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;
|
|
2648
|
-
|
|
2637
|
+
include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
|
|
2638
|
+
const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
|
|
2639
|
+
(tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
2640
|
+
)) == null ? void 0 : _b.name;
|
|
2641
|
+
include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
|
|
2649
2642
|
const baseArgs = {
|
|
2650
2643
|
model: this.modelId,
|
|
2651
2644
|
input: messages,
|
|
@@ -2658,7 +2651,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2658
2651
|
format: responseFormat.schema != null ? {
|
|
2659
2652
|
type: "json_schema",
|
|
2660
2653
|
strict: strictJsonSchema,
|
|
2661
|
-
name: (
|
|
2654
|
+
name: (_c = responseFormat.name) != null ? _c : "response",
|
|
2662
2655
|
description: responseFormat.description,
|
|
2663
2656
|
schema: responseFormat.schema
|
|
2664
2657
|
} : { type: "json_object" }
|
|
@@ -2676,7 +2669,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2676
2669
|
user: openaiOptions == null ? void 0 : openaiOptions.user,
|
|
2677
2670
|
instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
|
|
2678
2671
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
2679
|
-
include
|
|
2672
|
+
include,
|
|
2680
2673
|
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
2681
2674
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
2682
2675
|
top_logprobs: topLogprobs,
|
|
@@ -2754,6 +2747,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2754
2747
|
strictJsonSchema
|
|
2755
2748
|
});
|
|
2756
2749
|
return {
|
|
2750
|
+
webSearchToolName,
|
|
2757
2751
|
args: {
|
|
2758
2752
|
...baseArgs,
|
|
2759
2753
|
tools: openaiTools,
|
|
@@ -2764,7 +2758,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2764
2758
|
}
|
|
2765
2759
|
async doGenerate(options) {
|
|
2766
2760
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2767
|
-
const {
|
|
2761
|
+
const {
|
|
2762
|
+
args: body,
|
|
2763
|
+
warnings,
|
|
2764
|
+
webSearchToolName
|
|
2765
|
+
} = await this.getArgs(options);
|
|
2768
2766
|
const url = this.config.url({
|
|
2769
2767
|
path: "/responses",
|
|
2770
2768
|
modelId: this.modelId
|
|
@@ -2815,12 +2813,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2815
2813
|
start_index: z17.number().nullish(),
|
|
2816
2814
|
end_index: z17.number().nullish(),
|
|
2817
2815
|
quote: z17.string().nullish()
|
|
2816
|
+
}),
|
|
2817
|
+
z17.object({
|
|
2818
|
+
type: z17.literal("container_file_citation")
|
|
2818
2819
|
})
|
|
2819
2820
|
])
|
|
2820
2821
|
)
|
|
2821
2822
|
})
|
|
2822
2823
|
)
|
|
2823
2824
|
}),
|
|
2825
|
+
z17.object({
|
|
2826
|
+
type: z17.literal("code_interpreter_call")
|
|
2827
|
+
}),
|
|
2824
2828
|
z17.object({
|
|
2825
2829
|
type: z17.literal("function_call"),
|
|
2826
2830
|
call_id: z17.string(),
|
|
@@ -2961,14 +2965,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2961
2965
|
content.push({
|
|
2962
2966
|
type: "tool-call",
|
|
2963
2967
|
toolCallId: part.id,
|
|
2964
|
-
toolName: "
|
|
2968
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
2965
2969
|
input: JSON.stringify({ action: part.action }),
|
|
2966
2970
|
providerExecuted: true
|
|
2967
2971
|
});
|
|
2968
2972
|
content.push({
|
|
2969
2973
|
type: "tool-result",
|
|
2970
2974
|
toolCallId: part.id,
|
|
2971
|
-
toolName: "
|
|
2975
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
2972
2976
|
result: { status: part.status },
|
|
2973
2977
|
providerExecuted: true
|
|
2974
2978
|
});
|
|
@@ -3053,7 +3057,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3053
3057
|
};
|
|
3054
3058
|
}
|
|
3055
3059
|
async doStream(options) {
|
|
3056
|
-
const {
|
|
3060
|
+
const {
|
|
3061
|
+
args: body,
|
|
3062
|
+
warnings,
|
|
3063
|
+
webSearchToolName
|
|
3064
|
+
} = await this.getArgs(options);
|
|
3057
3065
|
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
3058
3066
|
url: this.config.url({
|
|
3059
3067
|
path: "/responses",
|
|
@@ -3114,13 +3122,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3114
3122
|
});
|
|
3115
3123
|
} else if (value.item.type === "web_search_call") {
|
|
3116
3124
|
ongoingToolCalls[value.output_index] = {
|
|
3117
|
-
toolName: "
|
|
3125
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3118
3126
|
toolCallId: value.item.id
|
|
3119
3127
|
};
|
|
3120
3128
|
controller.enqueue({
|
|
3121
3129
|
type: "tool-input-start",
|
|
3122
3130
|
id: value.item.id,
|
|
3123
|
-
toolName: "
|
|
3131
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search"
|
|
3124
3132
|
});
|
|
3125
3133
|
} else if (value.item.type === "computer_call") {
|
|
3126
3134
|
ongoingToolCalls[value.output_index] = {
|