ogx-client 0.7.2-rc1
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 +512 -0
- package/LICENSE +7 -0
- package/README.md +391 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +21 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +17 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +26 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +7 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +26 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +7 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +26 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +7 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +26 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +7 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +107 -0
- package/_shims/auto/types.js +9 -0
- package/_shims/auto/types.mjs +10 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +19 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +15 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +89 -0
- package/_shims/index.js +23 -0
- package/_shims/index.mjs +18 -0
- package/_shims/manual-types.d.ts +18 -0
- package/_shims/manual-types.js +9 -0
- package/_shims/manual-types.mjs +10 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +94 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +61 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +48 -0
- package/_shims/node-types.js +9 -0
- package/_shims/node-types.mjs +10 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +46 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +42 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +83 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +76 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +89 -0
- package/_shims/web-types.js +9 -0
- package/_shims/web-types.mjs +10 -0
- package/core.d.ts +257 -0
- package/core.d.ts.map +1 -0
- package/core.js +936 -0
- package/core.js.map +1 -0
- package/core.mjs +904 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +47 -0
- package/error.d.ts.map +1 -0
- package/error.js +119 -0
- package/error.js.map +1 -0
- package/error.mjs +101 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +233 -0
- package/index.d.ts +233 -0
- package/index.d.ts.map +1 -0
- package/index.js +254 -0
- package/index.js.map +1 -0
- package/index.mjs +210 -0
- package/index.mjs.map +1 -0
- package/internal/decoders/line.d.ts +21 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +155 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +150 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/qs/formats.d.ts +6 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +16 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +13 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +19 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +15 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +285 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +281 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +8 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +7 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.ts +14 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +234 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +222 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/stream-utils.d.ts +8 -0
- package/internal/stream-utils.d.ts.map +1 -0
- package/internal/stream-utils.js +44 -0
- package/internal/stream-utils.js.map +1 -0
- package/internal/stream-utils.mjs +40 -0
- package/internal/stream-utils.mjs.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +39 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +12 -0
- package/internal/utils/query.mjs.map +1 -0
- package/lib/response-helpers.d.ts +23 -0
- package/lib/response-helpers.d.ts.map +1 -0
- package/lib/response-helpers.js +53 -0
- package/lib/response-helpers.js.map +1 -0
- package/lib/response-helpers.mjs +49 -0
- package/lib/response-helpers.mjs.map +1 -0
- package/ogx-client-0.7.2-rc1.tgz +0 -0
- package/package.json +108 -0
- package/pagination.d.ts +21 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +53 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +47 -0
- package/pagination.mjs.map +1 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +15 -0
- package/resource.js.map +1 -0
- package/resource.mjs +11 -0
- package/resource.mjs.map +1 -0
- package/resources/alpha/admin.d.ts +44 -0
- package/resources/alpha/admin.d.ts.map +1 -0
- package/resources/alpha/admin.js +49 -0
- package/resources/alpha/admin.js.map +1 -0
- package/resources/alpha/admin.mjs +45 -0
- package/resources/alpha/admin.mjs.map +1 -0
- package/resources/alpha/alpha.d.ts +14 -0
- package/resources/alpha/alpha.d.ts.map +1 -0
- package/resources/alpha/alpha.js +49 -0
- package/resources/alpha/alpha.js.map +1 -0
- package/resources/alpha/alpha.mjs +22 -0
- package/resources/alpha/alpha.mjs.map +1 -0
- package/resources/alpha/benchmarks.d.ts +104 -0
- package/resources/alpha/benchmarks.d.ts.map +1 -0
- package/resources/alpha/benchmarks.js +50 -0
- package/resources/alpha/benchmarks.js.map +1 -0
- package/resources/alpha/benchmarks.mjs +44 -0
- package/resources/alpha/benchmarks.mjs.map +1 -0
- package/resources/alpha/index.d.ts +4 -0
- package/resources/alpha/index.d.ts.map +1 -0
- package/resources/alpha/index.js +17 -0
- package/resources/alpha/index.js.map +1 -0
- package/resources/alpha/index.mjs +11 -0
- package/resources/alpha/index.mjs.map +1 -0
- package/resources/alpha/inference.d.ts +144 -0
- package/resources/alpha/inference.d.ts.map +1 -0
- package/resources/alpha/inference.js +29 -0
- package/resources/alpha/inference.js.map +1 -0
- package/resources/alpha/inference.mjs +25 -0
- package/resources/alpha/inference.mjs.map +1 -0
- package/resources/alpha.d.ts +2 -0
- package/resources/alpha.d.ts.map +1 -0
- package/resources/alpha.js +25 -0
- package/resources/alpha.js.map +1 -0
- package/resources/alpha.mjs +9 -0
- package/resources/alpha.mjs.map +1 -0
- package/resources/batches.d.ts +442 -0
- package/resources/batches.d.ts.map +1 -0
- package/resources/batches.js +53 -0
- package/resources/batches.js.map +1 -0
- package/resources/batches.mjs +48 -0
- package/resources/batches.mjs.map +1 -0
- package/resources/chat/chat.d.ts +276 -0
- package/resources/chat/chat.d.ts.map +1 -0
- package/resources/chat/chat.js +45 -0
- package/resources/chat/chat.js.map +1 -0
- package/resources/chat/chat.mjs +18 -0
- package/resources/chat/chat.mjs.map +1 -0
- package/resources/chat/completions.d.ts +2021 -0
- package/resources/chat/completions.d.ts.map +1 -0
- package/resources/chat/completions.js +39 -0
- package/resources/chat/completions.js.map +1 -0
- package/resources/chat/completions.mjs +35 -0
- package/resources/chat/completions.mjs.map +1 -0
- package/resources/chat/index.d.ts +3 -0
- package/resources/chat/index.d.ts.map +1 -0
- package/resources/chat/index.js +15 -0
- package/resources/chat/index.js.map +1 -0
- package/resources/chat/index.mjs +10 -0
- package/resources/chat/index.mjs.map +1 -0
- package/resources/chat.d.ts +2 -0
- package/resources/chat.d.ts.map +1 -0
- package/resources/chat.js +25 -0
- package/resources/chat.js.map +1 -0
- package/resources/chat.mjs +9 -0
- package/resources/chat.mjs.map +1 -0
- package/resources/completions.d.ts +273 -0
- package/resources/completions.d.ts.map +1 -0
- package/resources/completions.js +26 -0
- package/resources/completions.js.map +1 -0
- package/resources/completions.mjs +22 -0
- package/resources/completions.mjs.map +1 -0
- package/resources/conversations/conversations.d.ts +429 -0
- package/resources/conversations/conversations.d.ts.map +1 -0
- package/resources/conversations/conversations.js +73 -0
- package/resources/conversations/conversations.js.map +1 -0
- package/resources/conversations/conversations.mjs +46 -0
- package/resources/conversations/conversations.mjs.map +1 -0
- package/resources/conversations/index.d.ts +3 -0
- package/resources/conversations/index.d.ts.map +1 -0
- package/resources/conversations/index.js +16 -0
- package/resources/conversations/index.js.map +1 -0
- package/resources/conversations/index.mjs +10 -0
- package/resources/conversations/index.mjs.map +1 -0
- package/resources/conversations/items.d.ts +1408 -0
- package/resources/conversations/items.d.ts.map +1 -0
- package/resources/conversations/items.js +48 -0
- package/resources/conversations/items.js.map +1 -0
- package/resources/conversations/items.mjs +43 -0
- package/resources/conversations/items.mjs.map +1 -0
- package/resources/conversations.d.ts +2 -0
- package/resources/conversations.d.ts.map +1 -0
- package/resources/conversations.js +25 -0
- package/resources/conversations.js.map +1 -0
- package/resources/conversations.mjs +9 -0
- package/resources/conversations.mjs.map +1 -0
- package/resources/embeddings.d.ts +98 -0
- package/resources/embeddings.d.ts.map +1 -0
- package/resources/embeddings.js +30 -0
- package/resources/embeddings.js.map +1 -0
- package/resources/embeddings.mjs +26 -0
- package/resources/embeddings.mjs.map +1 -0
- package/resources/files.d.ts +159 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +78 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +50 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.ts +20 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +66 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +27 -0
- package/resources/index.mjs.map +1 -0
- package/resources/inspect.d.ts +17 -0
- package/resources/inspect.d.ts.map +1 -0
- package/resources/inspect.js +30 -0
- package/resources/inspect.js.map +1 -0
- package/resources/inspect.mjs +26 -0
- package/resources/inspect.mjs.map +1 -0
- package/resources/models/index.d.ts +3 -0
- package/resources/models/index.d.ts.map +1 -0
- package/resources/models/index.js +15 -0
- package/resources/models/index.js.map +1 -0
- package/resources/models/index.mjs +10 -0
- package/resources/models/index.mjs.map +1 -0
- package/resources/models/models.d.ts +97 -0
- package/resources/models/models.d.ts.map +1 -0
- package/resources/models/models.js +57 -0
- package/resources/models/models.js.map +1 -0
- package/resources/models/models.mjs +30 -0
- package/resources/models/models.mjs.map +1 -0
- package/resources/models/openai.d.ts +10 -0
- package/resources/models/openai.d.ts.map +1 -0
- package/resources/models/openai.js +21 -0
- package/resources/models/openai.js.map +1 -0
- package/resources/models/openai.mjs +17 -0
- package/resources/models/openai.mjs.map +1 -0
- package/resources/models.d.ts +2 -0
- package/resources/models.d.ts.map +1 -0
- package/resources/models.js +25 -0
- package/resources/models.js.map +1 -0
- package/resources/models.mjs +9 -0
- package/resources/models.mjs.map +1 -0
- package/resources/moderations.d.ts +83 -0
- package/resources/moderations.d.ts.map +1 -0
- package/resources/moderations.js +24 -0
- package/resources/moderations.js.map +1 -0
- package/resources/moderations.mjs +20 -0
- package/resources/moderations.mjs.map +1 -0
- package/resources/prompts/index.d.ts +3 -0
- package/resources/prompts/index.d.ts.map +1 -0
- package/resources/prompts/index.js +15 -0
- package/resources/prompts/index.js.map +1 -0
- package/resources/prompts/index.mjs +10 -0
- package/resources/prompts/index.mjs.map +1 -0
- package/resources/prompts/prompts.d.ts +113 -0
- package/resources/prompts/prompts.d.ts.map +1 -0
- package/resources/prompts/prompts.js +88 -0
- package/resources/prompts/prompts.js.map +1 -0
- package/resources/prompts/prompts.mjs +61 -0
- package/resources/prompts/prompts.mjs.map +1 -0
- package/resources/prompts/versions.d.ts +13 -0
- package/resources/prompts/versions.d.ts.map +1 -0
- package/resources/prompts/versions.js +24 -0
- package/resources/prompts/versions.js.map +1 -0
- package/resources/prompts/versions.mjs +20 -0
- package/resources/prompts/versions.mjs.map +1 -0
- package/resources/prompts.d.ts +2 -0
- package/resources/prompts.d.ts.map +1 -0
- package/resources/prompts.js +25 -0
- package/resources/prompts.js.map +1 -0
- package/resources/prompts.mjs +9 -0
- package/resources/prompts.mjs.map +1 -0
- package/resources/providers.d.ts +24 -0
- package/resources/providers.d.ts.map +1 -0
- package/resources/providers.js +30 -0
- package/resources/providers.js.map +1 -0
- package/resources/providers.mjs +26 -0
- package/resources/providers.mjs.map +1 -0
- package/resources/responses/index.d.ts +3 -0
- package/resources/responses/index.d.ts.map +1 -0
- package/resources/responses/index.js +16 -0
- package/resources/responses/index.js.map +1 -0
- package/resources/responses/index.mjs +10 -0
- package/resources/responses/index.mjs.map +1 -0
- package/resources/responses/input-items.d.ts +382 -0
- package/resources/responses/input-items.d.ts.map +1 -0
- package/resources/responses/input-items.js +25 -0
- package/resources/responses/input-items.js.map +1 -0
- package/resources/responses/input-items.mjs +21 -0
- package/resources/responses/input-items.mjs.map +1 -0
- package/resources/responses/responses.d.ts +4808 -0
- package/resources/responses/responses.d.ts.map +1 -0
- package/resources/responses/responses.js +85 -0
- package/resources/responses/responses.js.map +1 -0
- package/resources/responses/responses.mjs +57 -0
- package/resources/responses/responses.mjs.map +1 -0
- package/resources/responses.d.ts +2 -0
- package/resources/responses.d.ts.map +1 -0
- package/resources/responses.js +25 -0
- package/resources/responses.js.map +1 -0
- package/resources/responses.mjs +9 -0
- package/resources/responses.mjs.map +1 -0
- package/resources/routes.d.ts +30 -0
- package/resources/routes.d.ts.map +1 -0
- package/resources/routes.js +25 -0
- package/resources/routes.js.map +1 -0
- package/resources/routes.mjs +21 -0
- package/resources/routes.mjs.map +1 -0
- package/resources/safety.d.ts +297 -0
- package/resources/safety.d.ts.map +1 -0
- package/resources/safety.js +24 -0
- package/resources/safety.js.map +1 -0
- package/resources/safety.mjs +20 -0
- package/resources/safety.mjs.map +1 -0
- package/resources/shared.d.ts +447 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +10 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +9 -0
- package/resources/shared.mjs.map +1 -0
- package/resources/shields.d.ts +82 -0
- package/resources/shields.d.ts.map +1 -0
- package/resources/shields.js +46 -0
- package/resources/shields.js.map +1 -0
- package/resources/shields.mjs +42 -0
- package/resources/shields.mjs.map +1 -0
- package/resources/vector-io.d.ts +375 -0
- package/resources/vector-io.d.ts.map +1 -0
- package/resources/vector-io.js +31 -0
- package/resources/vector-io.js.map +1 -0
- package/resources/vector-io.mjs +27 -0
- package/resources/vector-io.mjs.map +1 -0
- package/resources/vector-stores/file-batches.d.ts +268 -0
- package/resources/vector-stores/file-batches.d.ts.map +1 -0
- package/resources/vector-stores/file-batches.js +42 -0
- package/resources/vector-stores/file-batches.js.map +1 -0
- package/resources/vector-stores/file-batches.mjs +38 -0
- package/resources/vector-stores/file-batches.mjs.map +1 -0
- package/resources/vector-stores/files.d.ts +335 -0
- package/resources/vector-stores/files.d.ts.map +1 -0
- package/resources/vector-stores/files.js +60 -0
- package/resources/vector-stores/files.js.map +1 -0
- package/resources/vector-stores/files.mjs +55 -0
- package/resources/vector-stores/files.mjs.map +1 -0
- package/resources/vector-stores/index.d.ts +4 -0
- package/resources/vector-stores/index.d.ts.map +1 -0
- package/resources/vector-stores/index.js +19 -0
- package/resources/vector-stores/index.js.map +1 -0
- package/resources/vector-stores/index.mjs +11 -0
- package/resources/vector-stores/index.mjs.map +1 -0
- package/resources/vector-stores/vector-stores.d.ts +412 -0
- package/resources/vector-stores/vector-stores.d.ts.map +1 -0
- package/resources/vector-stores/vector-stores.js +92 -0
- package/resources/vector-stores/vector-stores.js.map +1 -0
- package/resources/vector-stores/vector-stores.mjs +64 -0
- package/resources/vector-stores/vector-stores.mjs.map +1 -0
- package/resources/vector-stores.d.ts +2 -0
- package/resources/vector-stores.d.ts.map +1 -0
- package/resources/vector-stores.js +25 -0
- package/resources/vector-stores.js.map +1 -0
- package/resources/vector-stores.mjs +9 -0
- package/resources/vector-stores.mjs.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +23 -0
- package/resources.js.map +1 -0
- package/resources.mjs +7 -0
- package/resources.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +36 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +10 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +36 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +10 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +15 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +10 -0
- package/src/_shims/auto/runtime-node.ts +10 -0
- package/src/_shims/auto/runtime.ts +10 -0
- package/src/_shims/auto/types-node.ts +10 -0
- package/src/_shims/auto/types.d.ts +107 -0
- package/src/_shims/auto/types.js +9 -0
- package/src/_shims/auto/types.mjs +10 -0
- package/src/_shims/bun-runtime.ts +20 -0
- package/src/_shims/index.d.ts +89 -0
- package/src/_shims/index.js +23 -0
- package/src/_shims/index.mjs +18 -0
- package/src/_shims/manual-types.d.ts +18 -0
- package/src/_shims/manual-types.js +9 -0
- package/src/_shims/manual-types.mjs +10 -0
- package/src/_shims/node-runtime.ts +87 -0
- package/src/_shims/node-types.d.ts +48 -0
- package/src/_shims/node-types.js +9 -0
- package/src/_shims/node-types.mjs +10 -0
- package/src/_shims/registry.ts +73 -0
- package/src/_shims/web-runtime.ts +109 -0
- package/src/_shims/web-types.d.ts +89 -0
- package/src/_shims/web-types.js +9 -0
- package/src/_shims/web-types.mjs +10 -0
- package/src/core.ts +1253 -0
- package/src/error.ts +137 -0
- package/src/index.ts +554 -0
- package/src/internal/decoders/line.ts +182 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +15 -0
- package/src/internal/qs/index.ts +19 -0
- package/src/internal/qs/stringify.ts +394 -0
- package/src/internal/qs/types.ts +77 -0
- package/src/internal/qs/utils.ts +271 -0
- package/src/internal/stream-utils.ts +38 -0
- package/src/internal/utils/query.ts +13 -0
- package/src/lib/response-helpers.ts +60 -0
- package/src/pagination.ts +80 -0
- package/src/resource.ts +18 -0
- package/src/resources/alpha/admin.ts +87 -0
- package/src/resources/alpha/alpha.ts +31 -0
- package/src/resources/alpha/benchmarks.ts +152 -0
- package/src/resources/alpha/index.ts +11 -0
- package/src/resources/alpha/inference.ts +191 -0
- package/src/resources/alpha.ts +9 -0
- package/src/resources/batches.ts +692 -0
- package/src/resources/chat/chat.ts +351 -0
- package/src/resources/chat/completions.ts +2430 -0
- package/src/resources/chat/index.ts +19 -0
- package/src/resources/chat.ts +9 -0
- package/src/resources/completions.ts +350 -0
- package/src/resources/conversations/conversations.ts +627 -0
- package/src/resources/conversations/index.ts +25 -0
- package/src/resources/conversations/items.ts +2061 -0
- package/src/resources/conversations.ts +9 -0
- package/src/resources/embeddings.ts +130 -0
- package/src/resources/files.ts +225 -0
- package/src/resources/index.ts +104 -0
- package/src/resources/inspect.ts +30 -0
- package/src/resources/models/index.ts +10 -0
- package/src/resources/models/models.ts +133 -0
- package/src/resources/models/openai.ts +20 -0
- package/src/resources/models.ts +9 -0
- package/src/resources/moderations.ts +97 -0
- package/src/resources/prompts/index.ts +19 -0
- package/src/resources/prompts/prompts.ts +188 -0
- package/src/resources/prompts/versions.ts +27 -0
- package/src/resources/prompts.ts +9 -0
- package/src/resources/providers.ts +41 -0
- package/src/resources/responses/index.ts +26 -0
- package/src/resources/responses/input-items.ts +571 -0
- package/src/resources/responses/responses.ts +6718 -0
- package/src/resources/responses.ts +9 -0
- package/src/resources/routes.ts +55 -0
- package/src/resources/safety.ts +367 -0
- package/src/resources/shared.ts +544 -0
- package/src/resources/shields.ts +119 -0
- package/src/resources/vector-io.ts +485 -0
- package/src/resources/vector-stores/file-batches.ts +386 -0
- package/src/resources/vector-stores/files.ts +496 -0
- package/src/resources/vector-stores/index.ts +38 -0
- package/src/resources/vector-stores/vector-stores.ts +588 -0
- package/src/resources/vector-stores.ts +9 -0
- package/src/resources.ts +7 -0
- package/src/shims/node.ts +56 -0
- package/src/shims/web.ts +56 -0
- package/src/streaming.ts +315 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +261 -0
- package/src/version.ts +7 -0
- package/streaming.d.ts +32 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +272 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +267 -0
- package/streaming.mjs.map +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +176 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +163 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +10 -0
- package/version.js.map +1 -0
- package/version.mjs +7 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
export type Format = 'RFC1738' | 'RFC3986';
|
|
8
|
+
|
|
9
|
+
export type DefaultEncoder = (str: any, defaultEncoder?: any, charset?: string) => string;
|
|
10
|
+
export type DefaultDecoder = (str: string, decoder?: any, charset?: string) => string;
|
|
11
|
+
|
|
12
|
+
export type BooleanOptional = boolean | undefined;
|
|
13
|
+
|
|
14
|
+
export type StringifyBaseOptions = {
|
|
15
|
+
delimiter?: string;
|
|
16
|
+
allowDots?: boolean;
|
|
17
|
+
encodeDotInKeys?: boolean;
|
|
18
|
+
strictNullHandling?: boolean;
|
|
19
|
+
skipNulls?: boolean;
|
|
20
|
+
encode?: boolean;
|
|
21
|
+
encoder?: (
|
|
22
|
+
str: any,
|
|
23
|
+
defaultEncoder: DefaultEncoder,
|
|
24
|
+
charset: string,
|
|
25
|
+
type: 'key' | 'value',
|
|
26
|
+
format?: Format,
|
|
27
|
+
) => string;
|
|
28
|
+
filter?: Array<PropertyKey> | ((prefix: PropertyKey, value: any) => any);
|
|
29
|
+
arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma';
|
|
30
|
+
indices?: boolean;
|
|
31
|
+
sort?: ((a: PropertyKey, b: PropertyKey) => number) | null;
|
|
32
|
+
serializeDate?: (d: Date) => string;
|
|
33
|
+
format?: 'RFC1738' | 'RFC3986';
|
|
34
|
+
formatter?: (str: PropertyKey) => string;
|
|
35
|
+
encodeValuesOnly?: boolean;
|
|
36
|
+
addQueryPrefix?: boolean;
|
|
37
|
+
charset?: 'utf-8' | 'iso-8859-1';
|
|
38
|
+
charsetSentinel?: boolean;
|
|
39
|
+
allowEmptyArrays?: boolean;
|
|
40
|
+
commaRoundTrip?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type StringifyOptions = StringifyBaseOptions;
|
|
44
|
+
|
|
45
|
+
export type ParseBaseOptions = {
|
|
46
|
+
comma?: boolean;
|
|
47
|
+
delimiter?: string | RegExp;
|
|
48
|
+
depth?: number | false;
|
|
49
|
+
decoder?: (str: string, defaultDecoder: DefaultDecoder, charset: string, type: 'key' | 'value') => any;
|
|
50
|
+
arrayLimit?: number;
|
|
51
|
+
parseArrays?: boolean;
|
|
52
|
+
plainObjects?: boolean;
|
|
53
|
+
allowPrototypes?: boolean;
|
|
54
|
+
allowSparse?: boolean;
|
|
55
|
+
parameterLimit?: number;
|
|
56
|
+
strictDepth?: boolean;
|
|
57
|
+
strictNullHandling?: boolean;
|
|
58
|
+
ignoreQueryPrefix?: boolean;
|
|
59
|
+
charset?: 'utf-8' | 'iso-8859-1';
|
|
60
|
+
charsetSentinel?: boolean;
|
|
61
|
+
interpretNumericEntities?: boolean;
|
|
62
|
+
allowEmptyArrays?: boolean;
|
|
63
|
+
duplicates?: 'combine' | 'first' | 'last';
|
|
64
|
+
allowDots?: boolean;
|
|
65
|
+
decodeDotInKeys?: boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type ParseOptions = ParseBaseOptions;
|
|
69
|
+
|
|
70
|
+
export type ParsedQs = {
|
|
71
|
+
[key: string]: undefined | string | string[] | ParsedQs | ParsedQs[];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Type to remove null or undefined union from each property
|
|
75
|
+
export type NonNullableProperties<T> = {
|
|
76
|
+
[K in keyof T]-?: Exclude<T[K], undefined | null>;
|
|
77
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
import { RFC1738 } from './formats';
|
|
8
|
+
import type { DefaultEncoder, Format } from './types';
|
|
9
|
+
|
|
10
|
+
const has = Object.prototype.hasOwnProperty;
|
|
11
|
+
const is_array = Array.isArray;
|
|
12
|
+
|
|
13
|
+
const hex_table = (() => {
|
|
14
|
+
const array = [];
|
|
15
|
+
for (let i = 0; i < 256; ++i) {
|
|
16
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return array;
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
|
|
23
|
+
while (queue.length > 1) {
|
|
24
|
+
const item = queue.pop();
|
|
25
|
+
if (!item) continue;
|
|
26
|
+
|
|
27
|
+
const obj = item.obj[item.prop];
|
|
28
|
+
|
|
29
|
+
if (is_array(obj)) {
|
|
30
|
+
const compacted: unknown[] = [];
|
|
31
|
+
|
|
32
|
+
for (let j = 0; j < obj.length; ++j) {
|
|
33
|
+
if (typeof obj[j] !== 'undefined') {
|
|
34
|
+
compacted.push(obj[j]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
item.obj[item.prop] = compacted;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function array_to_object(source: any[], options: { plainObjects: boolean }) {
|
|
45
|
+
const obj = options && options.plainObjects ? Object.create(null) : {};
|
|
46
|
+
for (let i = 0; i < source.length; ++i) {
|
|
47
|
+
if (typeof source[i] !== 'undefined') {
|
|
48
|
+
obj[i] = source[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return obj;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function merge(
|
|
56
|
+
target: any,
|
|
57
|
+
source: any,
|
|
58
|
+
options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
|
|
59
|
+
) {
|
|
60
|
+
if (!source) {
|
|
61
|
+
return target;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof source !== 'object') {
|
|
65
|
+
if (is_array(target)) {
|
|
66
|
+
target.push(source);
|
|
67
|
+
} else if (target && typeof target === 'object') {
|
|
68
|
+
if (
|
|
69
|
+
(options && (options.plainObjects || options.allowPrototypes)) ||
|
|
70
|
+
!has.call(Object.prototype, source)
|
|
71
|
+
) {
|
|
72
|
+
target[source] = true;
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
return [target, source];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!target || typeof target !== 'object') {
|
|
82
|
+
return [target].concat(source);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let mergeTarget = target;
|
|
86
|
+
if (is_array(target) && !is_array(source)) {
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
mergeTarget = array_to_object(target, options);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (is_array(target) && is_array(source)) {
|
|
92
|
+
source.forEach(function (item, i) {
|
|
93
|
+
if (has.call(target, i)) {
|
|
94
|
+
const targetItem = target[i];
|
|
95
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
96
|
+
target[i] = merge(targetItem, item, options);
|
|
97
|
+
} else {
|
|
98
|
+
target.push(item);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
target[i] = item;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return target;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
108
|
+
const value = source[key];
|
|
109
|
+
|
|
110
|
+
if (has.call(acc, key)) {
|
|
111
|
+
acc[key] = merge(acc[key], value, options);
|
|
112
|
+
} else {
|
|
113
|
+
acc[key] = value;
|
|
114
|
+
}
|
|
115
|
+
return acc;
|
|
116
|
+
}, mergeTarget);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function assign_single_source(target: any, source: any) {
|
|
120
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
121
|
+
acc[key] = source[key];
|
|
122
|
+
return acc;
|
|
123
|
+
}, target);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function decode(str: string, _: any, charset: string) {
|
|
127
|
+
const strWithoutPlus = str.replace(/\+/g, ' ');
|
|
128
|
+
if (charset === 'iso-8859-1') {
|
|
129
|
+
// unescape never throws, no try...catch needed:
|
|
130
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
131
|
+
}
|
|
132
|
+
// utf-8
|
|
133
|
+
try {
|
|
134
|
+
return decodeURIComponent(strWithoutPlus);
|
|
135
|
+
} catch (e) {
|
|
136
|
+
return strWithoutPlus;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const limit = 1024;
|
|
141
|
+
|
|
142
|
+
export const encode: (
|
|
143
|
+
str: any,
|
|
144
|
+
defaultEncoder: DefaultEncoder,
|
|
145
|
+
charset: string,
|
|
146
|
+
type: 'key' | 'value',
|
|
147
|
+
format: Format,
|
|
148
|
+
) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
|
|
149
|
+
// This code was originally written by Brian White for the io.js core querystring library.
|
|
150
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
151
|
+
if (str.length === 0) {
|
|
152
|
+
return str;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
let string = str;
|
|
156
|
+
if (typeof str === 'symbol') {
|
|
157
|
+
string = Symbol.prototype.toString.call(str);
|
|
158
|
+
} else if (typeof str !== 'string') {
|
|
159
|
+
string = String(str);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (charset === 'iso-8859-1') {
|
|
163
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
164
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let out = '';
|
|
169
|
+
for (let j = 0; j < string.length; j += limit) {
|
|
170
|
+
const segment = string.length >= limit ? string.slice(j, j + limit) : string;
|
|
171
|
+
const arr = [];
|
|
172
|
+
|
|
173
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
174
|
+
let c = segment.charCodeAt(i);
|
|
175
|
+
if (
|
|
176
|
+
c === 0x2d || // -
|
|
177
|
+
c === 0x2e || // .
|
|
178
|
+
c === 0x5f || // _
|
|
179
|
+
c === 0x7e || // ~
|
|
180
|
+
(c >= 0x30 && c <= 0x39) || // 0-9
|
|
181
|
+
(c >= 0x41 && c <= 0x5a) || // a-z
|
|
182
|
+
(c >= 0x61 && c <= 0x7a) || // A-Z
|
|
183
|
+
(format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
184
|
+
) {
|
|
185
|
+
arr[arr.length] = segment.charAt(i);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (c < 0x80) {
|
|
190
|
+
arr[arr.length] = hex_table[c];
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (c < 0x800) {
|
|
195
|
+
arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (c < 0xd800 || c >= 0xe000) {
|
|
200
|
+
arr[arr.length] =
|
|
201
|
+
hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
i += 1;
|
|
206
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
207
|
+
|
|
208
|
+
arr[arr.length] =
|
|
209
|
+
hex_table[0xf0 | (c >> 18)]! +
|
|
210
|
+
hex_table[0x80 | ((c >> 12) & 0x3f)] +
|
|
211
|
+
hex_table[0x80 | ((c >> 6) & 0x3f)] +
|
|
212
|
+
hex_table[0x80 | (c & 0x3f)];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
out += arr.join('');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return out;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export function compact(value: any) {
|
|
222
|
+
const queue = [{ obj: { o: value }, prop: 'o' }];
|
|
223
|
+
const refs = [];
|
|
224
|
+
|
|
225
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
226
|
+
const item = queue[i];
|
|
227
|
+
// @ts-ignore
|
|
228
|
+
const obj = item.obj[item.prop];
|
|
229
|
+
|
|
230
|
+
const keys = Object.keys(obj);
|
|
231
|
+
for (let j = 0; j < keys.length; ++j) {
|
|
232
|
+
const key = keys[j]!;
|
|
233
|
+
const val = obj[key];
|
|
234
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
235
|
+
queue.push({ obj: obj, prop: key });
|
|
236
|
+
refs.push(val);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
compact_queue(queue);
|
|
242
|
+
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function is_regexp(obj: any) {
|
|
247
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function is_buffer(obj: any) {
|
|
251
|
+
if (!obj || typeof obj !== 'object') {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function combine(a: any, b: any) {
|
|
259
|
+
return [].concat(a, b);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
263
|
+
if (is_array(val)) {
|
|
264
|
+
const mapped = [];
|
|
265
|
+
for (let i = 0; i < val.length; i += 1) {
|
|
266
|
+
mapped.push(fn(val[i]!));
|
|
267
|
+
}
|
|
268
|
+
return mapped;
|
|
269
|
+
}
|
|
270
|
+
return fn(val);
|
|
271
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
9
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
10
|
+
*
|
|
11
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
12
|
+
*/
|
|
13
|
+
export function ReadableStreamToAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
|
|
14
|
+
if (stream[Symbol.asyncIterator]) return stream;
|
|
15
|
+
|
|
16
|
+
const reader = stream.getReader();
|
|
17
|
+
return {
|
|
18
|
+
async next() {
|
|
19
|
+
try {
|
|
20
|
+
const result = await reader.read();
|
|
21
|
+
if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
|
|
22
|
+
return result;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
async return() {
|
|
29
|
+
const cancelPromise = reader.cancel();
|
|
30
|
+
reader.releaseLock();
|
|
31
|
+
await cancelPromise;
|
|
32
|
+
return { done: true, value: undefined };
|
|
33
|
+
},
|
|
34
|
+
[Symbol.asyncIterator]() {
|
|
35
|
+
return this;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) The OGX Contributors.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8
|
+
|
|
9
|
+
import * as qs from '../qs/stringify';
|
|
10
|
+
|
|
11
|
+
export function stringifyQuery(query: object | Record<string, unknown>) {
|
|
12
|
+
return qs.stringify(query, { arrayFormat: 'comma' });
|
|
13
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Helper utilities for working with response objects.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ResponseObject } from '../resources/responses/responses';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Extracts aggregated text output from a ResponseObject.
|
|
15
|
+
* This concatenates all `output_text` entries from the response's output array.
|
|
16
|
+
*
|
|
17
|
+
* Useful for streaming responses where you want to get the final text from chunk.response:
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const stream = await client.responses.create({ stream: true, ... });
|
|
22
|
+
* for await (const chunk of stream) {
|
|
23
|
+
* if (chunk.type === 'response.completed') {
|
|
24
|
+
* const text = getResponseOutputText(chunk.response);
|
|
25
|
+
* console.log(text);
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function getResponseOutputText(response: ResponseObject): string {
|
|
31
|
+
const pieces: string[] = [];
|
|
32
|
+
|
|
33
|
+
for (const output of response.output ?? []) {
|
|
34
|
+
if (!output || output.type !== 'message') {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const content = output.content;
|
|
39
|
+
if (typeof content === 'string') {
|
|
40
|
+
pieces.push(content);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!Array.isArray(content)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (const item of content) {
|
|
49
|
+
if (typeof item === 'string') {
|
|
50
|
+
pieces.push(item);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (item && item.type === 'output_text' && 'text' in item && typeof item.text === 'string') {
|
|
54
|
+
pieces.push(item.text);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return pieces.join('');
|
|
60
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright (c) The OGX Contributors.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
9
|
+
|
|
10
|
+
import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';
|
|
11
|
+
|
|
12
|
+
export interface OpenAICursorPageResponse<Item> {
|
|
13
|
+
data: Array<Item>;
|
|
14
|
+
|
|
15
|
+
has_more: boolean;
|
|
16
|
+
|
|
17
|
+
last_id: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface OpenAICursorPageParams {
|
|
21
|
+
limit?: number;
|
|
22
|
+
|
|
23
|
+
after?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class OpenAICursorPage<Item> extends AbstractPage<Item> implements OpenAICursorPageResponse<Item> {
|
|
27
|
+
data: Array<Item>;
|
|
28
|
+
|
|
29
|
+
has_more: boolean;
|
|
30
|
+
|
|
31
|
+
last_id: string;
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
client: APIClient,
|
|
35
|
+
response: Response,
|
|
36
|
+
body: OpenAICursorPageResponse<Item>,
|
|
37
|
+
options: FinalRequestOptions,
|
|
38
|
+
) {
|
|
39
|
+
super(client, response, body, options);
|
|
40
|
+
|
|
41
|
+
this.data = body.data || [];
|
|
42
|
+
this.has_more = body.has_more || false;
|
|
43
|
+
this.last_id = body.last_id || '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getPaginatedItems(): Item[] {
|
|
47
|
+
return this.data ?? [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override hasNextPage(): boolean {
|
|
51
|
+
if (this.has_more === false) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return super.hasNextPage();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// @deprecated Please use `nextPageInfo()` instead
|
|
59
|
+
nextPageParams(): Partial<OpenAICursorPageParams> | null {
|
|
60
|
+
const info = this.nextPageInfo();
|
|
61
|
+
if (!info) return null;
|
|
62
|
+
if ('params' in info) return info.params;
|
|
63
|
+
const params = Object.fromEntries(info.url.searchParams);
|
|
64
|
+
if (!Object.keys(params).length) return null;
|
|
65
|
+
return params;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
nextPageInfo(): PageInfo | null {
|
|
69
|
+
const cursor = this.last_id;
|
|
70
|
+
if (!cursor) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
params: {
|
|
76
|
+
after: cursor,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/resource.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright (c) The OGX Contributors.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
9
|
+
|
|
10
|
+
import type { OgxClient } from './index';
|
|
11
|
+
|
|
12
|
+
export abstract class APIResource {
|
|
13
|
+
protected _client: OgxClient;
|
|
14
|
+
|
|
15
|
+
constructor(client: OgxClient) {
|
|
16
|
+
this._client = client;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright (c) The OGX Contributors.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8
|
+
|
|
9
|
+
import { APIResource } from '../../resource';
|
|
10
|
+
import { isRequestOptions } from '../../core';
|
|
11
|
+
import * as Core from '../../core';
|
|
12
|
+
import * as ProvidersAPI from '../providers';
|
|
13
|
+
import * as RoutesAPI from '../routes';
|
|
14
|
+
import * as Shared from '../shared';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Administrative APIs for inspecting providers, routes, health, and version.
|
|
18
|
+
*/
|
|
19
|
+
export class Admin extends APIResource {
|
|
20
|
+
/**
|
|
21
|
+
* Get the current health status of the service.
|
|
22
|
+
*/
|
|
23
|
+
health(options?: Core.RequestOptions): Core.APIPromise<Shared.HealthInfo> {
|
|
24
|
+
return this._client.get('/v1alpha/admin/health', options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get detailed information about a specific provider.
|
|
29
|
+
*/
|
|
30
|
+
inspectProvider(providerId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.ProviderInfo> {
|
|
31
|
+
return this._client.get(`/v1alpha/admin/providers/${providerId}`, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* List all available providers with their configuration and health status.
|
|
36
|
+
*/
|
|
37
|
+
listProviders(options?: Core.RequestOptions): Core.APIPromise<ProvidersAPI.ProviderListResponse> {
|
|
38
|
+
return (
|
|
39
|
+
this._client.get('/v1alpha/admin/providers', options) as Core.APIPromise<{
|
|
40
|
+
data: ProvidersAPI.ProviderListResponse;
|
|
41
|
+
}>
|
|
42
|
+
)._thenUnwrap((obj) => obj.data);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* List all available API routes with their methods and implementing providers.
|
|
47
|
+
*/
|
|
48
|
+
listRoutes(
|
|
49
|
+
query?: AdminListRoutesParams,
|
|
50
|
+
options?: Core.RequestOptions,
|
|
51
|
+
): Core.APIPromise<RoutesAPI.RouteListResponse>;
|
|
52
|
+
listRoutes(options?: Core.RequestOptions): Core.APIPromise<RoutesAPI.RouteListResponse>;
|
|
53
|
+
listRoutes(
|
|
54
|
+
query: AdminListRoutesParams | Core.RequestOptions = {},
|
|
55
|
+
options?: Core.RequestOptions,
|
|
56
|
+
): Core.APIPromise<RoutesAPI.RouteListResponse> {
|
|
57
|
+
if (isRequestOptions(query)) {
|
|
58
|
+
return this.listRoutes({}, query);
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
this._client.get('/v1alpha/admin/inspect/routes', { query, ...options }) as Core.APIPromise<{
|
|
62
|
+
data: RoutesAPI.RouteListResponse;
|
|
63
|
+
}>
|
|
64
|
+
)._thenUnwrap((obj) => obj.data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the version of the service.
|
|
69
|
+
*/
|
|
70
|
+
version(options?: Core.RequestOptions): Core.APIPromise<Shared.VersionInfo> {
|
|
71
|
+
return this._client.get('/v1alpha/admin/version', options);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface AdminListRoutesParams {
|
|
76
|
+
/**
|
|
77
|
+
* Filter to control which routes are returned. Can be an API level ('v1',
|
|
78
|
+
* 'v1alpha', 'v1beta') to show non-deprecated routes at that level, or
|
|
79
|
+
* 'deprecated' to show deprecated routes across all levels. If not specified,
|
|
80
|
+
* returns all non-deprecated routes.
|
|
81
|
+
*/
|
|
82
|
+
api_filter?: 'v1' | 'v1alpha' | 'v1beta' | 'deprecated' | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export declare namespace Admin {
|
|
86
|
+
export { type AdminListRoutesParams as AdminListRoutesParams };
|
|
87
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) The OGX Contributors.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the terms described in the LICENSE file in
|
|
5
|
+
// the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8
|
+
|
|
9
|
+
import { APIResource } from '../../resource';
|
|
10
|
+
import * as AdminAPI from './admin';
|
|
11
|
+
import { Admin, AdminListRoutesParams } from './admin';
|
|
12
|
+
import * as InferenceAPI from './inference';
|
|
13
|
+
import { Inference, InferenceRerankParams, InferenceRerankResponse } from './inference';
|
|
14
|
+
|
|
15
|
+
export class Alpha extends APIResource {
|
|
16
|
+
admin: AdminAPI.Admin = new AdminAPI.Admin(this._client);
|
|
17
|
+
inference: InferenceAPI.Inference = new InferenceAPI.Inference(this._client);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Alpha.Admin = Admin;
|
|
21
|
+
Alpha.Inference = Inference;
|
|
22
|
+
|
|
23
|
+
export declare namespace Alpha {
|
|
24
|
+
export { Admin as Admin, type AdminListRoutesParams as AdminListRoutesParams };
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
Inference as Inference,
|
|
28
|
+
type InferenceRerankResponse as InferenceRerankResponse,
|
|
29
|
+
type InferenceRerankParams as InferenceRerankParams,
|
|
30
|
+
};
|
|
31
|
+
}
|