openai 6.45.0 → 6.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +9 -2
- package/client.d.mts +1 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -0
- package/client.d.ts.map +1 -1
- package/client.js +11 -5
- package/client.js.map +1 -1
- package/client.mjs +11 -5
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +38 -6
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +38 -6
- package/core/streaming.mjs.map +1 -1
- package/core/uploads.d.mts +1 -1
- package/core/uploads.d.mts.map +1 -1
- package/core/uploads.d.ts +1 -1
- package/core/uploads.d.ts.map +1 -1
- package/core/uploads.js +3 -1
- package/core/uploads.js.map +1 -1
- package/core/uploads.mjs +1 -0
- package/core/uploads.mjs.map +1 -1
- package/helpers/audio.d.mts.map +1 -1
- package/helpers/audio.d.ts.map +1 -1
- package/helpers/audio.js +16 -3
- package/helpers/audio.js.map +1 -1
- package/helpers/audio.mjs +17 -4
- package/helpers/audio.mjs.map +1 -1
- package/helpers/zod.d.mts +20 -7
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts +20 -7
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +24 -12
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +24 -12
- package/helpers/zod.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/internal/uploads.d.mts +26 -1
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +26 -1
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +169 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +169 -2
- package/internal/uploads.mjs.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts +3 -3
- package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts +3 -3
- package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/lib/AbstractChatCompletionRunner.js +18 -3
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +18 -3
- package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/lib/AssistantStream.d.mts.map +1 -1
- package/lib/AssistantStream.d.ts.map +1 -1
- package/lib/AssistantStream.js +4 -3
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +4 -3
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionRunner.d.mts +26 -2
- package/lib/ChatCompletionRunner.d.mts.map +1 -1
- package/lib/ChatCompletionRunner.d.ts +26 -2
- package/lib/ChatCompletionRunner.d.ts.map +1 -1
- package/lib/ChatCompletionRunner.js.map +1 -1
- package/lib/ChatCompletionRunner.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts +14 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts +14 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +75 -16
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +74 -16
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/lib/ChatCompletionStreamingRunner.d.mts +25 -2
- package/lib/ChatCompletionStreamingRunner.d.mts.map +1 -1
- package/lib/ChatCompletionStreamingRunner.d.ts +25 -2
- package/lib/ChatCompletionStreamingRunner.d.ts.map +1 -1
- package/lib/ChatCompletionStreamingRunner.js +77 -0
- package/lib/ChatCompletionStreamingRunner.js.map +1 -1
- package/lib/ChatCompletionStreamingRunner.mjs +78 -1
- package/lib/ChatCompletionStreamingRunner.mjs.map +1 -1
- package/lib/EventStream.d.mts +13 -0
- package/lib/EventStream.d.mts.map +1 -1
- package/lib/EventStream.d.ts +13 -0
- package/lib/EventStream.d.ts.map +1 -1
- package/lib/EventStream.js +107 -2
- package/lib/EventStream.js.map +1 -1
- package/lib/EventStream.mjs +107 -2
- package/lib/EventStream.mjs.map +1 -1
- package/lib/RunnableFunction.d.mts +38 -21
- package/lib/RunnableFunction.d.mts.map +1 -1
- package/lib/RunnableFunction.d.ts +38 -21
- package/lib/RunnableFunction.d.ts.map +1 -1
- package/lib/RunnableFunction.js.map +1 -1
- package/lib/RunnableFunction.mjs.map +1 -1
- package/lib/parser.d.mts +2 -2
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts +2 -2
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs.map +1 -1
- package/lib/responses/ResponseAccumulator.d.mts +6 -1
- package/lib/responses/ResponseAccumulator.d.mts.map +1 -1
- package/lib/responses/ResponseAccumulator.d.ts +6 -1
- package/lib/responses/ResponseAccumulator.d.ts.map +1 -1
- package/lib/responses/ResponseAccumulator.js +1 -0
- package/lib/responses/ResponseAccumulator.js.map +1 -1
- package/lib/responses/ResponseAccumulator.mjs +1 -0
- package/lib/responses/ResponseAccumulator.mjs.map +1 -1
- package/lib/responses/ResponseInputItems.d.mts.map +1 -1
- package/lib/responses/ResponseInputItems.d.ts.map +1 -1
- package/lib/responses/ResponseInputItems.js +2 -0
- package/lib/responses/ResponseInputItems.js.map +1 -1
- package/lib/responses/ResponseInputItems.mjs +2 -0
- package/lib/responses/ResponseInputItems.mjs.map +1 -1
- package/lib/responses/ResponseStream.d.mts +6 -1
- package/lib/responses/ResponseStream.d.mts.map +1 -1
- package/lib/responses/ResponseStream.d.ts +6 -1
- package/lib/responses/ResponseStream.d.ts.map +1 -1
- package/lib/responses/ResponseStream.js +21 -0
- package/lib/responses/ResponseStream.js.map +1 -1
- package/lib/responses/ResponseStream.mjs +21 -0
- package/lib/responses/ResponseStream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/admin/organization/projects/api-keys.d.mts +12 -0
- package/resources/admin/organization/projects/api-keys.d.mts.map +1 -1
- package/resources/admin/organization/projects/api-keys.d.ts +12 -0
- package/resources/admin/organization/projects/api-keys.d.ts.map +1 -1
- package/resources/beta/assistants.d.mts +12 -26
- package/resources/beta/assistants.d.mts.map +1 -1
- package/resources/beta/assistants.d.ts +12 -26
- package/resources/beta/assistants.d.ts.map +1 -1
- package/resources/beta/beta.d.mts +6 -1
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +6 -1
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +4 -0
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +4 -0
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -0
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -0
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js +5 -3
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs +1 -0
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/responses/index.d.mts +6 -0
- package/resources/beta/responses/index.d.mts.map +1 -0
- package/resources/beta/responses/index.d.ts +6 -0
- package/resources/beta/responses/index.d.ts.map +1 -0
- package/resources/beta/responses/index.js +11 -0
- package/resources/beta/responses/index.js.map +1 -0
- package/resources/beta/responses/index.mjs +5 -0
- package/resources/beta/responses/index.mjs.map +1 -0
- package/resources/beta/responses/input-items.d.mts +69 -0
- package/resources/beta/responses/input-items.d.mts.map +1 -0
- package/resources/beta/responses/input-items.d.ts +69 -0
- package/resources/beta/responses/input-items.d.ts.map +1 -0
- package/resources/beta/responses/input-items.js +37 -0
- package/resources/beta/responses/input-items.js.map +1 -0
- package/resources/beta/responses/input-items.mjs +33 -0
- package/resources/beta/responses/input-items.mjs.map +1 -0
- package/resources/beta/responses/input-tokens.d.mts +191 -0
- package/resources/beta/responses/input-tokens.d.mts.map +1 -0
- package/resources/beta/responses/input-tokens.d.ts +191 -0
- package/resources/beta/responses/input-tokens.d.ts.map +1 -0
- package/resources/beta/responses/input-tokens.js +34 -0
- package/resources/beta/responses/input-tokens.js.map +1 -0
- package/resources/beta/responses/input-tokens.mjs +30 -0
- package/resources/beta/responses/input-tokens.mjs.map +1 -0
- package/resources/beta/responses/internal-base.d.mts +71 -0
- package/resources/beta/responses/internal-base.d.mts.map +1 -0
- package/resources/beta/responses/internal-base.d.ts +71 -0
- package/resources/beta/responses/internal-base.d.ts.map +1 -0
- package/resources/beta/responses/internal-base.js +48 -0
- package/resources/beta/responses/internal-base.js.map +1 -0
- package/resources/beta/responses/internal-base.mjs +42 -0
- package/resources/beta/responses/internal-base.mjs.map +1 -0
- package/resources/beta/responses/responses.d.mts +9986 -0
- package/resources/beta/responses/responses.d.mts.map +1 -0
- package/resources/beta/responses/responses.d.ts +9986 -0
- package/resources/beta/responses/responses.d.ts.map +1 -0
- package/resources/beta/responses/responses.js +121 -0
- package/resources/beta/responses/responses.js.map +1 -0
- package/resources/beta/responses/responses.mjs +116 -0
- package/resources/beta/responses/responses.mjs.map +1 -0
- package/resources/beta/responses/ws-base.d.mts +106 -0
- package/resources/beta/responses/ws-base.d.mts.map +1 -0
- package/resources/beta/responses/ws-base.d.ts +106 -0
- package/resources/beta/responses/ws-base.d.ts.map +1 -0
- package/resources/beta/responses/ws-base.js +476 -0
- package/resources/beta/responses/ws-base.js.map +1 -0
- package/resources/beta/responses/ws-base.mjs +472 -0
- package/resources/beta/responses/ws-base.mjs.map +1 -0
- package/resources/beta/responses/ws.d.mts +13 -0
- package/resources/beta/responses/ws.d.mts.map +1 -0
- package/resources/beta/responses/ws.d.ts +13 -0
- package/resources/beta/responses/ws.d.ts.map +1 -0
- package/resources/beta/responses/ws.js +31 -0
- package/resources/beta/responses/ws.js.map +1 -0
- package/resources/beta/responses/ws.mjs +26 -0
- package/resources/beta/responses/ws.mjs.map +1 -0
- package/resources/beta/responses.d.mts +2 -0
- package/resources/beta/responses.d.mts.map +1 -0
- package/resources/beta/responses.d.ts +2 -0
- package/resources/beta/responses.d.ts.map +1 -0
- package/resources/beta/responses.js +6 -0
- package/resources/beta/responses.js.map +1 -0
- package/resources/beta/responses.mjs +3 -0
- package/resources/beta/responses.mjs.map +1 -0
- package/resources/beta/threads/runs/runs.d.mts +6 -13
- package/resources/beta/threads/runs/runs.d.mts.map +1 -1
- package/resources/beta/threads/runs/runs.d.ts +6 -13
- package/resources/beta/threads/runs/runs.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.js.map +1 -1
- package/resources/beta/threads/runs/runs.mjs.map +1 -1
- package/resources/chat/completions/completions.d.mts +170 -20
- package/resources/chat/completions/completions.d.mts.map +1 -1
- package/resources/chat/completions/completions.d.ts +170 -20
- package/resources/chat/completions/completions.d.ts.map +1 -1
- package/resources/chat/completions/completions.js.map +1 -1
- package/resources/chat/completions/completions.mjs.map +1 -1
- package/resources/completions.d.mts +4 -0
- package/resources/completions.d.mts.map +1 -1
- package/resources/completions.d.ts +4 -0
- package/resources/completions.d.ts.map +1 -1
- package/resources/conversations/conversations.d.mts +19 -0
- package/resources/conversations/conversations.d.mts.map +1 -1
- package/resources/conversations/conversations.d.ts +19 -0
- package/resources/conversations/conversations.d.ts.map +1 -1
- package/resources/conversations/conversations.js.map +1 -1
- package/resources/conversations/conversations.mjs.map +1 -1
- package/resources/conversations/items.d.mts +45 -1
- package/resources/conversations/items.d.mts.map +1 -1
- package/resources/conversations/items.d.ts +45 -1
- package/resources/conversations/items.d.ts.map +1 -1
- package/resources/evals/runs/runs.d.mts +66 -143
- package/resources/evals/runs/runs.d.mts.map +1 -1
- package/resources/evals/runs/runs.d.ts +66 -143
- package/resources/evals/runs/runs.d.ts.map +1 -1
- package/resources/evals/runs/runs.js.map +1 -1
- package/resources/evals/runs/runs.mjs.map +1 -1
- package/resources/graders/grader-models.d.mts +6 -13
- package/resources/graders/grader-models.d.mts.map +1 -1
- package/resources/graders/grader-models.d.ts +6 -13
- package/resources/graders/grader-models.d.ts.map +1 -1
- package/resources/realtime/calls.d.mts +1 -1
- package/resources/realtime/calls.d.mts.map +1 -1
- package/resources/realtime/calls.d.ts +1 -1
- package/resources/realtime/calls.d.ts.map +1 -1
- package/resources/realtime/client-secrets.d.mts +5 -1
- package/resources/realtime/client-secrets.d.mts.map +1 -1
- package/resources/realtime/client-secrets.d.ts +5 -1
- package/resources/realtime/client-secrets.d.ts.map +1 -1
- package/resources/realtime/realtime.d.mts +9 -1
- package/resources/realtime/realtime.d.mts.map +1 -1
- package/resources/realtime/realtime.d.ts +9 -1
- package/resources/realtime/realtime.d.ts.map +1 -1
- package/resources/realtime/realtime.js.map +1 -1
- package/resources/realtime/realtime.mjs.map +1 -1
- package/resources/responses/input-tokens.d.mts +7 -1
- package/resources/responses/input-tokens.d.mts.map +1 -1
- package/resources/responses/input-tokens.d.ts +7 -1
- package/resources/responses/input-tokens.d.ts.map +1 -1
- package/resources/responses/responses.d.mts +819 -26
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +819 -26
- package/resources/responses/responses.d.ts.map +1 -1
- package/resources/responses/responses.js +1 -1
- package/resources/responses/responses.js.map +1 -1
- package/resources/responses/responses.mjs +1 -1
- package/resources/responses/responses.mjs.map +1 -1
- package/resources/shared.d.mts +20 -28
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +20 -28
- package/resources/shared.d.ts.map +1 -1
- package/src/client.ts +13 -5
- package/src/core/streaming.ts +36 -8
- package/src/core/uploads.ts +6 -1
- package/src/helpers/audio.ts +18 -4
- package/src/helpers/zod.ts +62 -23
- package/src/index.ts +1 -1
- package/src/internal/uploads.ts +214 -4
- package/src/lib/AbstractChatCompletionRunner.ts +32 -9
- package/src/lib/AssistantStream.ts +4 -3
- package/src/lib/ChatCompletionRunner.ts +46 -6
- package/src/lib/ChatCompletionStream.ts +115 -17
- package/src/lib/ChatCompletionStreamingRunner.ts +144 -7
- package/src/lib/EventStream.ts +114 -4
- package/src/lib/RunnableFunction.ts +60 -31
- package/src/lib/parser.ts +4 -0
- package/src/lib/responses/ResponseAccumulator.ts +10 -1
- package/src/lib/responses/ResponseInputItems.ts +2 -0
- package/src/lib/responses/ResponseStream.ts +29 -1
- package/src/resources/admin/organization/projects/api-keys.ts +15 -1
- package/src/resources/beta/assistants.ts +12 -26
- package/src/resources/beta/beta.ts +330 -2
- package/src/resources/beta/index.ts +163 -0
- package/src/resources/beta/responses/index.ts +169 -0
- package/src/resources/beta/responses/input-items.ts +105 -0
- package/src/resources/beta/responses/input-tokens.ts +245 -0
- package/src/resources/beta/responses/internal-base.ts +117 -0
- package/src/resources/beta/responses/responses.ts +12633 -0
- package/src/resources/beta/responses/ws-base.ts +615 -0
- package/src/resources/beta/responses/ws.ts +38 -0
- package/src/resources/beta/responses.ts +3 -0
- package/src/resources/beta/threads/runs/runs.ts +6 -13
- package/src/resources/chat/completions/completions.ts +237 -23
- package/src/resources/completions.ts +5 -0
- package/src/resources/conversations/conversations.ts +21 -0
- package/src/resources/conversations/items.ts +56 -0
- package/src/resources/evals/runs/runs.ts +66 -143
- package/src/resources/graders/grader-models.ts +6 -13
- package/src/resources/realtime/calls.ts +2 -0
- package/src/resources/realtime/client-secrets.ts +7 -0
- package/src/resources/realtime/realtime.ts +12 -0
- package/src/resources/responses/input-tokens.ts +8 -0
- package/src/resources/responses/responses.ts +953 -17
- package/src/resources/shared.ts +23 -27
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/shared.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type AllModels = (string & {}) | ChatModel | 'o1-pro' | 'o1-pro-2025-03-19' | 'o3-pro' | 'o3-pro-2025-06-10' | 'o3-deep-research' | 'o3-deep-research-2025-06-26' | 'o4-mini-deep-research' | 'o4-mini-deep-research-2025-06-26' | 'computer-use-preview' | 'computer-use-preview-2025-03-11' | 'gpt-5-codex' | 'gpt-5-pro' | 'gpt-5-pro-2025-10-06' | 'gpt-5.1-codex-max';
|
|
2
|
-
export type ChatModel = 'gpt-5.4' | 'gpt-5.4-mini' | 'gpt-5.4-nano' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.3-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.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-codex' | 'gpt-5.1-mini' | 'gpt-5.1-chat-latest' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-5-2025-08-07' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano-2025-04-14' | 'o4-mini' | 'o4-mini-2025-04-16' | 'o3' | 'o3-2025-04-16' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o1' | 'o1-2024-12-17' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o1-mini' | 'o1-mini-2024-09-12' | 'gpt-4o' | 'gpt-4o-2024-11-20' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-05-13' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-mini-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview-2025-03-11' | 'chatgpt-4o-latest' | 'codex-mini-latest' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0301' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613';
|
|
2
|
+
export type ChatModel = 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-5.6-luna' | 'gpt-5.4' | 'gpt-5.4-mini' | 'gpt-5.4-nano' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.3-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.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-codex' | 'gpt-5.1-mini' | 'gpt-5.1-chat-latest' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-5-2025-08-07' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano-2025-04-14' | 'o4-mini' | 'o4-mini-2025-04-16' | 'o3' | 'o3-2025-04-16' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o1' | 'o1-2024-12-17' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o1-mini' | 'o1-mini-2024-09-12' | 'gpt-4o' | 'gpt-4o-2024-11-20' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-05-13' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-mini-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview-2025-03-11' | 'chatgpt-4o-latest' | 'codex-mini-latest' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0301' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613';
|
|
3
3
|
/**
|
|
4
4
|
* A filter used to compare a specified attribute key to a given value using a
|
|
5
5
|
* defined comparison operation.
|
|
@@ -149,19 +149,12 @@ export interface Reasoning {
|
|
|
149
149
|
*/
|
|
150
150
|
context?: 'auto' | 'current_turn' | 'all_turns' | null;
|
|
151
151
|
/**
|
|
152
|
-
* Constrains effort on reasoning for
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
|
159
|
-
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
|
160
|
-
* calls are supported for all reasoning values in gpt-5.1.
|
|
161
|
-
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
|
162
|
-
* support `none`.
|
|
163
|
-
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
|
164
|
-
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
|
|
152
|
+
* Constrains effort on reasoning for reasoning models. Currently supported values
|
|
153
|
+
* are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing
|
|
154
|
+
* reasoning effort can result in faster responses and fewer tokens used on
|
|
155
|
+
* reasoning in a response. Not all reasoning models support every value. See the
|
|
156
|
+
* [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
|
|
157
|
+
* model-specific support.
|
|
165
158
|
*/
|
|
166
159
|
effort?: ReasoningEffort | null;
|
|
167
160
|
/**
|
|
@@ -172,6 +165,12 @@ export interface Reasoning {
|
|
|
172
165
|
* `concise`, or `detailed`.
|
|
173
166
|
*/
|
|
174
167
|
generate_summary?: 'auto' | 'concise' | 'detailed' | null;
|
|
168
|
+
/**
|
|
169
|
+
* Controls the reasoning execution mode for the request.
|
|
170
|
+
*
|
|
171
|
+
* When returned on a response, this is the effective execution mode.
|
|
172
|
+
*/
|
|
173
|
+
mode?: (string & {}) | 'standard' | 'pro';
|
|
175
174
|
/**
|
|
176
175
|
* A summary of the reasoning performed by the model. This can be useful for
|
|
177
176
|
* debugging and understanding the model's reasoning process. One of `auto`,
|
|
@@ -183,21 +182,14 @@ export interface Reasoning {
|
|
|
183
182
|
summary?: 'auto' | 'concise' | 'detailed' | null;
|
|
184
183
|
}
|
|
185
184
|
/**
|
|
186
|
-
* Constrains effort on reasoning for
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
|
193
|
-
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
|
194
|
-
* calls are supported for all reasoning values in gpt-5.1.
|
|
195
|
-
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
|
196
|
-
* support `none`.
|
|
197
|
-
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
|
198
|
-
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
|
|
185
|
+
* Constrains effort on reasoning for reasoning models. Currently supported values
|
|
186
|
+
* are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing
|
|
187
|
+
* reasoning effort can result in faster responses and fewer tokens used on
|
|
188
|
+
* reasoning in a response. Not all reasoning models support every value. See the
|
|
189
|
+
* [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
|
|
190
|
+
* model-specific support.
|
|
199
191
|
*/
|
|
200
|
-
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | null;
|
|
192
|
+
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;
|
|
201
193
|
/**
|
|
202
194
|
* JSON object response format. An older method of generating JSON responses. Using
|
|
203
195
|
* `json_schema` is recommended for models that support it. Note that the model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACjB,CAAC,MAAM,GAAG,EAAE,CAAC,GACb,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,QAAQ,GACR,mBAAmB,GACnB,kBAAkB,GAClB,6BAA6B,GAC7B,uBAAuB,GACvB,kCAAkC,GAClC,sBAAsB,GACtB,iCAAiC,GACjC,aAAa,GACb,WAAW,GACX,sBAAsB,GACtB,mBAAmB,CAAC;AAExB,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,cAAc,GACd,cAAc,GACd,yBAAyB,GACzB,yBAAyB,GACzB,qBAAqB,GACrB,SAAS,GACT,oBAAoB,GACpB,qBAAqB,GACrB,aAAa,GACb,wBAAwB,GACxB,SAAS,GACT,oBAAoB,GACpB,eAAe,GACf,cAAc,GACd,qBAAqB,GACrB,OAAO,GACP,YAAY,GACZ,YAAY,GACZ,kBAAkB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S;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,WAAW,GAAG,IAAI,CAAC;IAEvD
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACjB,CAAC,MAAM,GAAG,EAAE,CAAC,GACb,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,QAAQ,GACR,mBAAmB,GACnB,kBAAkB,GAClB,6BAA6B,GAC7B,uBAAuB,GACvB,kCAAkC,GAClC,sBAAsB,GACtB,iCAAiC,GACjC,aAAa,GACb,WAAW,GACX,sBAAsB,GACtB,mBAAmB,CAAC;AAExB,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,eAAe,GACf,cAAc,GACd,SAAS,GACT,cAAc,GACd,cAAc,GACd,yBAAyB,GACzB,yBAAyB,GACzB,qBAAqB,GACrB,SAAS,GACT,oBAAoB,GACpB,qBAAqB,GACrB,aAAa,GACb,wBAAwB,GACxB,SAAS,GACT,oBAAoB,GACpB,eAAe,GACf,cAAc,GACd,qBAAqB,GACrB,OAAO,GACP,YAAY,GACZ,YAAY,GACZ,kBAAkB,GAClB,uBAAuB,GACvB,uBAAuB,GACvB,mBAAmB,GACnB,SAAS,GACT,cAAc,GACd,cAAc,GACd,oBAAoB,GACpB,yBAAyB,GACzB,yBAAyB,GACzB,SAAS,GACT,oBAAoB,GACpB,IAAI,GACJ,eAAe,GACf,SAAS,GACT,oBAAoB,GACpB,IAAI,GACJ,eAAe,GACf,YAAY,GACZ,uBAAuB,GACvB,SAAS,GACT,oBAAoB,GACpB,QAAQ,GACR,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,iCAAiC,GACjC,iCAAiC,GACjC,iCAAiC,GACjC,2BAA2B,GAC3B,sCAAsC,GACtC,uBAAuB,GACvB,4BAA4B,GAC5B,kCAAkC,GAClC,uCAAuC,GACvC,mBAAmB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CAAC"}
|
package/src/client.ts
CHANGED
|
@@ -765,6 +765,7 @@ export class OpenAI {
|
|
|
765
765
|
const { req, url, timeout } = await this.buildRequest(options, {
|
|
766
766
|
retryCount: maxRetries - retriesRemaining,
|
|
767
767
|
});
|
|
768
|
+
const hasStreamingBody = options.__metadata?.['hasStreamingBody'] === true;
|
|
768
769
|
|
|
769
770
|
await this.prepareRequest(req, { url, options });
|
|
770
771
|
await this._provider?.prepareRequest?.(req, { url, options });
|
|
@@ -806,7 +807,7 @@ export class OpenAI {
|
|
|
806
807
|
const isTimeout =
|
|
807
808
|
isAbortError(response) ||
|
|
808
809
|
/timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
|
|
809
|
-
if (retriesRemaining) {
|
|
810
|
+
if (retriesRemaining && !hasStreamingBody) {
|
|
810
811
|
loggerFor(this).info(
|
|
811
812
|
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`,
|
|
812
813
|
);
|
|
@@ -821,11 +822,13 @@ export class OpenAI {
|
|
|
821
822
|
);
|
|
822
823
|
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
|
|
823
824
|
}
|
|
825
|
+
const terminalMessage =
|
|
826
|
+
hasStreamingBody ? 'error; streaming body cannot be retried' : 'error; no more retries left';
|
|
824
827
|
loggerFor(this).info(
|
|
825
|
-
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} -
|
|
828
|
+
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${terminalMessage}`,
|
|
826
829
|
);
|
|
827
830
|
loggerFor(this).debug(
|
|
828
|
-
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (
|
|
831
|
+
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${terminalMessage})`,
|
|
829
832
|
formatRequestDetails({
|
|
830
833
|
retryOfRequestLogID,
|
|
831
834
|
url,
|
|
@@ -878,7 +881,7 @@ export class OpenAI {
|
|
|
878
881
|
}
|
|
879
882
|
|
|
880
883
|
const shouldRetry = await this.shouldRetry(response);
|
|
881
|
-
if (retriesRemaining && shouldRetry) {
|
|
884
|
+
if (retriesRemaining && shouldRetry && !hasStreamingBody) {
|
|
882
885
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
883
886
|
|
|
884
887
|
// We don't need the body of this response.
|
|
@@ -902,7 +905,11 @@ export class OpenAI {
|
|
|
902
905
|
);
|
|
903
906
|
}
|
|
904
907
|
|
|
905
|
-
const retryMessage =
|
|
908
|
+
const retryMessage =
|
|
909
|
+
shouldRetry ?
|
|
910
|
+
hasStreamingBody ? `error; streaming body cannot be retried`
|
|
911
|
+
: `error; no more retries left`
|
|
912
|
+
: `error; not retryable`;
|
|
906
913
|
|
|
907
914
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
908
915
|
|
|
@@ -1278,6 +1285,7 @@ export class OpenAI {
|
|
|
1278
1285
|
static InvalidWebhookSignatureError = Errors.InvalidWebhookSignatureError;
|
|
1279
1286
|
|
|
1280
1287
|
static toFile = Uploads.toFile;
|
|
1288
|
+
static toStreamingFile = Uploads.toStreamingFile;
|
|
1281
1289
|
|
|
1282
1290
|
/**
|
|
1283
1291
|
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
|
package/src/core/streaming.ts
CHANGED
|
@@ -114,16 +114,44 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
114
114
|
|
|
115
115
|
async function* iterLines(): AsyncGenerator<string, void, unknown> {
|
|
116
116
|
const lineDecoder = new LineDecoder();
|
|
117
|
+
const reader = readableStream.getReader();
|
|
118
|
+
let closed = false;
|
|
119
|
+
let cancelPromise: Promise<void> | undefined;
|
|
120
|
+
const cancel = () => {
|
|
121
|
+
cancelPromise ??= reader.cancel();
|
|
122
|
+
cancelPromise.catch(() => {});
|
|
123
|
+
};
|
|
117
124
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
controller.signal.addEventListener('abort', cancel, { once: true });
|
|
126
|
+
try {
|
|
127
|
+
if (controller.signal.aborted) {
|
|
128
|
+
cancel();
|
|
129
|
+
return;
|
|
122
130
|
}
|
|
123
|
-
}
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
while (true) {
|
|
133
|
+
const { value: chunk, done } = await reader.read();
|
|
134
|
+
if (done) {
|
|
135
|
+
closed = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
if (controller.signal.aborted) return;
|
|
139
|
+
|
|
140
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
141
|
+
if (controller.signal.aborted) return;
|
|
142
|
+
yield line;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (controller.signal.aborted) return;
|
|
147
|
+
for (const line of lineDecoder.flush()) {
|
|
148
|
+
if (controller.signal.aborted) return;
|
|
149
|
+
yield line;
|
|
150
|
+
}
|
|
151
|
+
} finally {
|
|
152
|
+
controller.signal.removeEventListener('abort', cancel);
|
|
153
|
+
if (!closed) cancel();
|
|
154
|
+
reader.releaseLock();
|
|
127
155
|
}
|
|
128
156
|
}
|
|
129
157
|
|
|
@@ -141,7 +169,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
141
169
|
done = true;
|
|
142
170
|
} catch (e) {
|
|
143
171
|
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
144
|
-
if (isAbortError(e)) return;
|
|
172
|
+
if (controller.signal.aborted || isAbortError(e)) return;
|
|
145
173
|
throw e;
|
|
146
174
|
} finally {
|
|
147
175
|
// If the user `break`s, abort the ongoing request.
|
package/src/core/uploads.ts
CHANGED
package/src/helpers/audio.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
2
|
+
import { pipeline, Readable } from 'node:stream';
|
|
3
|
+
import type { ReadableStream as NodeReadableStream } from 'node:stream/web';
|
|
3
4
|
import { platform, versions } from 'node:process';
|
|
4
5
|
import { checkFileSupport } from '../internal/uploads';
|
|
5
6
|
|
|
@@ -36,14 +37,27 @@ async function nodejsPlayAudio(stream: NodeJS.ReadableStream | Response | File):
|
|
|
36
37
|
try {
|
|
37
38
|
const ffplay = spawn('ffplay', ['-autoexit', '-nodisp', '-i', 'pipe:0']);
|
|
38
39
|
|
|
40
|
+
let source: NodeJS.ReadableStream;
|
|
39
41
|
if (isResponse(stream)) {
|
|
40
|
-
|
|
42
|
+
const body = stream.body! as NodeReadableStream | NodeJS.ReadableStream;
|
|
43
|
+
if ('pipe' in body && typeof body.pipe === 'function') {
|
|
44
|
+
source = body;
|
|
45
|
+
} else {
|
|
46
|
+
source = Readable.fromWeb(body as NodeReadableStream);
|
|
47
|
+
}
|
|
41
48
|
} else if (isFile(stream)) {
|
|
42
|
-
Readable.from(stream.stream())
|
|
49
|
+
source = Readable.from(stream.stream());
|
|
43
50
|
} else {
|
|
44
|
-
stream
|
|
51
|
+
source = stream;
|
|
45
52
|
}
|
|
46
53
|
|
|
54
|
+
pipeline(source, ffplay.stdin, (error) => {
|
|
55
|
+
if (error) {
|
|
56
|
+
ffplay.kill();
|
|
57
|
+
reject(error);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
47
61
|
ffplay.on('close', (code: number) => {
|
|
48
62
|
if (code !== 0) {
|
|
49
63
|
reject(new Error(`ffplay process exited with code ${code}`));
|
package/src/helpers/zod.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResponseFormatJSONSchema } from '../resources/index';
|
|
2
2
|
import * as z3 from 'zod/v3';
|
|
3
3
|
import * as z4 from 'zod/v4';
|
|
4
|
+
import type * as z4Mini from 'zod/v4-mini';
|
|
4
5
|
import {
|
|
5
6
|
AutoParseableResponseFormat,
|
|
6
7
|
AutoParseableTextFormat,
|
|
@@ -15,9 +16,25 @@ import { type ResponseFormatTextJSONSchemaConfig } from '../resources/responses/
|
|
|
15
16
|
import { toStrictJsonSchema } from '../lib/transform';
|
|
16
17
|
import { JSONSchema } from '../lib/jsonschema';
|
|
17
18
|
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
type ZodV4Schema = z4.ZodType | z4Mini.ZodMiniType;
|
|
20
|
+
type ZodSchema = z3.ZodType | ZodV4Schema;
|
|
21
|
+
|
|
22
|
+
// The public helpers only need Zod's output type and, when available, parser. Using these small
|
|
23
|
+
// structural shapes avoids expanding Zod's full v3/v4 type graphs in Deno.
|
|
24
|
+
type ZodTypeLike = (
|
|
25
|
+
| { _output: unknown }
|
|
26
|
+
| {
|
|
27
|
+
_zod: {
|
|
28
|
+
output: unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
) & {
|
|
32
|
+
parse?: (data: unknown) => unknown;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type InferZodType<T extends ZodTypeLike> =
|
|
36
|
+
T extends { _output: infer Output } ? Output
|
|
37
|
+
: T extends { _zod: { output: infer Output } } ? Output
|
|
21
38
|
: never;
|
|
22
39
|
|
|
23
40
|
function zodV3ToJsonSchema(schema: z3.ZodType, options: { name: string }): Record<string, unknown> {
|
|
@@ -30,7 +47,7 @@ function zodV3ToJsonSchema(schema: z3.ZodType, options: { name: string }): Recor
|
|
|
30
47
|
});
|
|
31
48
|
}
|
|
32
49
|
|
|
33
|
-
function zodV4ToJsonSchema(schema:
|
|
50
|
+
function zodV4ToJsonSchema(schema: ZodV4Schema): Record<string, unknown> {
|
|
34
51
|
return toStrictJsonSchema(
|
|
35
52
|
z4.toJSONSchema(schema, {
|
|
36
53
|
target: 'draft-7',
|
|
@@ -54,10 +71,24 @@ function zodV4ToJsonSchema(schema: z4.ZodType): Record<string, unknown> {
|
|
|
54
71
|
) as Record<string, unknown>;
|
|
55
72
|
}
|
|
56
73
|
|
|
57
|
-
function isZodV4(zodObject:
|
|
74
|
+
function isZodV4(zodObject: ZodSchema): zodObject is ZodV4Schema {
|
|
58
75
|
return '_zod' in zodObject;
|
|
59
76
|
}
|
|
60
77
|
|
|
78
|
+
function parseZodObject<ZodInput extends ZodTypeLike>(
|
|
79
|
+
zodObject: ZodInput,
|
|
80
|
+
content: string,
|
|
81
|
+
): InferZodType<ZodInput> {
|
|
82
|
+
const parsed = JSON.parse(content);
|
|
83
|
+
const parser = (zodObject as { parse?: (data: unknown) => unknown }).parse;
|
|
84
|
+
|
|
85
|
+
if (typeof parser === 'function') {
|
|
86
|
+
return parser.call(zodObject, parsed) as InferZodType<ZodInput>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return z4.parse(zodObject as unknown as ZodV4Schema, parsed) as InferZodType<ZodInput>;
|
|
90
|
+
}
|
|
91
|
+
|
|
61
92
|
/**
|
|
62
93
|
* Creates a chat completion `JSONSchema` response format object from
|
|
63
94
|
* the given Zod schema.
|
|
@@ -95,39 +126,43 @@ function isZodV4(zodObject: z3.ZodType | z4.ZodType): zodObject is z4.ZodType {
|
|
|
95
126
|
* This can be passed directly to the `.create()` method but will not
|
|
96
127
|
* result in any automatic parsing, you'll have to parse the response yourself.
|
|
97
128
|
*/
|
|
98
|
-
export function zodResponseFormat<ZodInput extends
|
|
129
|
+
export function zodResponseFormat<ZodInput extends ZodTypeLike>(
|
|
99
130
|
zodObject: ZodInput,
|
|
100
131
|
name: string,
|
|
101
132
|
props?: Omit<ResponseFormatJSONSchema.JSONSchema, 'schema' | 'strict' | 'name'>,
|
|
102
133
|
): AutoParseableResponseFormat<InferZodType<ZodInput>> {
|
|
103
|
-
|
|
134
|
+
const zodSchema = zodObject as unknown as ZodSchema;
|
|
135
|
+
|
|
136
|
+
return makeParseableResponseFormat<InferZodType<ZodInput>>(
|
|
104
137
|
{
|
|
105
138
|
type: 'json_schema',
|
|
106
139
|
json_schema: {
|
|
107
140
|
...props,
|
|
108
141
|
name,
|
|
109
142
|
strict: true,
|
|
110
|
-
schema: isZodV4(
|
|
143
|
+
schema: isZodV4(zodSchema) ? zodV4ToJsonSchema(zodSchema) : zodV3ToJsonSchema(zodSchema, { name }),
|
|
111
144
|
},
|
|
112
145
|
},
|
|
113
|
-
(content) => zodObject
|
|
146
|
+
(content) => parseZodObject(zodObject, content),
|
|
114
147
|
);
|
|
115
148
|
}
|
|
116
149
|
|
|
117
|
-
export function zodTextFormat<ZodInput extends
|
|
150
|
+
export function zodTextFormat<ZodInput extends ZodTypeLike>(
|
|
118
151
|
zodObject: ZodInput,
|
|
119
152
|
name: string,
|
|
120
153
|
props?: Omit<ResponseFormatTextJSONSchemaConfig, 'schema' | 'type' | 'strict' | 'name'>,
|
|
121
154
|
): AutoParseableTextFormat<InferZodType<ZodInput>> {
|
|
122
|
-
|
|
155
|
+
const zodSchema = zodObject as unknown as ZodSchema;
|
|
156
|
+
|
|
157
|
+
return makeParseableTextFormat<InferZodType<ZodInput>>(
|
|
123
158
|
{
|
|
124
159
|
type: 'json_schema',
|
|
125
160
|
...props,
|
|
126
161
|
name,
|
|
127
162
|
strict: true,
|
|
128
|
-
schema: isZodV4(
|
|
163
|
+
schema: isZodV4(zodSchema) ? zodV4ToJsonSchema(zodSchema) : zodV3ToJsonSchema(zodSchema, { name }),
|
|
129
164
|
},
|
|
130
|
-
(content) => zodObject
|
|
165
|
+
(content) => parseZodObject(zodObject, content),
|
|
131
166
|
);
|
|
132
167
|
}
|
|
133
168
|
|
|
@@ -136,7 +171,7 @@ export function zodTextFormat<ZodInput extends z3.ZodType | z4.ZodType>(
|
|
|
136
171
|
* automatically by the chat completion `.runTools()` method or automatically
|
|
137
172
|
* parsed by `.parse()` / `.stream()`.
|
|
138
173
|
*/
|
|
139
|
-
export function zodFunction<Parameters extends
|
|
174
|
+
export function zodFunction<Parameters extends ZodTypeLike>(options: {
|
|
140
175
|
name: string;
|
|
141
176
|
parameters: Parameters;
|
|
142
177
|
function?: ((args: InferZodType<Parameters>) => unknown | Promise<unknown>) | undefined;
|
|
@@ -146,6 +181,8 @@ export function zodFunction<Parameters extends z3.ZodType | z4.ZodType>(options:
|
|
|
146
181
|
name: string;
|
|
147
182
|
function: (args: InferZodType<Parameters>) => unknown;
|
|
148
183
|
}> {
|
|
184
|
+
const zodSchema = options.parameters as unknown as ZodSchema;
|
|
185
|
+
|
|
149
186
|
// @ts-expect-error TODO
|
|
150
187
|
return makeParseableTool<any>(
|
|
151
188
|
{
|
|
@@ -153,21 +190,21 @@ export function zodFunction<Parameters extends z3.ZodType | z4.ZodType>(options:
|
|
|
153
190
|
function: {
|
|
154
191
|
name: options.name,
|
|
155
192
|
parameters:
|
|
156
|
-
isZodV4(
|
|
157
|
-
zodV4ToJsonSchema(
|
|
158
|
-
: zodV3ToJsonSchema(
|
|
193
|
+
isZodV4(zodSchema) ?
|
|
194
|
+
zodV4ToJsonSchema(zodSchema)
|
|
195
|
+
: zodV3ToJsonSchema(zodSchema, { name: options.name }),
|
|
159
196
|
strict: true,
|
|
160
197
|
...(options.description ? { description: options.description } : undefined),
|
|
161
198
|
},
|
|
162
199
|
},
|
|
163
200
|
{
|
|
164
201
|
callback: options.function,
|
|
165
|
-
parser: (args) => options.parameters
|
|
202
|
+
parser: (args) => parseZodObject(options.parameters, args),
|
|
166
203
|
},
|
|
167
204
|
);
|
|
168
205
|
}
|
|
169
206
|
|
|
170
|
-
export function zodResponsesFunction<Parameters extends
|
|
207
|
+
export function zodResponsesFunction<Parameters extends ZodTypeLike>(options: {
|
|
171
208
|
name: string;
|
|
172
209
|
parameters: Parameters;
|
|
173
210
|
function?: ((args: InferZodType<Parameters>) => unknown | Promise<unknown>) | undefined;
|
|
@@ -177,20 +214,22 @@ export function zodResponsesFunction<Parameters extends z3.ZodType | z4.ZodType>
|
|
|
177
214
|
name: string;
|
|
178
215
|
function: (args: InferZodType<Parameters>) => unknown;
|
|
179
216
|
}> {
|
|
217
|
+
const zodSchema = options.parameters as unknown as ZodSchema;
|
|
218
|
+
|
|
180
219
|
return makeParseableResponseTool<any>(
|
|
181
220
|
{
|
|
182
221
|
type: 'function',
|
|
183
222
|
name: options.name,
|
|
184
223
|
parameters:
|
|
185
|
-
isZodV4(
|
|
186
|
-
zodV4ToJsonSchema(
|
|
187
|
-
: zodV3ToJsonSchema(
|
|
224
|
+
isZodV4(zodSchema) ?
|
|
225
|
+
zodV4ToJsonSchema(zodSchema)
|
|
226
|
+
: zodV3ToJsonSchema(zodSchema, { name: options.name }),
|
|
188
227
|
strict: true,
|
|
189
228
|
...(options.description ? { description: options.description } : undefined),
|
|
190
229
|
},
|
|
191
230
|
{
|
|
192
231
|
callback: options.function,
|
|
193
|
-
parser: (args) => options.parameters
|
|
232
|
+
parser: (args) => parseZodObject(options.parameters, args),
|
|
194
233
|
},
|
|
195
234
|
);
|
|
196
235
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export { OpenAI as default } from './client';
|
|
4
4
|
|
|
5
|
-
export { type Uploadable, toFile } from './core/uploads';
|
|
5
|
+
export { type Uploadable, toFile, toStreamingFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { OpenAI, type ClientOptions } from './client';
|
|
8
8
|
export { PagePromise } from './core/pagination';
|