@ai-sdk/openai 4.0.102 → 4.0.104
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 +29 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -50
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +101 -5
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +74 -47
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +10 -6
- package/package.json +2 -2
- package/src/chat/openai-chat-language-model-options.ts +1 -0
- package/src/completion/convert-to-openai-completion-prompt.ts +1 -1
- package/src/internal/index.ts +1 -0
- package/src/normalize-openai-json-schema.ts +2 -1
- package/src/openai-batch.ts +2 -4
- package/src/openai-language-model-capabilities.ts +8 -5
- package/src/responses/openai-responses-language-model-options.ts +2 -0
- package/src/responses/openai-responses-language-model.ts +18 -8
- package/src/responses/openai-responses-prepare-tools.ts +4 -3
- package/src/transcription/openai-transcription-model-options.ts +5 -6
- package/src/transcription/openai-transcription-model.ts +89 -48
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EmbeddingModelV4, Experimental_TranscriptionModelV4StreamOptions, ImageModelV4, JSONObject, JSONSchema7, JSONValue, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SharedV4Warning, SpeechModelV4, TranscriptionModelV4, TranscriptionModelV4CallOptions } from "@ai-sdk/provider";
|
|
2
|
-
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, FetchFunction, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, FetchFunction, FlexibleSchema, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/chat/openai-chat-language-model-options.d.ts
|
|
5
|
-
export type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
|
|
5
|
+
export type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6.1-terra' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
|
|
6
6
|
export declare const openaiLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
7
7
|
logitBias?: Record<number, number> | undefined;
|
|
8
8
|
logprobs?: number | boolean | undefined;
|
|
@@ -243,7 +243,7 @@ export declare class OpenAIImageModel implements ImageModelV4 {
|
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/transcription/openai-transcription-model-options.d.ts
|
|
246
|
-
export type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-mini-transcribe-2025-03-20' | 'gpt-4o-mini-transcribe-2025-12-15' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'gpt-realtime-whisper' | (string & {});
|
|
246
|
+
export type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-mini-transcribe-2025-03-20' | 'gpt-4o-mini-transcribe-2025-12-15' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'gpt-live-transcribe' | 'gpt-realtime-whisper' | 'gpt-transcribe' | (string & {});
|
|
247
247
|
export declare const openAITranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
248
248
|
include?: string[] | undefined;
|
|
249
249
|
language?: string | undefined;
|
|
@@ -332,7 +332,7 @@ export declare class OpenAISpeechModel implements SpeechModelV4 {
|
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
334
334
|
//#region src/responses/openai-responses-language-model-options.d.ts
|
|
335
|
-
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
|
335
|
+
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6.1-terra' | 'gpt-6-luna' | 'gpt-6-sol' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
|
336
336
|
declare const openaiResponsesToolResultOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
337
337
|
additionalTools?: {
|
|
338
338
|
type: "function";
|
|
@@ -2004,7 +2004,17 @@ export declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
2004
2004
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
2005
2005
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
2006
2006
|
}
|
|
2007
|
-
export declare function
|
|
2007
|
+
export declare function mapWebSearchResult({ action, status }: {
|
|
2008
|
+
action?: OpenAIResponsesWebSearchAction | null;
|
|
2009
|
+
status: string;
|
|
2010
|
+
}): {
|
|
2011
|
+
isError: true;
|
|
2012
|
+
result: {
|
|
2013
|
+
status: string;
|
|
2014
|
+
};
|
|
2015
|
+
} | {
|
|
2016
|
+
result: InferSchema<typeof webSearchOutputSchema>;
|
|
2017
|
+
};
|
|
2008
2018
|
//#endregion
|
|
2009
2019
|
//#region src/responses/openai-responses-provider-metadata.d.ts
|
|
2010
2020
|
type OpenaiResponsesChunk = InferSchema<typeof openaiResponsesChunkSchema>;
|
|
@@ -2492,6 +2502,92 @@ export declare const programmaticToolCalling: () => import("@ai-sdk/provider-uti
|
|
|
2492
2502
|
status: "completed" | "incomplete";
|
|
2493
2503
|
}, {}>>;
|
|
2494
2504
|
//#endregion
|
|
2505
|
+
//#region src/tool/tool-search.d.ts
|
|
2506
|
+
export declare const toolSearchArgsSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
2507
|
+
execution?: "server" | "client" | undefined;
|
|
2508
|
+
description?: string | undefined;
|
|
2509
|
+
parameters?: Record<string, unknown> | undefined;
|
|
2510
|
+
}>;
|
|
2511
|
+
export declare const toolSearchInputSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
2512
|
+
arguments?: unknown;
|
|
2513
|
+
call_id?: string | null | undefined;
|
|
2514
|
+
}>;
|
|
2515
|
+
export declare const toolSearchOutputSchema: FlexibleSchema<{
|
|
2516
|
+
tools: Array<JSONObject>;
|
|
2517
|
+
}>;
|
|
2518
|
+
declare const toolSearchToolFactory: import("@ai-sdk/provider-utils").ProviderDefinedToolFactoryWithOutputSchema<{
|
|
2519
|
+
/**
|
|
2520
|
+
* The arguments from the tool_search_call.
|
|
2521
|
+
* This is preserved for multi-turn conversation reconstruction.
|
|
2522
|
+
*/
|
|
2523
|
+
arguments?: unknown;
|
|
2524
|
+
/**
|
|
2525
|
+
* The call ID from the tool_search_call.
|
|
2526
|
+
* Present for client-executed tool search; null for hosted.
|
|
2527
|
+
*/
|
|
2528
|
+
call_id?: string | null;
|
|
2529
|
+
}, {
|
|
2530
|
+
/**
|
|
2531
|
+
* The tools that were loaded by the tool search.
|
|
2532
|
+
* These are the deferred tools that the model requested to load.
|
|
2533
|
+
* Each tool is represented as a JSON object with properties depending on its type.
|
|
2534
|
+
*
|
|
2535
|
+
* Common properties include:
|
|
2536
|
+
* - `type`: The type of the tool (e.g., 'function', 'web_search', etc.)
|
|
2537
|
+
* - `name`: The name of the tool (for function tools)
|
|
2538
|
+
* - `description`: A description of the tool
|
|
2539
|
+
* - `deferLoading`: Whether this tool was deferred (had defer_loading: true)
|
|
2540
|
+
* - `parameters`: The JSON Schema for the function parameters (for function tools)
|
|
2541
|
+
* - `strict`: Whether to enable strict schema adherence (for function tools)
|
|
2542
|
+
*/
|
|
2543
|
+
tools: Array<JSONObject>;
|
|
2544
|
+
}, {
|
|
2545
|
+
/**
|
|
2546
|
+
* Whether the tool search is executed by the server (hosted) or client.
|
|
2547
|
+
* - `'server'` (default): OpenAI performs the search across deferred tools.
|
|
2548
|
+
* - `'client'`: The model emits a `tool_search_call` and your `execute`
|
|
2549
|
+
* function performs the lookup, returning the tools to load.
|
|
2550
|
+
*/
|
|
2551
|
+
execution?: "server" | "client";
|
|
2552
|
+
/**
|
|
2553
|
+
* A description of the tool search capability.
|
|
2554
|
+
* Only used for client-executed tool search.
|
|
2555
|
+
*/
|
|
2556
|
+
description?: string;
|
|
2557
|
+
/**
|
|
2558
|
+
* JSON Schema for the search arguments your application expects.
|
|
2559
|
+
* Only used for client-executed tool search.
|
|
2560
|
+
*/
|
|
2561
|
+
parameters?: Record<string, unknown>;
|
|
2562
|
+
}, {}>;
|
|
2563
|
+
export declare const toolSearch: (args?: Parameters<typeof toolSearchToolFactory>[0]) => import("@ai-sdk/provider-utils").ProviderDefinedTool<{
|
|
2564
|
+
/**
|
|
2565
|
+
* The arguments from the tool_search_call.
|
|
2566
|
+
* This is preserved for multi-turn conversation reconstruction.
|
|
2567
|
+
*/
|
|
2568
|
+
arguments?: unknown;
|
|
2569
|
+
/**
|
|
2570
|
+
* The call ID from the tool_search_call.
|
|
2571
|
+
* Present for client-executed tool search; null for hosted.
|
|
2572
|
+
*/
|
|
2573
|
+
call_id?: string | null;
|
|
2574
|
+
}, {
|
|
2575
|
+
/**
|
|
2576
|
+
* The tools that were loaded by the tool search.
|
|
2577
|
+
* These are the deferred tools that the model requested to load.
|
|
2578
|
+
* Each tool is represented as a JSON object with properties depending on its type.
|
|
2579
|
+
*
|
|
2580
|
+
* Common properties include:
|
|
2581
|
+
* - `type`: The type of the tool (e.g., 'function', 'web_search', etc.)
|
|
2582
|
+
* - `name`: The name of the tool (for function tools)
|
|
2583
|
+
* - `description`: A description of the tool
|
|
2584
|
+
* - `deferLoading`: Whether this tool was deferred (had defer_loading: true)
|
|
2585
|
+
* - `parameters`: The JSON Schema for the function parameters (for function tools)
|
|
2586
|
+
* - `strict`: Whether to enable strict schema adherence (for function tools)
|
|
2587
|
+
*/
|
|
2588
|
+
tools: Array<JSONObject>;
|
|
2589
|
+
}, {}>;
|
|
2590
|
+
//#endregion
|
|
2495
2591
|
//#region src/tool/web-search-preview.d.ts
|
|
2496
2592
|
export declare const webSearchPreviewArgsSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
2497
2593
|
searchContextSize?: "low" | "medium" | "high" | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["TranscriptionModelV4StreamOptions","_$__openai_responses_api0.OpenAIResponsesTool","_$__openai_responses_api0.OpenAIResponsesAllowedTool","_$__openai_responses_api0.OpenAIResponsesInput"],"sources":["../../src/chat/openai-chat-language-model-options.ts","../../src/chat/openai-chat-language-model.ts","../../src/completion/openai-completion-language-model-options.ts","../../src/completion/openai-completion-language-model.ts","../../src/openai-config.ts","../../src/embedding/openai-embedding-model-options.ts","../../src/embedding/openai-embedding-model.ts","../../src/image/openai-image-model-options.ts","../../src/image/openai-image-model.ts","../../src/transcription/openai-transcription-model-options.ts","../../src/transcription/openai-transcription-model.ts","../../src/speech/openai-speech-model-options.ts","../../src/speech/openai-speech-model.ts","../../src/responses/openai-responses-language-model-options.ts","../../src/responses/openai-responses-api.ts","../../src/tool/web-search.ts","../../src/responses/openai-responses-language-model.ts","../../src/responses/openai-responses-provider-metadata.ts","../../src/tool/apply-patch.ts","../../src/tool/code-interpreter.ts","../../src/tool/file-search.ts","../../src/tool/image-generation.ts","../../src/tool/programmatic-tool-calling.ts","../../src/tool/web-search-preview.ts"],"mappings":";;;;YAQY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["TranscriptionModelV4StreamOptions","_$__openai_responses_api0.OpenAIResponsesTool","_$__openai_responses_api0.OpenAIResponsesAllowedTool","_$__openai_responses_api0.OpenAIResponsesInput"],"sources":["../../src/chat/openai-chat-language-model-options.ts","../../src/chat/openai-chat-language-model.ts","../../src/completion/openai-completion-language-model-options.ts","../../src/completion/openai-completion-language-model.ts","../../src/openai-config.ts","../../src/embedding/openai-embedding-model-options.ts","../../src/embedding/openai-embedding-model.ts","../../src/image/openai-image-model-options.ts","../../src/image/openai-image-model.ts","../../src/transcription/openai-transcription-model-options.ts","../../src/transcription/openai-transcription-model.ts","../../src/speech/openai-speech-model-options.ts","../../src/speech/openai-speech-model.ts","../../src/responses/openai-responses-language-model-options.ts","../../src/responses/openai-responses-api.ts","../../src/tool/web-search.ts","../../src/responses/openai-responses-language-model.ts","../../src/responses/openai-responses-provider-metadata.ts","../../src/tool/apply-patch.ts","../../src/tool/code-interpreter.ts","../../src/tool/file-search.ts","../../src/tool/image-generation.ts","../../src/tool/programmatic-tool-calling.ts","../../src/tool/tool-search.ts","../../src/tool/web-search-preview.ts"],"mappings":";;;;YAQY;qBAuEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;YAwJ/B,iCAAiC,mBACpC;;;KCpLJ;EACH;;EAEA;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,mCAAmC;WACrC;WAEA,SAAS;WAET;;;mBAIQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAIW,YAAA,SAAS,mBAAmB,QAAQ;MAK5C;UAIU;EA6SR,WACJ,SAAS,6BACR,QAAQ;EA+FL,SACJ,SAAS,6BACR,QAAQ;;;;YCveD;qBAKC,uEAAoC;;cAApC;;;;;YAiDD,uCAAuC,mBAC1C;;;KCpBJ;EACH;;EAEA;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,yCAAyC;WAC3C;WAEA,SAAS;mBAED;cAEL;UAIJ,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAKC,YAAA,SAAS,yBACT,QAAQ;MAMN;WAIK,eAAe,eAAe;UAIzB;EA2FR,WACJ,SAAS,6BACR,QAAQ;EAgDL,SACJ,SAAS,6BACR,QAAQ;;;;KCvOR,gBAAgB;KAEhB,yBAAyB,KAAK,QAAQ;EACzC,iBAAiB,iBAAiB;;KAGxB;EACV;;EAEA;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;iBAGc,0CACd,QAAQ,yBACP;;;YCzCS;qBAMC,8DAA2B;;;;YAkB5B,8BAA8B,mBACjC;;;qBCVI,gCAAgC;WAClC;WACA,SAAS;WACT;YACC;WACD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;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;EAGpC,SAAS;;KAGC;EACN;;EACA;EAAiB;;KAEX;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA;;KAOU,8BAA8B,YACxC,kBAAkB;KAGR;EACV;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF,6BAA6B;IAC3B;IACA;IACA;;;KAIQ,gCAAgC,YAC1C,kBAAkB;KAGR;EACV;EACA;EACA;;;;;KAMU;EACV;EACA;EACA;EACA;EACA;IACE;IACA;IACA;;;KAIQ;EACV;EACA;EACA;EACA;EACA;EACA,QAAQ;IACN;IACA;IACA;MAAW;;MAAsB;MAAc;;;;KAIvC;EACV;EACA;EACA;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;;IAGA;IACA;IACA;;;KAII;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA,OAAO,MAAM;;KAGH;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;IACE;;;KAIQ;EACV;;;;;KAMU;;;;EAIV;;;;EAKA;;;;EAKA;;;;;KAMU;;;;EAIV;;;;EAKA,SAAS,MACL,gDACA;;KAIM;EACV;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA,kBAAkB;EAClB,gBAAgB;;;;;;KAON;EACN;EAAkB;;EAClB;EAAgB;;EAChB;EAAa;;EAEb,MAAM,QACJ;;KAKI,sBACR;EAEE;EACA;EACA;EACA,OAAO,MAAM;;EAGb;;EAGA;;EAGA;EACA;EACA;IAEM;IACA;;EAGN;EACA;IAEM;IACA;IACA;IACA;IACA;;;EAKN;EACA;EACA;IAEM;IACA;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
21
21
|
const isGptChatModel = gptVersion?.minor == null && (gptVersion?.variant?.startsWith("chat") ?? false);
|
|
22
22
|
const isGptNanoModel = gptVersion?.variant?.startsWith("nano") ?? false;
|
|
23
23
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
24
|
-
const
|
|
24
|
+
const isGpt6OrLaterModelWithNoneEffort = modelId === "gpt-6-sol" || modelId === "gpt-6-luna" || modelId === "gpt-6.1-terra";
|
|
25
25
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
26
26
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
27
27
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
28
|
-
const supportsNonReasoningParameters =
|
|
28
|
+
const supportsNonReasoningParameters = isGpt6OrLaterModelWithNoneEffort || !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1);
|
|
29
29
|
return {
|
|
30
30
|
supportsFlexProcessing,
|
|
31
31
|
supportsPriorityProcessing,
|
|
32
32
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
33
33
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
34
|
-
supportedReasoningEfforts:
|
|
34
|
+
supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort ? [
|
|
35
35
|
"none",
|
|
36
36
|
"low",
|
|
37
37
|
"medium",
|
|
@@ -757,7 +757,7 @@ function normalizeOpenAIJsonSchema(schema) {
|
|
|
757
757
|
function normalizeSchema(schema, isRoot = false) {
|
|
758
758
|
const propertyNames = schema.propertyNames;
|
|
759
759
|
if (propertyNames != null) {
|
|
760
|
-
if (typeof propertyNames === "boolean" || propertyNames.type !== "string") throw new UnsupportedFunctionalityError({ functionality: "JSON Schema propertyNames that does not use a string schema" });
|
|
760
|
+
if (typeof propertyNames === "boolean" || propertyNames.type != null && propertyNames.type !== "string") throw new UnsupportedFunctionalityError({ functionality: "JSON Schema propertyNames that does not use a string schema" });
|
|
761
761
|
removedPropertyNames = true;
|
|
762
762
|
}
|
|
763
763
|
const normalizedSchema = { ...schema };
|
|
@@ -1345,7 +1345,7 @@ function convertToOpenAICompletionPrompt({ prompt, user = "user", assistant = "a
|
|
|
1345
1345
|
}
|
|
1346
1346
|
for (const { role, content } of prompt) switch (role) {
|
|
1347
1347
|
case "system": throw new InvalidPromptError({
|
|
1348
|
-
message:
|
|
1348
|
+
message: `Unexpected system message in prompt: ${content}`,
|
|
1349
1349
|
prompt
|
|
1350
1350
|
});
|
|
1351
1351
|
case "user": {
|
|
@@ -2141,9 +2141,9 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2141
2141
|
temperature: z.number().min(0).max(1).default(0).optional(),
|
|
2142
2142
|
/**
|
|
2143
2143
|
* The timestamp granularities to populate for this transcription.
|
|
2144
|
-
*
|
|
2144
|
+
* Defaults to ['segment'] when the response format is verbose_json.
|
|
2145
2145
|
*/
|
|
2146
|
-
timestampGranularities: z.array(z.enum(["word", "segment"])).
|
|
2146
|
+
timestampGranularities: z.array(z.enum(["word", "segment"])).optional(),
|
|
2147
2147
|
/**
|
|
2148
2148
|
* The format of the transcription response.
|
|
2149
2149
|
*/
|
|
@@ -2162,7 +2162,7 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2162
2162
|
silenceDurationMs: z.number().int().min(0).optional()
|
|
2163
2163
|
})]).optional(),
|
|
2164
2164
|
/**
|
|
2165
|
-
* Options for streaming transcription models such as `gpt-
|
|
2165
|
+
* Options for streaming transcription models such as `gpt-live-transcribe`.
|
|
2166
2166
|
*/
|
|
2167
2167
|
streaming: z.object({
|
|
2168
2168
|
/**
|
|
@@ -2184,12 +2184,32 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/transcription/openai-transcription-model.ts
|
|
2186
2186
|
/**
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2189
|
-
|
|
2187
|
+
* Whether `modelId` is `base` or one of its dated snapshots
|
|
2188
|
+
* (e.g. `gpt-realtime-whisper-2026-01-01`).
|
|
2189
|
+
*/
|
|
2190
|
+
function isModelOrSnapshot(modelId, base) {
|
|
2191
|
+
return modelId === base || modelId.startsWith(`${base}-`);
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Model IDs that stream over the realtime transcription WebSocket and do not
|
|
2195
|
+
* support the REST transcription endpoint.
|
|
2190
2196
|
*/
|
|
2191
2197
|
function isRealtimeTranscriptionModelId(modelId) {
|
|
2192
|
-
return modelId
|
|
2198
|
+
return isModelOrSnapshot(modelId, "gpt-realtime-whisper") || isModelOrSnapshot(modelId, "gpt-live-transcribe");
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Model IDs that support streaming transcription. `gpt-transcribe` also
|
|
2202
|
+
* supports the REST transcription endpoint.
|
|
2203
|
+
*/
|
|
2204
|
+
function supportsStreamingTranscription(modelId) {
|
|
2205
|
+
return isRealtimeTranscriptionModelId(modelId) || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Models whose realtime transcription session takes a `languages` list
|
|
2209
|
+
* instead of the singular `language` field.
|
|
2210
|
+
*/
|
|
2211
|
+
function usesLanguagesList(modelId) {
|
|
2212
|
+
return isModelOrSnapshot(modelId, "gpt-live-transcribe") || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
2193
2213
|
}
|
|
2194
2214
|
const languageMap = {
|
|
2195
2215
|
afrikaans: "af",
|
|
@@ -2283,24 +2303,22 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2283
2303
|
formData.append("model", this.modelId);
|
|
2284
2304
|
const fileExtension = mediaTypeToExtension(mediaType);
|
|
2285
2305
|
formData.append("file", new File([blob], "audio", { type: mediaType }), `audio.${fileExtension}`);
|
|
2286
|
-
if (this.modelId === "whisper-1") formData.append("response_format", "verbose_json");
|
|
2287
2306
|
const isDiarizationModel = this.modelId === "gpt-4o-transcribe-diarize";
|
|
2307
|
+
const responseFormat = openAIOptions?.responseFormat ?? (isDiarizationModel ? "diarized_json" : this.modelId === "whisper-1" ? "verbose_json" : void 0);
|
|
2308
|
+
const timestampGranularities = openAIOptions?.timestampGranularities ?? (responseFormat === "verbose_json" ? ["segment"] : void 0);
|
|
2288
2309
|
const chunkingStrategy = openAIOptions?.chunkingStrategy ?? (isDiarizationModel ? "auto" : void 0);
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
};
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
else formData.append(key, String(value));
|
|
2302
|
-
}
|
|
2303
|
-
} else if (isDiarizationModel) formData.append("response_format", "diarized_json");
|
|
2310
|
+
const transcriptionModelOptions = {
|
|
2311
|
+
response_format: responseFormat,
|
|
2312
|
+
include: openAIOptions?.include,
|
|
2313
|
+
language: openAIOptions?.language,
|
|
2314
|
+
prompt: openAIOptions?.prompt,
|
|
2315
|
+
temperature: openAIOptions?.temperature,
|
|
2316
|
+
timestamp_granularities: timestampGranularities
|
|
2317
|
+
};
|
|
2318
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) if (value != null) {
|
|
2319
|
+
if (Array.isArray(value)) for (const item of value) formData.append(`${key}[]`, String(item));
|
|
2320
|
+
else formData.append(key, String(value));
|
|
2321
|
+
}
|
|
2304
2322
|
if (chunkingStrategy != null) formData.append("chunking_strategy", typeof chunkingStrategy === "string" ? chunkingStrategy : JSON.stringify({
|
|
2305
2323
|
type: chunkingStrategy.type,
|
|
2306
2324
|
...chunkingStrategy.threshold != null && { threshold: chunkingStrategy.threshold },
|
|
@@ -2347,7 +2365,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2347
2365
|
endSecond: word.end
|
|
2348
2366
|
})) ?? [],
|
|
2349
2367
|
language,
|
|
2350
|
-
durationInSeconds: response.duration ?? void 0,
|
|
2368
|
+
durationInSeconds: response.duration ?? (response.usage?.type === "duration" && typeof response.usage.seconds === "number" ? response.usage.seconds : void 0),
|
|
2351
2369
|
warnings,
|
|
2352
2370
|
...response.usage != null && { usage: response.usage },
|
|
2353
2371
|
response: {
|
|
@@ -2363,7 +2381,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2363
2381
|
};
|
|
2364
2382
|
}
|
|
2365
2383
|
async doStream(options) {
|
|
2366
|
-
if (!
|
|
2384
|
+
if (!supportsStreamingTranscription(this.modelId)) throw new UnsupportedFunctionalityError({ functionality: `streaming transcription with ${this.modelId}` });
|
|
2367
2385
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
2368
2386
|
const openAIOptions = await parseProviderOptions({
|
|
2369
2387
|
provider: "openai",
|
|
@@ -2382,11 +2400,18 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2382
2400
|
feature: `providerOptions.openai.${option}`,
|
|
2383
2401
|
details: `OpenAI streaming transcription does not support ${option}.`
|
|
2384
2402
|
});
|
|
2403
|
+
const supportsDelay = !isModelOrSnapshot(this.modelId, "gpt-transcribe");
|
|
2404
|
+
if (!supportsDelay && openAIOptions?.streaming?.delay != null) warnings.push({
|
|
2405
|
+
type: "unsupported",
|
|
2406
|
+
feature: "providerOptions.openai.streaming.delay",
|
|
2407
|
+
details: `OpenAI streaming transcription with ${this.modelId} does not support delay.`
|
|
2408
|
+
});
|
|
2385
2409
|
const headers = combineHeaders(this.config.headers?.(), options.headers);
|
|
2386
2410
|
const sessionUpdate = buildOpenAIRealtimeTranscriptionSession({
|
|
2387
2411
|
modelId: this.modelId,
|
|
2388
2412
|
inputAudioFormat: options.inputAudioFormat,
|
|
2389
|
-
providerOptions: openAIOptions
|
|
2413
|
+
providerOptions: openAIOptions,
|
|
2414
|
+
supportsDelay
|
|
2390
2415
|
});
|
|
2391
2416
|
return {
|
|
2392
2417
|
request: { body: sessionUpdate },
|
|
@@ -2521,7 +2546,7 @@ function createOpenAIRealtimeTranscriptionStream({ webSocket, url, headers, sess
|
|
|
2521
2546
|
}
|
|
2522
2547
|
});
|
|
2523
2548
|
}
|
|
2524
|
-
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions }) {
|
|
2549
|
+
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions, supportsDelay }) {
|
|
2525
2550
|
return {
|
|
2526
2551
|
type: "session.update",
|
|
2527
2552
|
session: {
|
|
@@ -2533,8 +2558,8 @@ function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, pr
|
|
|
2533
2558
|
},
|
|
2534
2559
|
transcription: {
|
|
2535
2560
|
model: modelId,
|
|
2536
|
-
...providerOptions?.language != null ? { language: providerOptions.language } : {},
|
|
2537
|
-
...providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
2561
|
+
...providerOptions?.language != null ? usesLanguagesList(modelId) ? { languages: [providerOptions.language] } : { language: providerOptions.language } : {},
|
|
2562
|
+
...supportsDelay && providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
2538
2563
|
},
|
|
2539
2564
|
turn_detection: null
|
|
2540
2565
|
} },
|
|
@@ -3230,11 +3255,12 @@ const toolSearchInputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
3230
3255
|
call_id: z.string().nullish()
|
|
3231
3256
|
})));
|
|
3232
3257
|
const toolSearchOutputSchema = lazySchema(() => zodSchema(z.object({ tools: z.array(z.record(z.string(), z.unknown())) })));
|
|
3233
|
-
createProviderDefinedToolFactoryWithOutputSchema({
|
|
3258
|
+
const toolSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
3234
3259
|
id: "openai.tool_search",
|
|
3235
3260
|
inputSchema: toolSearchInputSchema,
|
|
3236
3261
|
outputSchema: toolSearchOutputSchema
|
|
3237
3262
|
});
|
|
3263
|
+
const toolSearch = (args = {}) => toolSearchToolFactory(args);
|
|
3238
3264
|
//#endregion
|
|
3239
3265
|
//#region src/tool/programmatic-tool-calling.ts
|
|
3240
3266
|
const programmaticToolCallingInputSchema = lazySchema(() => zodSchema(z.object({
|
|
@@ -5714,7 +5740,7 @@ const webSearchPreview = createProviderExecutedToolFactory({
|
|
|
5714
5740
|
});
|
|
5715
5741
|
//#endregion
|
|
5716
5742
|
//#region src/responses/openai-responses-prepare-tools.ts
|
|
5717
|
-
async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolNameMapping, customProviderToolNames, outputSchemaToolNames, supportsAsyncToolCalling = true }) {
|
|
5743
|
+
async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolNameMapping, customProviderToolNames, outputSchemaToolNames, supportsAsyncToolCalling = true, providerOptionsName = "openai" }) {
|
|
5718
5744
|
tools = tools?.length ? tools : void 0;
|
|
5719
5745
|
const toolWarnings = [];
|
|
5720
5746
|
if (tools == null) return {
|
|
@@ -5736,7 +5762,7 @@ async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolName
|
|
|
5736
5762
|
};
|
|
5737
5763
|
for (const tool of tools) switch (tool.type) {
|
|
5738
5764
|
case "function": {
|
|
5739
|
-
const openaiOptions = tool.providerOptions?.openai;
|
|
5765
|
+
const openaiOptions = tool.providerOptions?.[providerOptionsName] ?? tool.providerOptions?.openai;
|
|
5740
5766
|
if (openaiOptions?.outputSchema != null) outputSchemaToolNames?.add(tool.name);
|
|
5741
5767
|
if (openaiOptions?.omitFromRequestTools === true) {
|
|
5742
5768
|
recordAllowedTool(tool.name, {
|
|
@@ -6352,7 +6378,8 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6352
6378
|
toolNameMapping,
|
|
6353
6379
|
customProviderToolNames,
|
|
6354
6380
|
outputSchemaToolNames,
|
|
6355
|
-
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
6381
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling,
|
|
6382
|
+
providerOptionsName
|
|
6356
6383
|
});
|
|
6357
6384
|
const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
|
|
6358
6385
|
modelCapabilities,
|
|
@@ -6819,10 +6846,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6819
6846
|
type: "tool-result",
|
|
6820
6847
|
toolCallId: part.id,
|
|
6821
6848
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
6822
|
-
...part
|
|
6823
|
-
isError: true,
|
|
6824
|
-
result: { status: part.status }
|
|
6825
|
-
} : { result: mapWebSearchOutput(part.action) }
|
|
6849
|
+
...mapWebSearchResult(part)
|
|
6826
6850
|
});
|
|
6827
6851
|
if (part.action?.type === "search") {
|
|
6828
6852
|
for (const source of part.action.sources ?? []) if (source.type === "url") content.push({
|
|
@@ -7433,10 +7457,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7433
7457
|
type: "tool-result",
|
|
7434
7458
|
toolCallId: value.item.id,
|
|
7435
7459
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
7436
|
-
...value.item
|
|
7437
|
-
isError: true,
|
|
7438
|
-
result: { status: value.item.status }
|
|
7439
|
-
} : { result: mapWebSearchOutput(value.item.action) }
|
|
7460
|
+
...mapWebSearchResult(value.item)
|
|
7440
7461
|
});
|
|
7441
7462
|
if (value.item.action?.type === "search") {
|
|
7442
7463
|
for (const source of value.item.action.sources ?? []) if (source.type === "url") {
|
|
@@ -8052,6 +8073,12 @@ function isResponseInProgressChunk(chunk) {
|
|
|
8052
8073
|
function isResponseOutputChunk(chunk) {
|
|
8053
8074
|
return !(chunk.type === "response.created" || chunk.type === "response.in_progress" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
|
|
8054
8075
|
}
|
|
8076
|
+
function mapWebSearchResult({ action, status }) {
|
|
8077
|
+
return status === "completed" ? { result: mapWebSearchOutput(action) } : {
|
|
8078
|
+
isError: true,
|
|
8079
|
+
result: { status }
|
|
8080
|
+
};
|
|
8081
|
+
}
|
|
8055
8082
|
function mapWebSearchOutput(action) {
|
|
8056
8083
|
if (action == null) return {};
|
|
8057
8084
|
switch (action.type) {
|
|
@@ -8078,6 +8105,6 @@ function escapeJSONDelta(delta) {
|
|
|
8078
8105
|
return JSON.stringify(delta).slice(1, -1);
|
|
8079
8106
|
}
|
|
8080
8107
|
//#endregion
|
|
8081
|
-
export { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema,
|
|
8108
|
+
export { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchResult, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiResponsesSupportedUrls, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, toolSearch, toolSearchArgsSchema, toolSearchInputSchema, toolSearchOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
|
|
8082
8109
|
|
|
8083
8110
|
//# sourceMappingURL=index.js.map
|