@ai-sdk/openai 3.0.0-beta.60 → 3.0.0-beta.62
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 +12 -0
- package/dist/index.js +27 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +84 -1
- package/dist/internal/index.d.ts +84 -1
- package/dist/internal/index.js +34 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +30 -19
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -481,4 +481,87 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_
|
|
|
481
481
|
result: string;
|
|
482
482
|
}>;
|
|
483
483
|
|
|
484
|
-
|
|
484
|
+
declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
485
|
+
searchContextSize?: "low" | "medium" | "high" | undefined;
|
|
486
|
+
userLocation?: {
|
|
487
|
+
type: "approximate";
|
|
488
|
+
country?: string | undefined;
|
|
489
|
+
city?: string | undefined;
|
|
490
|
+
region?: string | undefined;
|
|
491
|
+
timezone?: string | undefined;
|
|
492
|
+
} | undefined;
|
|
493
|
+
}>;
|
|
494
|
+
declare const webSearchPreviewInputSchema: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
|
|
495
|
+
declare const webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
|
|
496
|
+
/**
|
|
497
|
+
* An object describing the specific action taken in this web search call.
|
|
498
|
+
* Includes details on how the model used the web (search, open_page, find).
|
|
499
|
+
*/
|
|
500
|
+
action: {
|
|
501
|
+
/**
|
|
502
|
+
* Action type "search" - Performs a web search query.
|
|
503
|
+
*/
|
|
504
|
+
type: "search";
|
|
505
|
+
/**
|
|
506
|
+
* The search query.
|
|
507
|
+
*/
|
|
508
|
+
query?: string;
|
|
509
|
+
} | {
|
|
510
|
+
/**
|
|
511
|
+
* Action type "openPage" - Opens a specific URL from search results.
|
|
512
|
+
*/
|
|
513
|
+
type: "openPage";
|
|
514
|
+
/**
|
|
515
|
+
* The URL opened by the model.
|
|
516
|
+
*/
|
|
517
|
+
url: string;
|
|
518
|
+
} | {
|
|
519
|
+
/**
|
|
520
|
+
* Action type "find": Searches for a pattern within a loaded page.
|
|
521
|
+
*/
|
|
522
|
+
type: "find";
|
|
523
|
+
/**
|
|
524
|
+
* The URL of the page searched for the pattern.
|
|
525
|
+
*/
|
|
526
|
+
url: string;
|
|
527
|
+
/**
|
|
528
|
+
* The pattern or text to search for within the page.
|
|
529
|
+
*/
|
|
530
|
+
pattern: string;
|
|
531
|
+
};
|
|
532
|
+
}, {
|
|
533
|
+
/**
|
|
534
|
+
* Search context size to use for the web search.
|
|
535
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
536
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
537
|
+
* - low: Least context, lowest cost, fastest response
|
|
538
|
+
*/
|
|
539
|
+
searchContextSize?: "low" | "medium" | "high";
|
|
540
|
+
/**
|
|
541
|
+
* User location information to provide geographically relevant search results.
|
|
542
|
+
*/
|
|
543
|
+
userLocation?: {
|
|
544
|
+
/**
|
|
545
|
+
* Type of location (always 'approximate')
|
|
546
|
+
*/
|
|
547
|
+
type: "approximate";
|
|
548
|
+
/**
|
|
549
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
550
|
+
*/
|
|
551
|
+
country?: string;
|
|
552
|
+
/**
|
|
553
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
554
|
+
*/
|
|
555
|
+
city?: string;
|
|
556
|
+
/**
|
|
557
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
558
|
+
*/
|
|
559
|
+
region?: string;
|
|
560
|
+
/**
|
|
561
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
562
|
+
*/
|
|
563
|
+
timezone?: string;
|
|
564
|
+
};
|
|
565
|
+
}>;
|
|
566
|
+
|
|
567
|
+
export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiSpeechProviderOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -481,4 +481,87 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_
|
|
|
481
481
|
result: string;
|
|
482
482
|
}>;
|
|
483
483
|
|
|
484
|
-
|
|
484
|
+
declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
485
|
+
searchContextSize?: "low" | "medium" | "high" | undefined;
|
|
486
|
+
userLocation?: {
|
|
487
|
+
type: "approximate";
|
|
488
|
+
country?: string | undefined;
|
|
489
|
+
city?: string | undefined;
|
|
490
|
+
region?: string | undefined;
|
|
491
|
+
timezone?: string | undefined;
|
|
492
|
+
} | undefined;
|
|
493
|
+
}>;
|
|
494
|
+
declare const webSearchPreviewInputSchema: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
|
|
495
|
+
declare const webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
|
|
496
|
+
/**
|
|
497
|
+
* An object describing the specific action taken in this web search call.
|
|
498
|
+
* Includes details on how the model used the web (search, open_page, find).
|
|
499
|
+
*/
|
|
500
|
+
action: {
|
|
501
|
+
/**
|
|
502
|
+
* Action type "search" - Performs a web search query.
|
|
503
|
+
*/
|
|
504
|
+
type: "search";
|
|
505
|
+
/**
|
|
506
|
+
* The search query.
|
|
507
|
+
*/
|
|
508
|
+
query?: string;
|
|
509
|
+
} | {
|
|
510
|
+
/**
|
|
511
|
+
* Action type "openPage" - Opens a specific URL from search results.
|
|
512
|
+
*/
|
|
513
|
+
type: "openPage";
|
|
514
|
+
/**
|
|
515
|
+
* The URL opened by the model.
|
|
516
|
+
*/
|
|
517
|
+
url: string;
|
|
518
|
+
} | {
|
|
519
|
+
/**
|
|
520
|
+
* Action type "find": Searches for a pattern within a loaded page.
|
|
521
|
+
*/
|
|
522
|
+
type: "find";
|
|
523
|
+
/**
|
|
524
|
+
* The URL of the page searched for the pattern.
|
|
525
|
+
*/
|
|
526
|
+
url: string;
|
|
527
|
+
/**
|
|
528
|
+
* The pattern or text to search for within the page.
|
|
529
|
+
*/
|
|
530
|
+
pattern: string;
|
|
531
|
+
};
|
|
532
|
+
}, {
|
|
533
|
+
/**
|
|
534
|
+
* Search context size to use for the web search.
|
|
535
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
536
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
537
|
+
* - low: Least context, lowest cost, fastest response
|
|
538
|
+
*/
|
|
539
|
+
searchContextSize?: "low" | "medium" | "high";
|
|
540
|
+
/**
|
|
541
|
+
* User location information to provide geographically relevant search results.
|
|
542
|
+
*/
|
|
543
|
+
userLocation?: {
|
|
544
|
+
/**
|
|
545
|
+
* Type of location (always 'approximate')
|
|
546
|
+
*/
|
|
547
|
+
type: "approximate";
|
|
548
|
+
/**
|
|
549
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
550
|
+
*/
|
|
551
|
+
country?: string;
|
|
552
|
+
/**
|
|
553
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
554
|
+
*/
|
|
555
|
+
city?: string;
|
|
556
|
+
/**
|
|
557
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
558
|
+
*/
|
|
559
|
+
region?: string;
|
|
560
|
+
/**
|
|
561
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
562
|
+
*/
|
|
563
|
+
timezone?: string;
|
|
564
|
+
};
|
|
565
|
+
}>;
|
|
566
|
+
|
|
567
|
+
export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiSpeechProviderOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
|
package/dist/internal/index.js
CHANGED
|
@@ -44,7 +44,10 @@ __export(internal_exports, {
|
|
|
44
44
|
openaiChatLanguageModelOptions: () => openaiChatLanguageModelOptions,
|
|
45
45
|
openaiCompletionProviderOptions: () => openaiCompletionProviderOptions,
|
|
46
46
|
openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
|
|
47
|
-
openaiSpeechProviderOptionsSchema: () => openaiSpeechProviderOptionsSchema
|
|
47
|
+
openaiSpeechProviderOptionsSchema: () => openaiSpeechProviderOptionsSchema,
|
|
48
|
+
webSearchPreview: () => webSearchPreview,
|
|
49
|
+
webSearchPreviewArgsSchema: () => webSearchPreviewArgsSchema,
|
|
50
|
+
webSearchPreviewInputSchema: () => webSearchPreviewInputSchema
|
|
48
51
|
});
|
|
49
52
|
module.exports = __toCommonJS(internal_exports);
|
|
50
53
|
|
|
@@ -2759,6 +2762,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2759
2762
|
annotation: import_v414.z.discriminatedUnion("type", [
|
|
2760
2763
|
import_v414.z.object({
|
|
2761
2764
|
type: import_v414.z.literal("url_citation"),
|
|
2765
|
+
start_index: import_v414.z.number(),
|
|
2766
|
+
end_index: import_v414.z.number(),
|
|
2762
2767
|
url: import_v414.z.string(),
|
|
2763
2768
|
title: import_v414.z.string()
|
|
2764
2769
|
}),
|
|
@@ -2805,10 +2810,13 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2805
2810
|
}),
|
|
2806
2811
|
import_v414.z.object({
|
|
2807
2812
|
type: import_v414.z.literal("error"),
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2813
|
+
sequence_number: import_v414.z.number(),
|
|
2814
|
+
error: import_v414.z.object({
|
|
2815
|
+
type: import_v414.z.string(),
|
|
2816
|
+
code: import_v414.z.string(),
|
|
2817
|
+
message: import_v414.z.string(),
|
|
2818
|
+
param: import_v414.z.string().nullish()
|
|
2819
|
+
})
|
|
2812
2820
|
}),
|
|
2813
2821
|
import_v414.z.object({ type: import_v414.z.string() }).loose().transform((value) => ({
|
|
2814
2822
|
type: "unknown_chunk",
|
|
@@ -2821,13 +2829,15 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2821
2829
|
var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
|
|
2822
2830
|
() => (0, import_provider_utils21.zodSchema)(
|
|
2823
2831
|
import_v414.z.object({
|
|
2824
|
-
id: import_v414.z.string(),
|
|
2825
|
-
created_at: import_v414.z.number(),
|
|
2832
|
+
id: import_v414.z.string().optional(),
|
|
2833
|
+
created_at: import_v414.z.number().optional(),
|
|
2826
2834
|
error: import_v414.z.object({
|
|
2827
|
-
|
|
2828
|
-
|
|
2835
|
+
message: import_v414.z.string(),
|
|
2836
|
+
type: import_v414.z.string(),
|
|
2837
|
+
param: import_v414.z.string().nullish(),
|
|
2838
|
+
code: import_v414.z.string()
|
|
2829
2839
|
}).nullish(),
|
|
2830
|
-
model: import_v414.z.string(),
|
|
2840
|
+
model: import_v414.z.string().optional(),
|
|
2831
2841
|
output: import_v414.z.array(
|
|
2832
2842
|
import_v414.z.discriminatedUnion("type", [
|
|
2833
2843
|
import_v414.z.object({
|
|
@@ -3030,7 +3040,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
3030
3040
|
approval_request_id: import_v414.z.string()
|
|
3031
3041
|
})
|
|
3032
3042
|
])
|
|
3033
|
-
),
|
|
3043
|
+
).optional(),
|
|
3034
3044
|
service_tier: import_v414.z.string().nullish(),
|
|
3035
3045
|
incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullish(),
|
|
3036
3046
|
usage: import_v414.z.object({
|
|
@@ -3038,7 +3048,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
3038
3048
|
input_tokens_details: import_v414.z.object({ cached_tokens: import_v414.z.number().nullish() }).nullish(),
|
|
3039
3049
|
output_tokens: import_v414.z.number(),
|
|
3040
3050
|
output_tokens_details: import_v414.z.object({ reasoning_tokens: import_v414.z.number().nullish() }).nullish()
|
|
3041
|
-
})
|
|
3051
|
+
}).optional()
|
|
3042
3052
|
})
|
|
3043
3053
|
)
|
|
3044
3054
|
);
|
|
@@ -4239,6 +4249,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4239
4249
|
if (typeof response.service_tier === "string") {
|
|
4240
4250
|
providerMetadata.openai.serviceTier = response.service_tier;
|
|
4241
4251
|
}
|
|
4252
|
+
const usage = response.usage;
|
|
4242
4253
|
return {
|
|
4243
4254
|
content,
|
|
4244
4255
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -4246,11 +4257,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4246
4257
|
hasFunctionCall
|
|
4247
4258
|
}),
|
|
4248
4259
|
usage: {
|
|
4249
|
-
inputTokens:
|
|
4250
|
-
outputTokens:
|
|
4251
|
-
totalTokens:
|
|
4252
|
-
reasoningTokens: (_z = (_y =
|
|
4253
|
-
cachedInputTokens: (_B = (_A =
|
|
4260
|
+
inputTokens: usage.input_tokens,
|
|
4261
|
+
outputTokens: usage.output_tokens,
|
|
4262
|
+
totalTokens: usage.input_tokens + usage.output_tokens,
|
|
4263
|
+
reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
|
|
4264
|
+
cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
|
|
4254
4265
|
},
|
|
4255
4266
|
request: { body },
|
|
4256
4267
|
response: {
|
|
@@ -4347,7 +4358,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4347
4358
|
controller.enqueue({
|
|
4348
4359
|
type: "tool-call",
|
|
4349
4360
|
toolCallId: value.item.id,
|
|
4350
|
-
toolName: "web_search",
|
|
4361
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
4351
4362
|
input: JSON.stringify({}),
|
|
4352
4363
|
providerExecuted: true
|
|
4353
4364
|
});
|
|
@@ -4455,7 +4466,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4455
4466
|
controller.enqueue({
|
|
4456
4467
|
type: "tool-result",
|
|
4457
4468
|
toolCallId: value.item.id,
|
|
4458
|
-
toolName: "web_search",
|
|
4469
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
4459
4470
|
result: mapWebSearchOutput(value.item.action)
|
|
4460
4471
|
});
|
|
4461
4472
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4921,6 +4932,9 @@ function mapWebSearchOutput(action) {
|
|
|
4921
4932
|
openaiChatLanguageModelOptions,
|
|
4922
4933
|
openaiCompletionProviderOptions,
|
|
4923
4934
|
openaiEmbeddingProviderOptions,
|
|
4924
|
-
openaiSpeechProviderOptionsSchema
|
|
4935
|
+
openaiSpeechProviderOptionsSchema,
|
|
4936
|
+
webSearchPreview,
|
|
4937
|
+
webSearchPreviewArgsSchema,
|
|
4938
|
+
webSearchPreviewInputSchema
|
|
4925
4939
|
});
|
|
4926
4940
|
//# sourceMappingURL=index.js.map
|