modelmix 2.2.8 → 2.3.8
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/README.md +19 -6
- package/demo/demo.mjs +24 -16
- package/demo/lmstudio.mjs +1 -1
- package/demo/node_modules/.package-lock.json +0 -47
- package/demo/package-lock.json +1 -50
- package/demo/package.json +1 -3
- package/demo/prompt.md +25 -0
- package/demo/stream.mjs +3 -3
- package/index.js +88 -2
- package/package.json +4 -2
- package/demo/node_modules/debug/LICENSE +0 -20
- package/demo/node_modules/debug/README.md +0 -481
- package/demo/node_modules/debug/node_modules/ms/index.js +0 -162
- package/demo/node_modules/debug/node_modules/ms/license.md +0 -21
- package/demo/node_modules/debug/node_modules/ms/package.json +0 -37
- package/demo/node_modules/debug/node_modules/ms/readme.md +0 -60
- package/demo/node_modules/debug/package.json +0 -59
- package/demo/node_modules/debug/src/browser.js +0 -269
- package/demo/node_modules/debug/src/common.js +0 -274
- package/demo/node_modules/debug/src/index.js +0 -10
- package/demo/node_modules/debug/src/node.js +0 -263
- package/demo/node_modules/lemonlog/README.md +0 -133
- package/demo/node_modules/lemonlog/demo/demo.js +0 -31
- package/demo/node_modules/lemonlog/index.js +0 -94
- package/demo/node_modules/lemonlog/package.json +0 -31
- package/demo/node_modules/openai/CHANGELOG.md +0 -1176
- package/demo/node_modules/openai/LICENSE +0 -201
- package/demo/node_modules/openai/README.md +0 -616
- package/demo/node_modules/openai/_shims/MultipartBody.d.ts +0 -9
- package/demo/node_modules/openai/_shims/MultipartBody.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/MultipartBody.js +0 -16
- package/demo/node_modules/openai/_shims/MultipartBody.js.map +0 -1
- package/demo/node_modules/openai/_shims/MultipartBody.mjs +0 -12
- package/demo/node_modules/openai/_shims/MultipartBody.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/README.md +0 -46
- package/demo/node_modules/openai/_shims/auto/runtime-bun.d.ts +0 -5
- package/demo/node_modules/openai/_shims/auto/runtime-bun.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime-bun.js +0 -21
- package/demo/node_modules/openai/_shims/auto/runtime-bun.js.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime-bun.mjs +0 -2
- package/demo/node_modules/openai/_shims/auto/runtime-bun.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime-node.d.ts +0 -5
- package/demo/node_modules/openai/_shims/auto/runtime-node.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime-node.js +0 -21
- package/demo/node_modules/openai/_shims/auto/runtime-node.js.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime-node.mjs +0 -2
- package/demo/node_modules/openai/_shims/auto/runtime-node.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime.d.ts +0 -5
- package/demo/node_modules/openai/_shims/auto/runtime.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime.js +0 -21
- package/demo/node_modules/openai/_shims/auto/runtime.js.map +0 -1
- package/demo/node_modules/openai/_shims/auto/runtime.mjs +0 -2
- package/demo/node_modules/openai/_shims/auto/runtime.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/auto/types-node.d.ts +0 -5
- package/demo/node_modules/openai/_shims/auto/types-node.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/auto/types-node.js +0 -21
- package/demo/node_modules/openai/_shims/auto/types-node.js.map +0 -1
- package/demo/node_modules/openai/_shims/auto/types-node.mjs +0 -2
- package/demo/node_modules/openai/_shims/auto/types-node.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/auto/types.d.ts +0 -101
- package/demo/node_modules/openai/_shims/auto/types.js +0 -3
- package/demo/node_modules/openai/_shims/auto/types.mjs +0 -3
- package/demo/node_modules/openai/_shims/bun-runtime.d.ts +0 -6
- package/demo/node_modules/openai/_shims/bun-runtime.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/bun-runtime.js +0 -14
- package/demo/node_modules/openai/_shims/bun-runtime.js.map +0 -1
- package/demo/node_modules/openai/_shims/bun-runtime.mjs +0 -10
- package/demo/node_modules/openai/_shims/bun-runtime.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/index.d.ts +0 -81
- package/demo/node_modules/openai/_shims/index.js +0 -13
- package/demo/node_modules/openai/_shims/index.mjs +0 -7
- package/demo/node_modules/openai/_shims/manual-types.d.ts +0 -12
- package/demo/node_modules/openai/_shims/manual-types.js +0 -3
- package/demo/node_modules/openai/_shims/manual-types.mjs +0 -3
- package/demo/node_modules/openai/_shims/node-runtime.d.ts +0 -3
- package/demo/node_modules/openai/_shims/node-runtime.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/node-runtime.js +0 -90
- package/demo/node_modules/openai/_shims/node-runtime.js.map +0 -1
- package/demo/node_modules/openai/_shims/node-runtime.mjs +0 -56
- package/demo/node_modules/openai/_shims/node-runtime.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/node-types.d.ts +0 -42
- package/demo/node_modules/openai/_shims/node-types.js +0 -3
- package/demo/node_modules/openai/_shims/node-types.mjs +0 -3
- package/demo/node_modules/openai/_shims/registry.d.ts +0 -37
- package/demo/node_modules/openai/_shims/registry.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/registry.js +0 -41
- package/demo/node_modules/openai/_shims/registry.js.map +0 -1
- package/demo/node_modules/openai/_shims/registry.mjs +0 -37
- package/demo/node_modules/openai/_shims/registry.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/web-runtime.d.ts +0 -5
- package/demo/node_modules/openai/_shims/web-runtime.d.ts.map +0 -1
- package/demo/node_modules/openai/_shims/web-runtime.js +0 -78
- package/demo/node_modules/openai/_shims/web-runtime.js.map +0 -1
- package/demo/node_modules/openai/_shims/web-runtime.mjs +0 -71
- package/demo/node_modules/openai/_shims/web-runtime.mjs.map +0 -1
- package/demo/node_modules/openai/_shims/web-types.d.ts +0 -83
- package/demo/node_modules/openai/_shims/web-types.js +0 -3
- package/demo/node_modules/openai/_shims/web-types.mjs +0 -3
- package/demo/node_modules/openai/bin/cli +0 -49
- package/demo/node_modules/openai/core.d.ts +0 -239
- package/demo/node_modules/openai/core.d.ts.map +0 -1
- package/demo/node_modules/openai/core.js +0 -879
- package/demo/node_modules/openai/core.js.map +0 -1
- package/demo/node_modules/openai/core.mjs +0 -848
- package/demo/node_modules/openai/core.mjs.map +0 -1
- package/demo/node_modules/openai/error.d.ts +0 -57
- package/demo/node_modules/openai/error.d.ts.map +0 -1
- package/demo/node_modules/openai/error.js +0 -148
- package/demo/node_modules/openai/error.js.map +0 -1
- package/demo/node_modules/openai/error.mjs +0 -132
- package/demo/node_modules/openai/error.mjs.map +0 -1
- package/demo/node_modules/openai/index.d.mts +0 -267
- package/demo/node_modules/openai/index.d.ts +0 -267
- package/demo/node_modules/openai/index.d.ts.map +0 -1
- package/demo/node_modules/openai/index.js +0 -262
- package/demo/node_modules/openai/index.js.map +0 -1
- package/demo/node_modules/openai/index.mjs +0 -232
- package/demo/node_modules/openai/index.mjs.map +0 -1
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.d.ts +0 -74
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.js +0 -246
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.js.map +0 -1
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.mjs +0 -242
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.mjs.map +0 -1
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts +0 -114
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.js +0 -519
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.js.map +0 -1
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +0 -515
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +0 -1
- package/demo/node_modules/openai/lib/AssistantStream.d.ts +0 -58
- package/demo/node_modules/openai/lib/AssistantStream.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/AssistantStream.js +0 -548
- package/demo/node_modules/openai/lib/AssistantStream.js.map +0 -1
- package/demo/node_modules/openai/lib/AssistantStream.mjs +0 -521
- package/demo/node_modules/openai/lib/AssistantStream.mjs.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.d.ts +0 -2
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.js +0 -2177
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.js.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.mjs +0 -2172
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.mjs.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionRunner.d.ts +0 -19
- package/demo/node_modules/openai/lib/ChatCompletionRunner.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionRunner.js +0 -34
- package/demo/node_modules/openai/lib/ChatCompletionRunner.js.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionRunner.mjs +0 -30
- package/demo/node_modules/openai/lib/ChatCompletionRunner.mjs.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionStream.d.ts +0 -149
- package/demo/node_modules/openai/lib/ChatCompletionStream.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionStream.js +0 -312
- package/demo/node_modules/openai/lib/ChatCompletionStream.js.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionStream.mjs +0 -308
- package/demo/node_modules/openai/lib/ChatCompletionStream.mjs.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.d.ts +0 -22
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.js +0 -32
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.js.map +0 -1
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +0 -28
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +0 -1
- package/demo/node_modules/openai/lib/RunnableFunction.d.ts +0 -95
- package/demo/node_modules/openai/lib/RunnableFunction.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/RunnableFunction.js +0 -35
- package/demo/node_modules/openai/lib/RunnableFunction.js.map +0 -1
- package/demo/node_modules/openai/lib/RunnableFunction.mjs +0 -29
- package/demo/node_modules/openai/lib/RunnableFunction.mjs.map +0 -1
- package/demo/node_modules/openai/lib/Util.d.ts +0 -5
- package/demo/node_modules/openai/lib/Util.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/Util.js +0 -26
- package/demo/node_modules/openai/lib/Util.js.map +0 -1
- package/demo/node_modules/openai/lib/Util.mjs +0 -22
- package/demo/node_modules/openai/lib/Util.mjs.map +0 -1
- package/demo/node_modules/openai/lib/chatCompletionUtils.d.ts +0 -6
- package/demo/node_modules/openai/lib/chatCompletionUtils.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/chatCompletionUtils.js +0 -20
- package/demo/node_modules/openai/lib/chatCompletionUtils.js.map +0 -1
- package/demo/node_modules/openai/lib/chatCompletionUtils.mjs +0 -13
- package/demo/node_modules/openai/lib/chatCompletionUtils.mjs.map +0 -1
- package/demo/node_modules/openai/lib/jsonschema.d.ts +0 -106
- package/demo/node_modules/openai/lib/jsonschema.d.ts.map +0 -1
- package/demo/node_modules/openai/lib/jsonschema.js +0 -11
- package/demo/node_modules/openai/lib/jsonschema.js.map +0 -1
- package/demo/node_modules/openai/lib/jsonschema.mjs +0 -10
- package/demo/node_modules/openai/lib/jsonschema.mjs.map +0 -1
- package/demo/node_modules/openai/package.json +0 -105
- package/demo/node_modules/openai/pagination.d.ts +0 -37
- package/demo/node_modules/openai/pagination.d.ts.map +0 -1
- package/demo/node_modules/openai/pagination.js +0 -64
- package/demo/node_modules/openai/pagination.js.map +0 -1
- package/demo/node_modules/openai/pagination.mjs +0 -59
- package/demo/node_modules/openai/pagination.mjs.map +0 -1
- package/demo/node_modules/openai/resource.d.ts +0 -6
- package/demo/node_modules/openai/resource.d.ts.map +0 -1
- package/demo/node_modules/openai/resource.js +0 -11
- package/demo/node_modules/openai/resource.js.map +0 -1
- package/demo/node_modules/openai/resource.mjs +0 -7
- package/demo/node_modules/openai/resource.mjs.map +0 -1
- package/demo/node_modules/openai/resources/audio/audio.d.ts +0 -20
- package/demo/node_modules/openai/resources/audio/audio.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/audio/audio.js +0 -46
- package/demo/node_modules/openai/resources/audio/audio.js.map +0 -1
- package/demo/node_modules/openai/resources/audio/audio.mjs +0 -19
- package/demo/node_modules/openai/resources/audio/audio.mjs.map +0 -1
- package/demo/node_modules/openai/resources/audio/index.d.ts +0 -5
- package/demo/node_modules/openai/resources/audio/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/audio/index.js +0 -13
- package/demo/node_modules/openai/resources/audio/index.js.map +0 -1
- package/demo/node_modules/openai/resources/audio/index.mjs +0 -6
- package/demo/node_modules/openai/resources/audio/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/audio/speech.d.ts +0 -42
- package/demo/node_modules/openai/resources/audio/speech.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/audio/speech.js +0 -17
- package/demo/node_modules/openai/resources/audio/speech.js.map +0 -1
- package/demo/node_modules/openai/resources/audio/speech.mjs +0 -13
- package/demo/node_modules/openai/resources/audio/speech.mjs.map +0 -1
- package/demo/node_modules/openai/resources/audio/transcriptions.d.ts +0 -71
- package/demo/node_modules/openai/resources/audio/transcriptions.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/audio/transcriptions.js +0 -18
- package/demo/node_modules/openai/resources/audio/transcriptions.js.map +0 -1
- package/demo/node_modules/openai/resources/audio/transcriptions.mjs +0 -14
- package/demo/node_modules/openai/resources/audio/transcriptions.mjs.map +0 -1
- package/demo/node_modules/openai/resources/audio/translations.d.ts +0 -50
- package/demo/node_modules/openai/resources/audio/translations.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/audio/translations.js +0 -18
- package/demo/node_modules/openai/resources/audio/translations.js.map +0 -1
- package/demo/node_modules/openai/resources/audio/translations.mjs +0 -14
- package/demo/node_modules/openai/resources/audio/translations.mjs.map +0 -1
- package/demo/node_modules/openai/resources/batches.d.ts +0 -189
- package/demo/node_modules/openai/resources/batches.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/batches.js +0 -65
- package/demo/node_modules/openai/resources/batches.js.map +0 -1
- package/demo/node_modules/openai/resources/batches.mjs +0 -37
- package/demo/node_modules/openai/resources/batches.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/assistants.d.ts +0 -1048
- package/demo/node_modules/openai/resources/beta/assistants.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/assistants.js +0 -89
- package/demo/node_modules/openai/resources/beta/assistants.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/assistants.mjs +0 -61
- package/demo/node_modules/openai/resources/beta/assistants.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/beta.d.ts +0 -53
- package/demo/node_modules/openai/resources/beta/beta.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/beta.js +0 -51
- package/demo/node_modules/openai/resources/beta/beta.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/beta.mjs +0 -24
- package/demo/node_modules/openai/resources/beta/beta.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/chat.d.ts +0 -9
- package/demo/node_modules/openai/resources/beta/chat/chat.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/chat.js +0 -40
- package/demo/node_modules/openai/resources/beta/chat/chat.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/chat.mjs +0 -13
- package/demo/node_modules/openai/resources/beta/chat/chat.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/completions.d.ts +0 -37
- package/demo/node_modules/openai/resources/beta/chat/completions.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/completions.js +0 -39
- package/demo/node_modules/openai/resources/beta/chat/completions.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/completions.mjs +0 -30
- package/demo/node_modules/openai/resources/beta/chat/completions.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/index.d.ts +0 -3
- package/demo/node_modules/openai/resources/beta/chat/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/index.js +0 -9
- package/demo/node_modules/openai/resources/beta/chat/index.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/chat/index.mjs +0 -4
- package/demo/node_modules/openai/resources/beta/chat/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/index.d.ts +0 -6
- package/demo/node_modules/openai/resources/beta/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/index.js +0 -17
- package/demo/node_modules/openai/resources/beta/index.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/index.mjs +0 -7
- package/demo/node_modules/openai/resources/beta/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/index.d.ts +0 -4
- package/demo/node_modules/openai/resources/beta/threads/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/index.js +0 -13
- package/demo/node_modules/openai/resources/beta/threads/index.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/index.mjs +0 -5
- package/demo/node_modules/openai/resources/beta/threads/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/messages.d.ts +0 -552
- package/demo/node_modules/openai/resources/beta/threads/messages.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/messages.js +0 -89
- package/demo/node_modules/openai/resources/beta/threads/messages.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/messages.mjs +0 -61
- package/demo/node_modules/openai/resources/beta/threads/messages.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/index.d.ts +0 -3
- package/demo/node_modules/openai/resources/beta/threads/runs/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/index.js +0 -11
- package/demo/node_modules/openai/resources/beta/threads/runs/index.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/index.mjs +0 -4
- package/demo/node_modules/openai/resources/beta/threads/runs/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.d.ts +0 -1194
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.js +0 -190
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.mjs +0 -162
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.d.ts +0 -520
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.js +0 -60
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.mjs +0 -32
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/threads.d.ts +0 -1240
- package/demo/node_modules/openai/resources/beta/threads/threads.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/threads.js +0 -108
- package/demo/node_modules/openai/resources/beta/threads/threads.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/threads/threads.mjs +0 -81
- package/demo/node_modules/openai/resources/beta/threads/threads.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.d.ts +0 -142
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.js +0 -129
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.mjs +0 -125
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/files.d.ts +0 -154
- package/demo/node_modules/openai/resources/beta/vector-stores/files.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/files.js +0 -149
- package/demo/node_modules/openai/resources/beta/vector-stores/files.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/files.mjs +0 -121
- package/demo/node_modules/openai/resources/beta/vector-stores/files.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/index.d.ts +0 -4
- package/demo/node_modules/openai/resources/beta/vector-stores/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/index.js +0 -13
- package/demo/node_modules/openai/resources/beta/vector-stores/index.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/index.mjs +0 -5
- package/demo/node_modules/openai/resources/beta/vector-stores/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.d.ts +0 -233
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.js +0 -99
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.js.map +0 -1
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.mjs +0 -71
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.mjs.map +0 -1
- package/demo/node_modules/openai/resources/chat/chat.d.ts +0 -42
- package/demo/node_modules/openai/resources/chat/chat.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/chat/chat.js +0 -40
- package/demo/node_modules/openai/resources/chat/chat.js.map +0 -1
- package/demo/node_modules/openai/resources/chat/chat.mjs +0 -13
- package/demo/node_modules/openai/resources/chat/chat.mjs.map +0 -1
- package/demo/node_modules/openai/resources/chat/completions.d.ts +0 -845
- package/demo/node_modules/openai/resources/chat/completions.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/chat/completions.js +0 -14
- package/demo/node_modules/openai/resources/chat/completions.js.map +0 -1
- package/demo/node_modules/openai/resources/chat/completions.mjs +0 -10
- package/demo/node_modules/openai/resources/chat/completions.mjs.map +0 -1
- package/demo/node_modules/openai/resources/chat/index.d.ts +0 -3
- package/demo/node_modules/openai/resources/chat/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/chat/index.js +0 -9
- package/demo/node_modules/openai/resources/chat/index.js.map +0 -1
- package/demo/node_modules/openai/resources/chat/index.mjs +0 -4
- package/demo/node_modules/openai/resources/chat/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/completions.d.ts +0 -272
- package/demo/node_modules/openai/resources/completions.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/completions.js +0 -14
- package/demo/node_modules/openai/resources/completions.js.map +0 -1
- package/demo/node_modules/openai/resources/completions.mjs +0 -10
- package/demo/node_modules/openai/resources/completions.mjs.map +0 -1
- package/demo/node_modules/openai/resources/embeddings.d.ts +0 -103
- package/demo/node_modules/openai/resources/embeddings.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/embeddings.js +0 -17
- package/demo/node_modules/openai/resources/embeddings.js.map +0 -1
- package/demo/node_modules/openai/resources/embeddings.mjs +0 -13
- package/demo/node_modules/openai/resources/embeddings.mjs.map +0 -1
- package/demo/node_modules/openai/resources/files.d.ts +0 -140
- package/demo/node_modules/openai/resources/files.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/files.js +0 -120
- package/demo/node_modules/openai/resources/files.js.map +0 -1
- package/demo/node_modules/openai/resources/files.mjs +0 -92
- package/demo/node_modules/openai/resources/files.mjs.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.d.ts +0 -19
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.js +0 -42
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.js.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +0 -15
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/index.d.ts +0 -3
- package/demo/node_modules/openai/resources/fine-tuning/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/index.js +0 -11
- package/demo/node_modules/openai/resources/fine-tuning/index.js.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/index.mjs +0 -4
- package/demo/node_modules/openai/resources/fine-tuning/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.d.ts +0 -69
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js +0 -47
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +0 -19
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.d.ts +0 -3
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.js +0 -12
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.js.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.mjs +0 -4
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.d.ts +0 -362
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.js +0 -93
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.js.map +0 -1
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +0 -64
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +0 -1
- package/demo/node_modules/openai/resources/images.d.ts +0 -174
- package/demo/node_modules/openai/resources/images.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/images.js +0 -30
- package/demo/node_modules/openai/resources/images.js.map +0 -1
- package/demo/node_modules/openai/resources/images.mjs +0 -26
- package/demo/node_modules/openai/resources/images.mjs.map +0 -1
- package/demo/node_modules/openai/resources/index.d.ts +0 -13
- package/demo/node_modules/openai/resources/index.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/index.js +0 -44
- package/demo/node_modules/openai/resources/index.js.map +0 -1
- package/demo/node_modules/openai/resources/index.mjs +0 -14
- package/demo/node_modules/openai/resources/index.mjs.map +0 -1
- package/demo/node_modules/openai/resources/models.d.ts +0 -58
- package/demo/node_modules/openai/resources/models.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/models.js +0 -64
- package/demo/node_modules/openai/resources/models.js.map +0 -1
- package/demo/node_modules/openai/resources/models.mjs +0 -36
- package/demo/node_modules/openai/resources/models.mjs.map +0 -1
- package/demo/node_modules/openai/resources/moderations.d.ts +0 -176
- package/demo/node_modules/openai/resources/moderations.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/moderations.js +0 -17
- package/demo/node_modules/openai/resources/moderations.js.map +0 -1
- package/demo/node_modules/openai/resources/moderations.mjs +0 -13
- package/demo/node_modules/openai/resources/moderations.mjs.map +0 -1
- package/demo/node_modules/openai/resources/shared.d.ts +0 -39
- package/demo/node_modules/openai/resources/shared.d.ts.map +0 -1
- package/demo/node_modules/openai/resources/shared.js +0 -4
- package/demo/node_modules/openai/resources/shared.js.map +0 -1
- package/demo/node_modules/openai/resources/shared.mjs +0 -3
- package/demo/node_modules/openai/resources/shared.mjs.map +0 -1
- package/demo/node_modules/openai/shims/node.d.ts +0 -29
- package/demo/node_modules/openai/shims/node.d.ts.map +0 -1
- package/demo/node_modules/openai/shims/node.js +0 -31
- package/demo/node_modules/openai/shims/node.js.map +0 -1
- package/demo/node_modules/openai/shims/node.mjs +0 -5
- package/demo/node_modules/openai/shims/node.mjs.map +0 -1
- package/demo/node_modules/openai/shims/web.d.ts +0 -26
- package/demo/node_modules/openai/shims/web.d.ts.map +0 -1
- package/demo/node_modules/openai/shims/web.js +0 -31
- package/demo/node_modules/openai/shims/web.js.map +0 -1
- package/demo/node_modules/openai/shims/web.mjs +0 -5
- package/demo/node_modules/openai/shims/web.mjs.map +0 -1
- package/demo/node_modules/openai/src/_shims/MultipartBody.ts +0 -9
- package/demo/node_modules/openai/src/_shims/README.md +0 -46
- package/demo/node_modules/openai/src/_shims/auto/runtime-bun.ts +0 -4
- package/demo/node_modules/openai/src/_shims/auto/runtime-node.ts +0 -4
- package/demo/node_modules/openai/src/_shims/auto/runtime.ts +0 -4
- package/demo/node_modules/openai/src/_shims/auto/types-node.ts +0 -4
- package/demo/node_modules/openai/src/_shims/auto/types.d.ts +0 -101
- package/demo/node_modules/openai/src/_shims/auto/types.js +0 -3
- package/demo/node_modules/openai/src/_shims/auto/types.mjs +0 -3
- package/demo/node_modules/openai/src/_shims/bun-runtime.ts +0 -14
- package/demo/node_modules/openai/src/_shims/index.d.ts +0 -81
- package/demo/node_modules/openai/src/_shims/index.js +0 -13
- package/demo/node_modules/openai/src/_shims/index.mjs +0 -7
- package/demo/node_modules/openai/src/_shims/manual-types.d.ts +0 -12
- package/demo/node_modules/openai/src/_shims/manual-types.js +0 -3
- package/demo/node_modules/openai/src/_shims/manual-types.mjs +0 -3
- package/demo/node_modules/openai/src/_shims/node-runtime.ts +0 -83
- package/demo/node_modules/openai/src/_shims/node-types.d.ts +0 -42
- package/demo/node_modules/openai/src/_shims/node-types.js +0 -3
- package/demo/node_modules/openai/src/_shims/node-types.mjs +0 -3
- package/demo/node_modules/openai/src/_shims/registry.ts +0 -65
- package/demo/node_modules/openai/src/_shims/web-runtime.ts +0 -103
- package/demo/node_modules/openai/src/_shims/web-types.d.ts +0 -83
- package/demo/node_modules/openai/src/_shims/web-types.js +0 -3
- package/demo/node_modules/openai/src/_shims/web-types.mjs +0 -3
- package/demo/node_modules/openai/src/core.ts +0 -1162
- package/demo/node_modules/openai/src/error.ts +0 -158
- package/demo/node_modules/openai/src/index.ts +0 -502
- package/demo/node_modules/openai/src/lib/.keep +0 -4
- package/demo/node_modules/openai/src/lib/AbstractAssistantStreamRunner.ts +0 -340
- package/demo/node_modules/openai/src/lib/AbstractChatCompletionRunner.ts +0 -682
- package/demo/node_modules/openai/src/lib/AssistantStream.ts +0 -723
- package/demo/node_modules/openai/src/lib/ChatCompletionRunFunctions.test.ts +0 -2328
- package/demo/node_modules/openai/src/lib/ChatCompletionRunner.ts +0 -68
- package/demo/node_modules/openai/src/lib/ChatCompletionStream.ts +0 -494
- package/demo/node_modules/openai/src/lib/ChatCompletionStreamingRunner.ts +0 -68
- package/demo/node_modules/openai/src/lib/RunnableFunction.ts +0 -134
- package/demo/node_modules/openai/src/lib/Util.ts +0 -23
- package/demo/node_modules/openai/src/lib/chatCompletionUtils.ts +0 -28
- package/demo/node_modules/openai/src/lib/jsonschema.ts +0 -148
- package/demo/node_modules/openai/src/pagination.ts +0 -98
- package/demo/node_modules/openai/src/resource.ts +0 -11
- package/demo/node_modules/openai/src/resources/audio/audio.ts +0 -23
- package/demo/node_modules/openai/src/resources/audio/index.ts +0 -6
- package/demo/node_modules/openai/src/resources/audio/speech.ts +0 -52
- package/demo/node_modules/openai/src/resources/audio/transcriptions.ts +0 -84
- package/demo/node_modules/openai/src/resources/audio/translations.ts +0 -61
- package/demo/node_modules/openai/src/resources/batches.ts +0 -252
- package/demo/node_modules/openai/src/resources/beta/assistants.ts +0 -1315
- package/demo/node_modules/openai/src/resources/beta/beta.ts +0 -56
- package/demo/node_modules/openai/src/resources/beta/chat/chat.ts +0 -12
- package/demo/node_modules/openai/src/resources/beta/chat/completions.ts +0 -106
- package/demo/node_modules/openai/src/resources/beta/chat/index.ts +0 -4
- package/demo/node_modules/openai/src/resources/beta/index.ts +0 -48
- package/demo/node_modules/openai/src/resources/beta/threads/index.ts +0 -72
- package/demo/node_modules/openai/src/resources/beta/threads/messages.ts +0 -706
- package/demo/node_modules/openai/src/resources/beta/threads/runs/index.ts +0 -44
- package/demo/node_modules/openai/src/resources/beta/threads/runs/runs.ts +0 -1627
- package/demo/node_modules/openai/src/resources/beta/threads/runs/steps.ts +0 -641
- package/demo/node_modules/openai/src/resources/beta/threads/threads.ts +0 -1536
- package/demo/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts +0 -293
- package/demo/node_modules/openai/src/resources/beta/vector-stores/files.ts +0 -284
- package/demo/node_modules/openai/src/resources/beta/vector-stores/index.ts +0 -25
- package/demo/node_modules/openai/src/resources/beta/vector-stores/vector-stores.ts +0 -318
- package/demo/node_modules/openai/src/resources/chat/chat.ts +0 -67
- package/demo/node_modules/openai/src/resources/chat/completions.ts +0 -996
- package/demo/node_modules/openai/src/resources/chat/index.ts +0 -33
- package/demo/node_modules/openai/src/resources/completions.ts +0 -329
- package/demo/node_modules/openai/src/resources/embeddings.ts +0 -125
- package/demo/node_modules/openai/src/resources/files.ts +0 -214
- package/demo/node_modules/openai/src/resources/fine-tuning/fine-tuning.ts +0 -22
- package/demo/node_modules/openai/src/resources/fine-tuning/index.ts +0 -16
- package/demo/node_modules/openai/src/resources/fine-tuning/jobs/checkpoints.ts +0 -108
- package/demo/node_modules/openai/src/resources/fine-tuning/jobs/index.ts +0 -21
- package/demo/node_modules/openai/src/resources/fine-tuning/jobs/jobs.ts +0 -458
- package/demo/node_modules/openai/src/resources/images.ts +0 -215
- package/demo/node_modules/openai/src/resources/index.ts +0 -45
- package/demo/node_modules/openai/src/resources/models.ts +0 -76
- package/demo/node_modules/openai/src/resources/moderations.ts +0 -214
- package/demo/node_modules/openai/src/resources/shared.ts +0 -47
- package/demo/node_modules/openai/src/shims/node.ts +0 -50
- package/demo/node_modules/openai/src/shims/web.ts +0 -50
- package/demo/node_modules/openai/src/streaming.ts +0 -508
- package/demo/node_modules/openai/src/tsconfig.json +0 -11
- package/demo/node_modules/openai/src/uploads.ts +0 -248
- package/demo/node_modules/openai/src/version.ts +0 -1
- package/demo/node_modules/openai/streaming.d.ts +0 -41
- package/demo/node_modules/openai/streaming.d.ts.map +0 -1
- package/demo/node_modules/openai/streaming.js +0 -433
- package/demo/node_modules/openai/streaming.js.map +0 -1
- package/demo/node_modules/openai/streaming.mjs +0 -426
- package/demo/node_modules/openai/streaming.mjs.map +0 -1
- package/demo/node_modules/openai/uploads.d.ts +0 -75
- package/demo/node_modules/openai/uploads.d.ts.map +0 -1
- package/demo/node_modules/openai/uploads.js +0 -165
- package/demo/node_modules/openai/uploads.js.map +0 -1
- package/demo/node_modules/openai/uploads.mjs +0 -152
- package/demo/node_modules/openai/uploads.mjs.map +0 -1
- package/demo/node_modules/openai/version.d.ts +0 -2
- package/demo/node_modules/openai/version.d.ts.map +0 -1
- package/demo/node_modules/openai/version.js +0 -5
- package/demo/node_modules/openai/version.js.map +0 -1
- package/demo/node_modules/openai/version.mjs +0 -2
- package/demo/node_modules/openai/version.mjs.map +0 -1
- package/demo/watson.png +0 -0
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = exports.isMultipartBody = exports.toFile = exports.isUploadable = exports.isBlobLike = exports.isFileLike = exports.isResponseLike = exports.fileFromPath = void 0;
|
|
4
|
-
const index_1 = require("./_shims/index.js");
|
|
5
|
-
var index_2 = require("./_shims/index.js");
|
|
6
|
-
Object.defineProperty(exports, "fileFromPath", { enumerable: true, get: function () { return index_2.fileFromPath; } });
|
|
7
|
-
const isResponseLike = (value) => value != null &&
|
|
8
|
-
typeof value === 'object' &&
|
|
9
|
-
typeof value.url === 'string' &&
|
|
10
|
-
typeof value.blob === 'function';
|
|
11
|
-
exports.isResponseLike = isResponseLike;
|
|
12
|
-
const isFileLike = (value) => value != null &&
|
|
13
|
-
typeof value === 'object' &&
|
|
14
|
-
typeof value.name === 'string' &&
|
|
15
|
-
typeof value.lastModified === 'number' &&
|
|
16
|
-
(0, exports.isBlobLike)(value);
|
|
17
|
-
exports.isFileLike = isFileLike;
|
|
18
|
-
/**
|
|
19
|
-
* The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
|
|
20
|
-
* adds the arrayBuffer() method type because it is available and used at runtime
|
|
21
|
-
*/
|
|
22
|
-
const isBlobLike = (value) => value != null &&
|
|
23
|
-
typeof value === 'object' &&
|
|
24
|
-
typeof value.size === 'number' &&
|
|
25
|
-
typeof value.type === 'string' &&
|
|
26
|
-
typeof value.text === 'function' &&
|
|
27
|
-
typeof value.slice === 'function' &&
|
|
28
|
-
typeof value.arrayBuffer === 'function';
|
|
29
|
-
exports.isBlobLike = isBlobLike;
|
|
30
|
-
const isUploadable = (value) => {
|
|
31
|
-
return (0, exports.isFileLike)(value) || (0, exports.isResponseLike)(value) || (0, index_1.isFsReadStream)(value);
|
|
32
|
-
};
|
|
33
|
-
exports.isUploadable = isUploadable;
|
|
34
|
-
/**
|
|
35
|
-
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
36
|
-
* @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
|
|
37
|
-
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
38
|
-
* @param {Object=} options additional properties
|
|
39
|
-
* @param {string=} options.type the MIME type of the content
|
|
40
|
-
* @param {number=} options.lastModified the last modified timestamp
|
|
41
|
-
* @returns a {@link File} with the given properties
|
|
42
|
-
*/
|
|
43
|
-
async function toFile(value, name, options) {
|
|
44
|
-
// If it's a promise, resolve it.
|
|
45
|
-
value = await value;
|
|
46
|
-
// Use the file's options if there isn't one provided
|
|
47
|
-
options ?? (options = (0, exports.isFileLike)(value) ? { lastModified: value.lastModified, type: value.type } : {});
|
|
48
|
-
if ((0, exports.isResponseLike)(value)) {
|
|
49
|
-
const blob = await value.blob();
|
|
50
|
-
name || (name = new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file');
|
|
51
|
-
return new index_1.File([blob], name, options);
|
|
52
|
-
}
|
|
53
|
-
const bits = await getBytes(value);
|
|
54
|
-
name || (name = getName(value) ?? 'unknown_file');
|
|
55
|
-
if (!options.type) {
|
|
56
|
-
const type = bits[0]?.type;
|
|
57
|
-
if (typeof type === 'string') {
|
|
58
|
-
options = { ...options, type };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return new index_1.File(bits, name, options);
|
|
62
|
-
}
|
|
63
|
-
exports.toFile = toFile;
|
|
64
|
-
async function getBytes(value) {
|
|
65
|
-
let parts = [];
|
|
66
|
-
if (typeof value === 'string' ||
|
|
67
|
-
ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
68
|
-
value instanceof ArrayBuffer) {
|
|
69
|
-
parts.push(value);
|
|
70
|
-
}
|
|
71
|
-
else if ((0, exports.isBlobLike)(value)) {
|
|
72
|
-
parts.push(await value.arrayBuffer());
|
|
73
|
-
}
|
|
74
|
-
else if (isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
|
|
75
|
-
) {
|
|
76
|
-
for await (const chunk of value) {
|
|
77
|
-
parts.push(chunk); // TODO, consider validating?
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor
|
|
82
|
-
?.name}; props: ${propsForError(value)}`);
|
|
83
|
-
}
|
|
84
|
-
return parts;
|
|
85
|
-
}
|
|
86
|
-
function propsForError(value) {
|
|
87
|
-
const props = Object.getOwnPropertyNames(value);
|
|
88
|
-
return `[${props.map((p) => `"${p}"`).join(', ')}]`;
|
|
89
|
-
}
|
|
90
|
-
function getName(value) {
|
|
91
|
-
return (getStringFromMaybeBuffer(value.name) ||
|
|
92
|
-
getStringFromMaybeBuffer(value.filename) ||
|
|
93
|
-
// For fs.ReadStream
|
|
94
|
-
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop());
|
|
95
|
-
}
|
|
96
|
-
const getStringFromMaybeBuffer = (x) => {
|
|
97
|
-
if (typeof x === 'string')
|
|
98
|
-
return x;
|
|
99
|
-
if (typeof Buffer !== 'undefined' && x instanceof Buffer)
|
|
100
|
-
return String(x);
|
|
101
|
-
return undefined;
|
|
102
|
-
};
|
|
103
|
-
const isAsyncIterableIterator = (value) => value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
|
|
104
|
-
const isMultipartBody = (body) => body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody';
|
|
105
|
-
exports.isMultipartBody = isMultipartBody;
|
|
106
|
-
/**
|
|
107
|
-
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
108
|
-
* Otherwise returns the request as is.
|
|
109
|
-
*/
|
|
110
|
-
const maybeMultipartFormRequestOptions = async (opts) => {
|
|
111
|
-
if (!hasUploadableValue(opts.body))
|
|
112
|
-
return opts;
|
|
113
|
-
const form = await (0, exports.createForm)(opts.body);
|
|
114
|
-
return (0, index_1.getMultipartRequestOptions)(form, opts);
|
|
115
|
-
};
|
|
116
|
-
exports.maybeMultipartFormRequestOptions = maybeMultipartFormRequestOptions;
|
|
117
|
-
const multipartFormRequestOptions = async (opts) => {
|
|
118
|
-
const form = await (0, exports.createForm)(opts.body);
|
|
119
|
-
return (0, index_1.getMultipartRequestOptions)(form, opts);
|
|
120
|
-
};
|
|
121
|
-
exports.multipartFormRequestOptions = multipartFormRequestOptions;
|
|
122
|
-
const createForm = async (body) => {
|
|
123
|
-
const form = new index_1.FormData();
|
|
124
|
-
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
125
|
-
return form;
|
|
126
|
-
};
|
|
127
|
-
exports.createForm = createForm;
|
|
128
|
-
const hasUploadableValue = (value) => {
|
|
129
|
-
if ((0, exports.isUploadable)(value))
|
|
130
|
-
return true;
|
|
131
|
-
if (Array.isArray(value))
|
|
132
|
-
return value.some(hasUploadableValue);
|
|
133
|
-
if (value && typeof value === 'object') {
|
|
134
|
-
for (const k in value) {
|
|
135
|
-
if (hasUploadableValue(value[k]))
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
};
|
|
141
|
-
const addFormValue = async (form, key, value) => {
|
|
142
|
-
if (value === undefined)
|
|
143
|
-
return;
|
|
144
|
-
if (value == null) {
|
|
145
|
-
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
146
|
-
}
|
|
147
|
-
// TODO: make nested formats configurable
|
|
148
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
149
|
-
form.append(key, String(value));
|
|
150
|
-
}
|
|
151
|
-
else if ((0, exports.isUploadable)(value)) {
|
|
152
|
-
const file = await toFile(value);
|
|
153
|
-
form.append(key, file);
|
|
154
|
-
}
|
|
155
|
-
else if (Array.isArray(value)) {
|
|
156
|
-
await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
|
|
157
|
-
}
|
|
158
|
-
else if (typeof value === 'object') {
|
|
159
|
-
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
//# sourceMappingURL=uploads.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":";;;AACA,6CAQwB;AAExB,2CAA8C;AAArC,qGAAA,YAAY,OAAA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AAC,CAAC;KAChC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KAChF;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,CACzF,CAAC;KACH;SAAM;QACL,MAAM,IAAI,SAAS,CACjB,wGAAwG,KAAK,UAAU,CACxH,CAAC;KACH;AACH,CAAC,CAAC"}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { FormData, File, getMultipartRequestOptions, isFsReadStream, } from "./_shims/index.mjs";
|
|
2
|
-
export { fileFromPath } from "./_shims/index.mjs";
|
|
3
|
-
export const isResponseLike = (value) => value != null &&
|
|
4
|
-
typeof value === 'object' &&
|
|
5
|
-
typeof value.url === 'string' &&
|
|
6
|
-
typeof value.blob === 'function';
|
|
7
|
-
export const isFileLike = (value) => value != null &&
|
|
8
|
-
typeof value === 'object' &&
|
|
9
|
-
typeof value.name === 'string' &&
|
|
10
|
-
typeof value.lastModified === 'number' &&
|
|
11
|
-
isBlobLike(value);
|
|
12
|
-
/**
|
|
13
|
-
* The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
|
|
14
|
-
* adds the arrayBuffer() method type because it is available and used at runtime
|
|
15
|
-
*/
|
|
16
|
-
export const isBlobLike = (value) => value != null &&
|
|
17
|
-
typeof value === 'object' &&
|
|
18
|
-
typeof value.size === 'number' &&
|
|
19
|
-
typeof value.type === 'string' &&
|
|
20
|
-
typeof value.text === 'function' &&
|
|
21
|
-
typeof value.slice === 'function' &&
|
|
22
|
-
typeof value.arrayBuffer === 'function';
|
|
23
|
-
export const isUploadable = (value) => {
|
|
24
|
-
return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
28
|
-
* @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
|
|
29
|
-
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
30
|
-
* @param {Object=} options additional properties
|
|
31
|
-
* @param {string=} options.type the MIME type of the content
|
|
32
|
-
* @param {number=} options.lastModified the last modified timestamp
|
|
33
|
-
* @returns a {@link File} with the given properties
|
|
34
|
-
*/
|
|
35
|
-
export async function toFile(value, name, options) {
|
|
36
|
-
// If it's a promise, resolve it.
|
|
37
|
-
value = await value;
|
|
38
|
-
// Use the file's options if there isn't one provided
|
|
39
|
-
options ?? (options = isFileLike(value) ? { lastModified: value.lastModified, type: value.type } : {});
|
|
40
|
-
if (isResponseLike(value)) {
|
|
41
|
-
const blob = await value.blob();
|
|
42
|
-
name || (name = new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file');
|
|
43
|
-
return new File([blob], name, options);
|
|
44
|
-
}
|
|
45
|
-
const bits = await getBytes(value);
|
|
46
|
-
name || (name = getName(value) ?? 'unknown_file');
|
|
47
|
-
if (!options.type) {
|
|
48
|
-
const type = bits[0]?.type;
|
|
49
|
-
if (typeof type === 'string') {
|
|
50
|
-
options = { ...options, type };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return new File(bits, name, options);
|
|
54
|
-
}
|
|
55
|
-
async function getBytes(value) {
|
|
56
|
-
let parts = [];
|
|
57
|
-
if (typeof value === 'string' ||
|
|
58
|
-
ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
59
|
-
value instanceof ArrayBuffer) {
|
|
60
|
-
parts.push(value);
|
|
61
|
-
}
|
|
62
|
-
else if (isBlobLike(value)) {
|
|
63
|
-
parts.push(await value.arrayBuffer());
|
|
64
|
-
}
|
|
65
|
-
else if (isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
|
|
66
|
-
) {
|
|
67
|
-
for await (const chunk of value) {
|
|
68
|
-
parts.push(chunk); // TODO, consider validating?
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor
|
|
73
|
-
?.name}; props: ${propsForError(value)}`);
|
|
74
|
-
}
|
|
75
|
-
return parts;
|
|
76
|
-
}
|
|
77
|
-
function propsForError(value) {
|
|
78
|
-
const props = Object.getOwnPropertyNames(value);
|
|
79
|
-
return `[${props.map((p) => `"${p}"`).join(', ')}]`;
|
|
80
|
-
}
|
|
81
|
-
function getName(value) {
|
|
82
|
-
return (getStringFromMaybeBuffer(value.name) ||
|
|
83
|
-
getStringFromMaybeBuffer(value.filename) ||
|
|
84
|
-
// For fs.ReadStream
|
|
85
|
-
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop());
|
|
86
|
-
}
|
|
87
|
-
const getStringFromMaybeBuffer = (x) => {
|
|
88
|
-
if (typeof x === 'string')
|
|
89
|
-
return x;
|
|
90
|
-
if (typeof Buffer !== 'undefined' && x instanceof Buffer)
|
|
91
|
-
return String(x);
|
|
92
|
-
return undefined;
|
|
93
|
-
};
|
|
94
|
-
const isAsyncIterableIterator = (value) => value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
|
|
95
|
-
export const isMultipartBody = (body) => body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody';
|
|
96
|
-
/**
|
|
97
|
-
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
98
|
-
* Otherwise returns the request as is.
|
|
99
|
-
*/
|
|
100
|
-
export const maybeMultipartFormRequestOptions = async (opts) => {
|
|
101
|
-
if (!hasUploadableValue(opts.body))
|
|
102
|
-
return opts;
|
|
103
|
-
const form = await createForm(opts.body);
|
|
104
|
-
return getMultipartRequestOptions(form, opts);
|
|
105
|
-
};
|
|
106
|
-
export const multipartFormRequestOptions = async (opts) => {
|
|
107
|
-
const form = await createForm(opts.body);
|
|
108
|
-
return getMultipartRequestOptions(form, opts);
|
|
109
|
-
};
|
|
110
|
-
export const createForm = async (body) => {
|
|
111
|
-
const form = new FormData();
|
|
112
|
-
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
113
|
-
return form;
|
|
114
|
-
};
|
|
115
|
-
const hasUploadableValue = (value) => {
|
|
116
|
-
if (isUploadable(value))
|
|
117
|
-
return true;
|
|
118
|
-
if (Array.isArray(value))
|
|
119
|
-
return value.some(hasUploadableValue);
|
|
120
|
-
if (value && typeof value === 'object') {
|
|
121
|
-
for (const k in value) {
|
|
122
|
-
if (hasUploadableValue(value[k]))
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
};
|
|
128
|
-
const addFormValue = async (form, key, value) => {
|
|
129
|
-
if (value === undefined)
|
|
130
|
-
return;
|
|
131
|
-
if (value == null) {
|
|
132
|
-
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
133
|
-
}
|
|
134
|
-
// TODO: make nested formats configurable
|
|
135
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
136
|
-
form.append(key, String(value));
|
|
137
|
-
}
|
|
138
|
-
else if (isUploadable(value)) {
|
|
139
|
-
const file = await toFile(value);
|
|
140
|
-
form.append(key, file);
|
|
141
|
-
}
|
|
142
|
-
else if (Array.isArray(value)) {
|
|
143
|
-
await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
|
|
144
|
-
}
|
|
145
|
-
else if (typeof value === 'object') {
|
|
146
|
-
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
//# sourceMappingURL=uploads.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.mjs","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":"OACO,EACL,QAAQ,EACR,IAAI,EAGJ,0BAA0B,EAE1B,cAAc,GACf;OAEM,EAAE,YAAY,EAAE;AAiDvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAU,EAAyB,EAAE,CAClE,KAAK,IAAI,IAAI;IACb,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;IAC7B,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;AAEnC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,EAAqB,EAAE,CAC1D,KAAK,IAAI,IAAI;IACb,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ;IACtC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,EAA+D,EAAE,CACpG,KAAK,IAAI,IAAI;IACb,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU;IAChC,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;IACjC,OAAO,KAA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SAAS,EAAE;QACxF,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACjC;SAAM,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;QAC9B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,IAAY,CAAC,CAAC;KAChC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KAChF;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,CACzF,CAAC;KACH;SAAM;QACL,MAAM,IAAI,SAAS,CACjB,wGAAwG,KAAK,UAAU,CACxH,CAAC;KACH;AACH,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC,CAAC,2BAA2B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,2BAA2B"}
|
package/demo/watson.png
DELETED
|
Binary file
|