modelmix 2.2.4 → 2.3.2
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 +21 -8
- package/demo/default.env +1 -0
- package/demo/demo.mjs +14 -15
- package/demo/groq.mjs +24 -0
- package/demo/lmstudio.mjs +1 -1
- package/demo/package-lock.json +1 -50
- package/demo/package.json +1 -3
- package/demo/stream.mjs +3 -3
- package/demo/watson.jpg +0 -0
- package/index.js +54 -2
- package/package.json +4 -2
- package/demo/node_modules/.package-lock.json +0 -301
- package/demo/node_modules/@anthropic-ai/sdk/CHANGELOG.md +0 -859
- package/demo/node_modules/@anthropic-ai/sdk/LICENSE +0 -8
- package/demo/node_modules/@anthropic-ai/sdk/README.md +0 -424
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.d.ts +0 -9
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.js +0 -16
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.mjs +0 -12
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/README.md +0 -46
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.d.ts +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.js +0 -21
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.mjs +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.d.ts +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.js +0 -21
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.mjs +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.d.ts +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.js +0 -21
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.mjs +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.d.ts +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.js +0 -21
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.mjs +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types.d.ts +0 -101
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.d.ts +0 -6
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.js +0 -14
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.mjs +0 -10
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/index.d.ts +0 -81
- package/demo/node_modules/@anthropic-ai/sdk/_shims/index.js +0 -13
- package/demo/node_modules/@anthropic-ai/sdk/_shims/index.mjs +0 -7
- package/demo/node_modules/@anthropic-ai/sdk/_shims/manual-types.d.ts +0 -12
- package/demo/node_modules/@anthropic-ai/sdk/_shims/manual-types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/manual-types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.d.ts +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.js +0 -90
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs +0 -56
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-types.d.ts +0 -42
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.d.ts +0 -37
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.js +0 -41
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.mjs +0 -37
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.d.ts +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.js +0 -78
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.mjs +0 -71
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-types.d.ts +0 -83
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/core.d.ts +0 -239
- package/demo/node_modules/@anthropic-ai/sdk/core.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/core.js +0 -879
- package/demo/node_modules/@anthropic-ai/sdk/core.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/core.mjs +0 -848
- package/demo/node_modules/@anthropic-ai/sdk/core.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/error.d.ts +0 -53
- package/demo/node_modules/@anthropic-ai/sdk/error.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/error.js +0 -143
- package/demo/node_modules/@anthropic-ai/sdk/error.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/error.mjs +0 -127
- package/demo/node_modules/@anthropic-ai/sdk/error.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/index.d.mts +0 -147
- package/demo/node_modules/@anthropic-ai/sdk/index.d.ts +0 -147
- package/demo/node_modules/@anthropic-ai/sdk/index.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/index.js +0 -149
- package/demo/node_modules/@anthropic-ai/sdk/index.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/index.mjs +0 -121
- package/demo/node_modules/@anthropic-ai/sdk/index.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts +0 -94
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.js +0 -436
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs +0 -432
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/package.json +0 -104
- package/demo/node_modules/@anthropic-ai/sdk/resource.d.ts +0 -6
- package/demo/node_modules/@anthropic-ai/sdk/resource.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resource.js +0 -11
- package/demo/node_modules/@anthropic-ai/sdk/resource.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resource.mjs +0 -7
- package/demo/node_modules/@anthropic-ai/sdk/resource.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts +0 -9
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +0 -40
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs +0 -13
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.js +0 -9
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.d.ts +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.js +0 -9
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.mjs +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.d.ts +0 -462
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.js +0 -20
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.mjs +0 -16
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.d.ts +0 -19
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.js +0 -40
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.mjs +0 -13
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.d.ts +0 -184
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.js +0 -19
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.mjs +0 -15
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.d.ts +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.js +0 -11
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.mjs +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.d.ts +0 -619
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.js +0 -28
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.mjs +0 -23
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.d.ts +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.js +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.d.ts +0 -29
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.js +0 -31
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.mjs +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.d.ts +0 -26
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.js +0 -31
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.mjs +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/MultipartBody.ts +0 -9
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/README.md +0 -46
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/runtime-bun.ts +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/runtime-node.ts +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/runtime.ts +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types-node.ts +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types.d.ts +0 -101
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/bun-runtime.ts +0 -14
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/index.d.ts +0 -81
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/index.js +0 -13
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/index.mjs +0 -7
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/manual-types.d.ts +0 -12
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/manual-types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/manual-types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-runtime.ts +0 -83
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-types.d.ts +0 -42
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/registry.ts +0 -67
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-runtime.ts +0 -103
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-types.d.ts +0 -83
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-types.js +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-types.mjs +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/core.ts +0 -1162
- package/demo/node_modules/@anthropic-ai/sdk/src/error.ts +0 -146
- package/demo/node_modules/@anthropic-ai/sdk/src/index.ts +0 -264
- package/demo/node_modules/@anthropic-ai/sdk/src/lib/.keep +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/src/lib/MessageStream.ts +0 -535
- package/demo/node_modules/@anthropic-ai/sdk/src/resource.ts +0 -11
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/beta.ts +0 -12
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/index.ts +0 -4
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/tools/index.ts +0 -16
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/tools/messages.ts +0 -531
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/tools/tools.ts +0 -22
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/completions.ts +0 -223
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/index.ts +0 -33
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/messages.ts +0 -729
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/top-level.ts +0 -3
- package/demo/node_modules/@anthropic-ai/sdk/src/shims/node.ts +0 -50
- package/demo/node_modules/@anthropic-ai/sdk/src/shims/web.ts +0 -50
- package/demo/node_modules/@anthropic-ai/sdk/src/streaming.ts +0 -509
- package/demo/node_modules/@anthropic-ai/sdk/src/tsconfig.json +0 -11
- package/demo/node_modules/@anthropic-ai/sdk/src/uploads.ts +0 -248
- package/demo/node_modules/@anthropic-ai/sdk/src/version.ts +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/streaming.d.ts +0 -41
- package/demo/node_modules/@anthropic-ai/sdk/streaming.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/streaming.js +0 -431
- package/demo/node_modules/@anthropic-ai/sdk/streaming.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/streaming.mjs +0 -424
- package/demo/node_modules/@anthropic-ai/sdk/streaming.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/uploads.d.ts +0 -75
- package/demo/node_modules/@anthropic-ai/sdk/uploads.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/uploads.js +0 -165
- package/demo/node_modules/@anthropic-ai/sdk/uploads.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/uploads.mjs +0 -152
- package/demo/node_modules/@anthropic-ai/sdk/uploads.mjs.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/version.d.ts +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/version.d.ts.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/version.js +0 -5
- package/demo/node_modules/@anthropic-ai/sdk/version.js.map +0 -1
- package/demo/node_modules/@anthropic-ai/sdk/version.mjs +0 -2
- package/demo/node_modules/@anthropic-ai/sdk/version.mjs.map +0 -1
- package/demo/node_modules/@types/node/LICENSE +0 -21
- package/demo/node_modules/@types/node/README.md +0 -15
- package/demo/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/demo/node_modules/@types/node/assert.d.ts +0 -985
- package/demo/node_modules/@types/node/async_hooks.d.ts +0 -522
- package/demo/node_modules/@types/node/buffer.d.ts +0 -2353
- package/demo/node_modules/@types/node/child_process.d.ts +0 -1544
- package/demo/node_modules/@types/node/cluster.d.ts +0 -578
- package/demo/node_modules/@types/node/console.d.ts +0 -452
- package/demo/node_modules/@types/node/constants.d.ts +0 -19
- package/demo/node_modules/@types/node/crypto.d.ts +0 -4457
- package/demo/node_modules/@types/node/dgram.d.ts +0 -596
- package/demo/node_modules/@types/node/diagnostics_channel.d.ts +0 -546
- package/demo/node_modules/@types/node/dns/promises.d.ts +0 -473
- package/demo/node_modules/@types/node/dns.d.ts +0 -853
- package/demo/node_modules/@types/node/dom-events.d.ts +0 -124
- package/demo/node_modules/@types/node/domain.d.ts +0 -170
- package/demo/node_modules/@types/node/events.d.ts +0 -819
- package/demo/node_modules/@types/node/fs/promises.d.ts +0 -1205
- package/demo/node_modules/@types/node/fs.d.ts +0 -4237
- package/demo/node_modules/@types/node/globals.d.ts +0 -377
- package/demo/node_modules/@types/node/globals.global.d.ts +0 -1
- package/demo/node_modules/@types/node/http.d.ts +0 -1803
- package/demo/node_modules/@types/node/http2.d.ts +0 -2392
- package/demo/node_modules/@types/node/https.d.ts +0 -544
- package/demo/node_modules/@types/node/index.d.ts +0 -88
- package/demo/node_modules/@types/node/inspector.d.ts +0 -2738
- package/demo/node_modules/@types/node/module.d.ts +0 -298
- package/demo/node_modules/@types/node/net.d.ts +0 -918
- package/demo/node_modules/@types/node/os.d.ts +0 -473
- package/demo/node_modules/@types/node/package.json +0 -222
- package/demo/node_modules/@types/node/path.d.ts +0 -191
- package/demo/node_modules/@types/node/perf_hooks.d.ts +0 -626
- package/demo/node_modules/@types/node/process.d.ts +0 -1548
- package/demo/node_modules/@types/node/punycode.d.ts +0 -117
- package/demo/node_modules/@types/node/querystring.d.ts +0 -141
- package/demo/node_modules/@types/node/readline/promises.d.ts +0 -143
- package/demo/node_modules/@types/node/readline.d.ts +0 -666
- package/demo/node_modules/@types/node/repl.d.ts +0 -430
- package/demo/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/demo/node_modules/@types/node/stream/promises.d.ts +0 -83
- package/demo/node_modules/@types/node/stream/web.d.ts +0 -352
- package/demo/node_modules/@types/node/stream.d.ts +0 -1731
- package/demo/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/demo/node_modules/@types/node/test.d.ts +0 -1113
- package/demo/node_modules/@types/node/timers/promises.d.ts +0 -93
- package/demo/node_modules/@types/node/timers.d.ts +0 -126
- package/demo/node_modules/@types/node/tls.d.ts +0 -1203
- package/demo/node_modules/@types/node/trace_events.d.ts +0 -171
- package/demo/node_modules/@types/node/tty.d.ts +0 -206
- package/demo/node_modules/@types/node/url.d.ts +0 -954
- package/demo/node_modules/@types/node/util.d.ts +0 -2075
- package/demo/node_modules/@types/node/v8.d.ts +0 -753
- package/demo/node_modules/@types/node/vm.d.ts +0 -667
- package/demo/node_modules/@types/node/wasi.d.ts +0 -160
- package/demo/node_modules/@types/node/worker_threads.d.ts +0 -692
- package/demo/node_modules/@types/node/zlib.d.ts +0 -517
- package/demo/node_modules/@types/node-fetch/LICENSE +0 -21
- package/demo/node_modules/@types/node-fetch/README.md +0 -15
- package/demo/node_modules/@types/node-fetch/externals.d.ts +0 -32
- package/demo/node_modules/@types/node-fetch/index.d.ts +0 -238
- package/demo/node_modules/@types/node-fetch/package.json +0 -83
- package/demo/node_modules/abort-controller/LICENSE +0 -21
- package/demo/node_modules/abort-controller/README.md +0 -98
- package/demo/node_modules/abort-controller/browser.js +0 -13
- package/demo/node_modules/abort-controller/browser.mjs +0 -11
- package/demo/node_modules/abort-controller/package.json +0 -97
- package/demo/node_modules/abort-controller/polyfill.js +0 -21
- package/demo/node_modules/abort-controller/polyfill.mjs +0 -19
- package/demo/node_modules/agentkeepalive/History.md +0 -268
- package/demo/node_modules/agentkeepalive/LICENSE +0 -23
- package/demo/node_modules/agentkeepalive/README.md +0 -256
- package/demo/node_modules/agentkeepalive/browser.js +0 -5
- package/demo/node_modules/agentkeepalive/index.d.ts +0 -65
- package/demo/node_modules/agentkeepalive/index.js +0 -5
- package/demo/node_modules/agentkeepalive/lib/agent.js +0 -402
- package/demo/node_modules/agentkeepalive/lib/constants.js +0 -14
- package/demo/node_modules/agentkeepalive/lib/https_agent.js +0 -51
- package/demo/node_modules/agentkeepalive/package.json +0 -56
- package/demo/node_modules/asynckit/LICENSE +0 -21
- package/demo/node_modules/asynckit/README.md +0 -233
- package/demo/node_modules/asynckit/bench.js +0 -76
- package/demo/node_modules/asynckit/index.js +0 -6
- package/demo/node_modules/asynckit/lib/abort.js +0 -29
- package/demo/node_modules/asynckit/lib/async.js +0 -34
- package/demo/node_modules/asynckit/lib/defer.js +0 -26
- package/demo/node_modules/asynckit/lib/iterate.js +0 -75
- package/demo/node_modules/asynckit/lib/readable_asynckit.js +0 -91
- package/demo/node_modules/asynckit/lib/readable_parallel.js +0 -25
- package/demo/node_modules/asynckit/lib/readable_serial.js +0 -25
- package/demo/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
- package/demo/node_modules/asynckit/lib/state.js +0 -37
- package/demo/node_modules/asynckit/lib/streamify.js +0 -141
- package/demo/node_modules/asynckit/lib/terminator.js +0 -29
- package/demo/node_modules/asynckit/package.json +0 -63
- package/demo/node_modules/asynckit/parallel.js +0 -43
- package/demo/node_modules/asynckit/serial.js +0 -17
- package/demo/node_modules/asynckit/serialOrdered.js +0 -75
- package/demo/node_modules/asynckit/stream.js +0 -21
- package/demo/node_modules/combined-stream/License +0 -19
- package/demo/node_modules/combined-stream/Readme.md +0 -138
- package/demo/node_modules/combined-stream/lib/combined_stream.js +0 -208
- package/demo/node_modules/combined-stream/package.json +0 -25
- package/demo/node_modules/combined-stream/yarn.lock +0 -17
- 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/delayed-stream/License +0 -19
- package/demo/node_modules/delayed-stream/Makefile +0 -7
- package/demo/node_modules/delayed-stream/Readme.md +0 -141
- package/demo/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
- package/demo/node_modules/delayed-stream/package.json +0 -27
- package/demo/node_modules/dotenv/CHANGELOG.md +0 -475
- package/demo/node_modules/dotenv/LICENSE +0 -23
- package/demo/node_modules/dotenv/README-es.md +0 -448
- package/demo/node_modules/dotenv/README.md +0 -728
- package/demo/node_modules/dotenv/config.d.ts +0 -1
- package/demo/node_modules/dotenv/config.js +0 -9
- package/demo/node_modules/dotenv/lib/cli-options.js +0 -11
- package/demo/node_modules/dotenv/lib/env-options.js +0 -24
- package/demo/node_modules/dotenv/lib/main.d.ts +0 -153
- package/demo/node_modules/dotenv/lib/main.js +0 -361
- package/demo/node_modules/dotenv/package.json +0 -65
- package/demo/node_modules/event-target-shim/LICENSE +0 -22
- package/demo/node_modules/event-target-shim/README.md +0 -293
- package/demo/node_modules/event-target-shim/index.d.ts +0 -399
- package/demo/node_modules/event-target-shim/package.json +0 -82
- package/demo/node_modules/form-data/License +0 -19
- package/demo/node_modules/form-data/README.md.bak +0 -358
- package/demo/node_modules/form-data/Readme.md +0 -358
- package/demo/node_modules/form-data/index.d.ts +0 -62
- package/demo/node_modules/form-data/lib/browser.js +0 -2
- package/demo/node_modules/form-data/lib/form_data.js +0 -501
- package/demo/node_modules/form-data/lib/populate.js +0 -10
- package/demo/node_modules/form-data/package.json +0 -68
- package/demo/node_modules/form-data-encoder/@type/FileLike.d.ts +0 -23
- package/demo/node_modules/form-data-encoder/@type/FormDataEncoder.d.ts +0 -160
- package/demo/node_modules/form-data-encoder/@type/FormDataLike.d.ts +0 -40
- package/demo/node_modules/form-data-encoder/@type/index.d.ts +0 -5
- package/demo/node_modules/form-data-encoder/@type/util/createBoundary.d.ts +0 -13
- package/demo/node_modules/form-data-encoder/@type/util/escapeName.d.ts +0 -11
- package/demo/node_modules/form-data-encoder/@type/util/isFileLike.d.ts +0 -28
- package/demo/node_modules/form-data-encoder/@type/util/isFormData.d.ts +0 -15
- package/demo/node_modules/form-data-encoder/@type/util/isFunction.d.ts +0 -7
- package/demo/node_modules/form-data-encoder/@type/util/isPlainObject.d.ts +0 -2
- package/demo/node_modules/form-data-encoder/@type/util/normalizeValue.d.ts +0 -11
- package/demo/node_modules/form-data-encoder/lib/cjs/FileLike.js +0 -2
- package/demo/node_modules/form-data-encoder/lib/cjs/FormDataEncoder.js +0 -126
- package/demo/node_modules/form-data-encoder/lib/cjs/FormDataLike.js +0 -2
- package/demo/node_modules/form-data-encoder/lib/cjs/index.js +0 -17
- package/demo/node_modules/form-data-encoder/lib/cjs/package.json +0 -3
- package/demo/node_modules/form-data-encoder/lib/cjs/util/createBoundary.js +0 -12
- package/demo/node_modules/form-data-encoder/lib/cjs/util/escapeName.js +0 -7
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isFileLike.js +0 -16
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isFormData.js +0 -16
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isFunction.js +0 -4
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isPlainObject.js +0 -15
- package/demo/node_modules/form-data-encoder/lib/cjs/util/normalizeValue.js +0 -11
- package/demo/node_modules/form-data-encoder/lib/esm/FileLike.js +0 -1
- package/demo/node_modules/form-data-encoder/lib/esm/FormDataEncoder.js +0 -119
- package/demo/node_modules/form-data-encoder/lib/esm/FormDataLike.js +0 -1
- package/demo/node_modules/form-data-encoder/lib/esm/index.js +0 -5
- package/demo/node_modules/form-data-encoder/lib/esm/package.json +0 -3
- package/demo/node_modules/form-data-encoder/lib/esm/util/createBoundary.js +0 -10
- package/demo/node_modules/form-data-encoder/lib/esm/util/escapeName.js +0 -5
- package/demo/node_modules/form-data-encoder/lib/esm/util/isFileLike.js +0 -9
- package/demo/node_modules/form-data-encoder/lib/esm/util/isFormData.js +0 -9
- package/demo/node_modules/form-data-encoder/lib/esm/util/isFunction.js +0 -2
- package/demo/node_modules/form-data-encoder/lib/esm/util/isPlainObject.js +0 -13
- package/demo/node_modules/form-data-encoder/lib/esm/util/normalizeValue.js +0 -9
- package/demo/node_modules/form-data-encoder/license +0 -21
- package/demo/node_modules/form-data-encoder/package.json +0 -63
- package/demo/node_modules/form-data-encoder/readme.md +0 -366
- package/demo/node_modules/formdata-node/@type/Blob.d.ts +0 -66
- package/demo/node_modules/formdata-node/@type/BlobPart.d.ts +0 -2
- package/demo/node_modules/formdata-node/@type/File.d.ts +0 -53
- package/demo/node_modules/formdata-node/@type/FormData.d.ts +0 -105
- package/demo/node_modules/formdata-node/@type/blobHelpers.d.ts +0 -9
- package/demo/node_modules/formdata-node/@type/browser.d.ts +0 -10
- package/demo/node_modules/formdata-node/@type/deprecateConstructorEntries.d.ts +0 -1
- package/demo/node_modules/formdata-node/@type/fileFromPath.d.ts +0 -55
- package/demo/node_modules/formdata-node/@type/index.d.ts +0 -3
- package/demo/node_modules/formdata-node/@type/isBlob.d.ts +0 -2
- package/demo/node_modules/formdata-node/@type/isFile.d.ts +0 -7
- package/demo/node_modules/formdata-node/@type/isFunction.d.ts +0 -1
- package/demo/node_modules/formdata-node/@type/isPlainObject.d.ts +0 -2
- package/demo/node_modules/formdata-node/lib/cjs/Blob.js +0 -122
- package/demo/node_modules/formdata-node/lib/cjs/BlobPart.js +0 -2
- package/demo/node_modules/formdata-node/lib/cjs/File.js +0 -52
- package/demo/node_modules/formdata-node/lib/cjs/FormData.js +0 -148
- package/demo/node_modules/formdata-node/lib/cjs/blobHelpers.js +0 -80
- package/demo/node_modules/formdata-node/lib/cjs/browser.js +0 -13
- package/demo/node_modules/formdata-node/lib/cjs/deprecateConstructorEntries.js +0 -6
- package/demo/node_modules/formdata-node/lib/cjs/fileFromPath.js +0 -97
- package/demo/node_modules/formdata-node/lib/cjs/index.js +0 -15
- package/demo/node_modules/formdata-node/lib/cjs/isBlob.js +0 -6
- package/demo/node_modules/formdata-node/lib/cjs/isFile.js +0 -6
- package/demo/node_modules/formdata-node/lib/cjs/isFunction.js +0 -5
- package/demo/node_modules/formdata-node/lib/cjs/isPlainObject.js +0 -15
- package/demo/node_modules/formdata-node/lib/cjs/package.json +0 -3
- package/demo/node_modules/formdata-node/lib/esm/Blob.js +0 -118
- package/demo/node_modules/formdata-node/lib/esm/BlobPart.js +0 -1
- package/demo/node_modules/formdata-node/lib/esm/File.js +0 -48
- package/demo/node_modules/formdata-node/lib/esm/FormData.js +0 -144
- package/demo/node_modules/formdata-node/lib/esm/blobHelpers.js +0 -75
- package/demo/node_modules/formdata-node/lib/esm/browser.js +0 -10
- package/demo/node_modules/formdata-node/lib/esm/deprecateConstructorEntries.js +0 -3
- package/demo/node_modules/formdata-node/lib/esm/fileFromPath.js +0 -79
- package/demo/node_modules/formdata-node/lib/esm/index.js +0 -3
- package/demo/node_modules/formdata-node/lib/esm/isBlob.js +0 -2
- package/demo/node_modules/formdata-node/lib/esm/isFile.js +0 -2
- package/demo/node_modules/formdata-node/lib/esm/isFunction.js +0 -1
- package/demo/node_modules/formdata-node/lib/esm/isPlainObject.js +0 -13
- package/demo/node_modules/formdata-node/lib/esm/package.json +0 -3
- package/demo/node_modules/formdata-node/lib/node-domexception.d.ts +0 -5
- package/demo/node_modules/formdata-node/license +0 -21
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/LICENSE +0 -22
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/README.md +0 -135
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/es5/package.json +0 -6
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/package.json +0 -101
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/polyfill/es5/package.json +0 -5
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/polyfill/package.json +0 -5
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/types/polyfill.d.ts +0 -62
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/types/ponyfill.d.ts +0 -775
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/types/tsdoc-metadata.json +0 -11
- package/demo/node_modules/formdata-node/package.json +0 -94
- package/demo/node_modules/formdata-node/readme.md +0 -444
- package/demo/node_modules/humanize-ms/History.md +0 -25
- package/demo/node_modules/humanize-ms/LICENSE +0 -17
- package/demo/node_modules/humanize-ms/README.md +0 -40
- package/demo/node_modules/humanize-ms/index.js +0 -24
- package/demo/node_modules/humanize-ms/package.json +0 -37
- 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/mime-db/HISTORY.md +0 -507
- package/demo/node_modules/mime-db/LICENSE +0 -23
- package/demo/node_modules/mime-db/README.md +0 -100
- package/demo/node_modules/mime-db/db.json +0 -8519
- package/demo/node_modules/mime-db/index.js +0 -12
- package/demo/node_modules/mime-db/package.json +0 -60
- package/demo/node_modules/mime-types/HISTORY.md +0 -397
- package/demo/node_modules/mime-types/LICENSE +0 -23
- package/demo/node_modules/mime-types/README.md +0 -113
- package/demo/node_modules/mime-types/index.js +0 -188
- package/demo/node_modules/mime-types/package.json +0 -44
- package/demo/node_modules/ms/index.js +0 -162
- package/demo/node_modules/ms/license.md +0 -21
- package/demo/node_modules/ms/package.json +0 -38
- package/demo/node_modules/ms/readme.md +0 -59
- package/demo/node_modules/node-domexception/.history/README_20210527203617.md +0 -2
- package/demo/node_modules/node-domexception/.history/README_20210527212714.md +0 -41
- package/demo/node_modules/node-domexception/.history/README_20210527213345.md +0 -36
- package/demo/node_modules/node-domexception/.history/README_20210527213411.md +0 -36
- package/demo/node_modules/node-domexception/.history/README_20210527213803.md +0 -36
- package/demo/node_modules/node-domexception/.history/README_20210527214323.md +0 -38
- package/demo/node_modules/node-domexception/.history/README_20210527214408.md +0 -38
- package/demo/node_modules/node-domexception/.history/index_20210527203842.js +0 -0
- package/demo/node_modules/node-domexception/.history/index_20210527203947.js +0 -8
- package/demo/node_modules/node-domexception/.history/index_20210527204259.js +0 -9
- package/demo/node_modules/node-domexception/.history/index_20210527204418.js +0 -9
- package/demo/node_modules/node-domexception/.history/index_20210527204756.js +0 -11
- package/demo/node_modules/node-domexception/.history/index_20210527204833.js +0 -11
- package/demo/node_modules/node-domexception/.history/index_20210527211208.js +0 -15
- package/demo/node_modules/node-domexception/.history/index_20210527211248.js +0 -15
- package/demo/node_modules/node-domexception/.history/index_20210527212722.js +0 -23
- package/demo/node_modules/node-domexception/.history/index_20210527212731.js +0 -23
- package/demo/node_modules/node-domexception/.history/index_20210527212746.js +0 -15
- package/demo/node_modules/node-domexception/.history/index_20210527212900.js +0 -16
- package/demo/node_modules/node-domexception/.history/index_20210527213022.js +0 -16
- package/demo/node_modules/node-domexception/.history/index_20210527213822.js +0 -16
- package/demo/node_modules/node-domexception/.history/index_20210527213843.js +0 -17
- package/demo/node_modules/node-domexception/.history/index_20210527213852.js +0 -17
- package/demo/node_modules/node-domexception/.history/index_20210527213910.js +0 -16
- package/demo/node_modules/node-domexception/.history/index_20210527214034.js +0 -16
- package/demo/node_modules/node-domexception/.history/index_20210527214643.js +0 -41
- package/demo/node_modules/node-domexception/.history/index_20210527214654.js +0 -41
- package/demo/node_modules/node-domexception/.history/index_20210527214700.js +0 -16
- package/demo/node_modules/node-domexception/.history/package_20210527203733.json +0 -19
- package/demo/node_modules/node-domexception/.history/package_20210527203825.json +0 -16
- package/demo/node_modules/node-domexception/.history/package_20210527204621.json +0 -19
- package/demo/node_modules/node-domexception/.history/package_20210527204913.json +0 -25
- package/demo/node_modules/node-domexception/.history/package_20210527204925.json +0 -25
- package/demo/node_modules/node-domexception/.history/package_20210527205145.json +0 -29
- package/demo/node_modules/node-domexception/.history/package_20210527205156.json +0 -29
- package/demo/node_modules/node-domexception/.history/test_20210527205603.js +0 -0
- package/demo/node_modules/node-domexception/.history/test_20210527205957.js +0 -3
- package/demo/node_modules/node-domexception/.history/test_20210527210021.js +0 -3
- package/demo/node_modules/node-domexception/LICENSE +0 -21
- package/demo/node_modules/node-domexception/README.md +0 -46
- package/demo/node_modules/node-domexception/index.js +0 -16
- package/demo/node_modules/node-domexception/package.json +0 -29
- package/demo/node_modules/node-fetch/LICENSE.md +0 -22
- package/demo/node_modules/node-fetch/README.md +0 -634
- package/demo/node_modules/node-fetch/browser.js +0 -25
- package/demo/node_modules/node-fetch/lib/index.es.js +0 -1777
- package/demo/node_modules/node-fetch/lib/index.js +0 -1787
- package/demo/node_modules/node-fetch/lib/index.mjs +0 -1775
- package/demo/node_modules/node-fetch/package.json +0 -89
- 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/node_modules/tr46/index.js +0 -193
- package/demo/node_modules/tr46/lib/.gitkeep +0 -0
- package/demo/node_modules/tr46/lib/mappingTable.json +0 -1
- package/demo/node_modules/tr46/package.json +0 -31
- package/demo/node_modules/undici-types/README.md +0 -6
- package/demo/node_modules/undici-types/agent.d.ts +0 -31
- package/demo/node_modules/undici-types/api.d.ts +0 -43
- package/demo/node_modules/undici-types/balanced-pool.d.ts +0 -18
- package/demo/node_modules/undici-types/cache.d.ts +0 -36
- package/demo/node_modules/undici-types/client.d.ts +0 -97
- package/demo/node_modules/undici-types/connector.d.ts +0 -34
- package/demo/node_modules/undici-types/content-type.d.ts +0 -21
- package/demo/node_modules/undici-types/cookies.d.ts +0 -28
- package/demo/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
- package/demo/node_modules/undici-types/dispatcher.d.ts +0 -241
- package/demo/node_modules/undici-types/errors.d.ts +0 -128
- package/demo/node_modules/undici-types/fetch.d.ts +0 -209
- package/demo/node_modules/undici-types/file.d.ts +0 -39
- package/demo/node_modules/undici-types/filereader.d.ts +0 -54
- package/demo/node_modules/undici-types/formdata.d.ts +0 -108
- package/demo/node_modules/undici-types/global-dispatcher.d.ts +0 -9
- package/demo/node_modules/undici-types/global-origin.d.ts +0 -7
- package/demo/node_modules/undici-types/handlers.d.ts +0 -9
- package/demo/node_modules/undici-types/header.d.ts +0 -4
- package/demo/node_modules/undici-types/index.d.ts +0 -63
- package/demo/node_modules/undici-types/interceptors.d.ts +0 -5
- package/demo/node_modules/undici-types/mock-agent.d.ts +0 -50
- package/demo/node_modules/undici-types/mock-client.d.ts +0 -25
- package/demo/node_modules/undici-types/mock-errors.d.ts +0 -12
- package/demo/node_modules/undici-types/mock-interceptor.d.ts +0 -93
- package/demo/node_modules/undici-types/mock-pool.d.ts +0 -25
- package/demo/node_modules/undici-types/package.json +0 -55
- package/demo/node_modules/undici-types/patch.d.ts +0 -71
- package/demo/node_modules/undici-types/pool-stats.d.ts +0 -19
- package/demo/node_modules/undici-types/pool.d.ts +0 -28
- package/demo/node_modules/undici-types/proxy-agent.d.ts +0 -30
- package/demo/node_modules/undici-types/readable.d.ts +0 -61
- package/demo/node_modules/undici-types/webidl.d.ts +0 -220
- package/demo/node_modules/undici-types/websocket.d.ts +0 -131
- package/demo/node_modules/web-streams-polyfill/LICENSE +0 -22
- package/demo/node_modules/web-streams-polyfill/README.md +0 -110
- package/demo/node_modules/web-streams-polyfill/es2018/package.json +0 -14
- package/demo/node_modules/web-streams-polyfill/es6/package.json +0 -14
- package/demo/node_modules/web-streams-polyfill/package.json +0 -83
- package/demo/node_modules/web-streams-polyfill/ponyfill/es2018/package.json +0 -13
- package/demo/node_modules/web-streams-polyfill/ponyfill/es6/package.json +0 -13
- package/demo/node_modules/web-streams-polyfill/ponyfill/package.json +0 -13
- package/demo/node_modules/webidl-conversions/LICENSE.md +0 -12
- package/demo/node_modules/webidl-conversions/README.md +0 -53
- package/demo/node_modules/webidl-conversions/lib/index.js +0 -189
- package/demo/node_modules/webidl-conversions/package.json +0 -23
- package/demo/node_modules/whatwg-url/LICENSE.txt +0 -21
- package/demo/node_modules/whatwg-url/README.md +0 -67
- package/demo/node_modules/whatwg-url/lib/URL-impl.js +0 -200
- package/demo/node_modules/whatwg-url/lib/URL.js +0 -196
- package/demo/node_modules/whatwg-url/lib/public-api.js +0 -11
- package/demo/node_modules/whatwg-url/lib/url-state-machine.js +0 -1297
- package/demo/node_modules/whatwg-url/lib/utils.js +0 -20
- package/demo/node_modules/whatwg-url/package.json +0 -32
- package/demo/watson.png +0 -0
|
@@ -1,2177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const openai_1 = __importDefault(require("openai"));
|
|
7
|
-
const error_1 = require("openai/error");
|
|
8
|
-
const stream_1 = require("stream");
|
|
9
|
-
const completions_1 = require("openai/resources/beta/chat/completions");
|
|
10
|
-
const node_fetch_1 = require("node-fetch");
|
|
11
|
-
const chatCompletionUtils_1 = require("./chatCompletionUtils.js");
|
|
12
|
-
/**
|
|
13
|
-
* Creates a mock `fetch` function and a `handleRequest` function for intercepting `fetch` calls.
|
|
14
|
-
*
|
|
15
|
-
* You call `handleRequest` with a callback function that handles the next `fetch` call.
|
|
16
|
-
* It returns a Promise that:
|
|
17
|
-
* - waits for the next call to `fetch`
|
|
18
|
-
* - calls the callback with the `fetch` arguments
|
|
19
|
-
* - resolves `fetch` with the callback output
|
|
20
|
-
*/
|
|
21
|
-
function mockFetch() {
|
|
22
|
-
const fetchQueue = [];
|
|
23
|
-
const handlerQueue = [];
|
|
24
|
-
const enqueueHandler = () => {
|
|
25
|
-
handlerQueue.push(new Promise((resolve) => {
|
|
26
|
-
fetchQueue.push((handle) => {
|
|
27
|
-
enqueueHandler();
|
|
28
|
-
resolve(handle);
|
|
29
|
-
});
|
|
30
|
-
}));
|
|
31
|
-
};
|
|
32
|
-
enqueueHandler();
|
|
33
|
-
async function fetch(req, init) {
|
|
34
|
-
const handler = await handlerQueue.shift();
|
|
35
|
-
if (!handler)
|
|
36
|
-
throw new Error('expected handler to be defined');
|
|
37
|
-
const signal = init?.signal;
|
|
38
|
-
if (!signal)
|
|
39
|
-
return await handler(req, init);
|
|
40
|
-
return await Promise.race([
|
|
41
|
-
handler(req, init),
|
|
42
|
-
new Promise((resolve, reject) => {
|
|
43
|
-
if (signal.aborted) {
|
|
44
|
-
// @ts-ignore does exist in Node
|
|
45
|
-
reject(new DOMException('The user aborted a request.', 'AbortError'));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
signal.addEventListener('abort', (e) => {
|
|
49
|
-
// @ts-ignore does exist in Node
|
|
50
|
-
reject(new DOMException('The user aborted a request.', 'AbortError'));
|
|
51
|
-
});
|
|
52
|
-
}),
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
function handleRequest(handle) {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
fetchQueue.shift()?.(async (req, init) => {
|
|
58
|
-
try {
|
|
59
|
-
return await handle(req, init);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
reject(err);
|
|
63
|
-
return err;
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
resolve();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return { fetch, handleRequest };
|
|
72
|
-
}
|
|
73
|
-
// mockChatCompletionFetch is like mockFetch, but with better a more convenient handleRequest to mock
|
|
74
|
-
// chat completion request/responses.
|
|
75
|
-
function mockChatCompletionFetch() {
|
|
76
|
-
const { fetch, handleRequest: handleRawRequest } = mockFetch();
|
|
77
|
-
function handleRequest(handler) {
|
|
78
|
-
return handleRawRequest(async (req, init) => {
|
|
79
|
-
const rawBody = init?.body;
|
|
80
|
-
if (typeof rawBody !== 'string')
|
|
81
|
-
throw new Error(`expected init.body to be a string`);
|
|
82
|
-
const body = JSON.parse(rawBody);
|
|
83
|
-
return new node_fetch_1.Response(JSON.stringify(await handler(body)), {
|
|
84
|
-
headers: { 'Content-Type': 'application/json' },
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return { fetch, handleRequest };
|
|
89
|
-
}
|
|
90
|
-
// mockStreamingChatCompletionFetch is like mockFetch, but with better a more convenient handleRequest to mock
|
|
91
|
-
// streaming chat completion request/responses.
|
|
92
|
-
function mockStreamingChatCompletionFetch() {
|
|
93
|
-
const { fetch, handleRequest: handleRawRequest } = mockFetch();
|
|
94
|
-
function handleRequest(handler) {
|
|
95
|
-
return handleRawRequest(async (req, init) => {
|
|
96
|
-
const rawBody = init?.body;
|
|
97
|
-
if (typeof rawBody !== 'string')
|
|
98
|
-
throw new Error(`expected init.body to be a string`);
|
|
99
|
-
const body = JSON.parse(rawBody);
|
|
100
|
-
const stream = new stream_1.PassThrough();
|
|
101
|
-
(async () => {
|
|
102
|
-
for await (const chunk of handler(body)) {
|
|
103
|
-
stream.write(`data: ${JSON.stringify(chunk)}\n\n`);
|
|
104
|
-
}
|
|
105
|
-
stream.end(`data: [DONE]\n\n`);
|
|
106
|
-
})();
|
|
107
|
-
return new node_fetch_1.Response(stream, {
|
|
108
|
-
headers: {
|
|
109
|
-
'Content-Type': 'text/event-stream',
|
|
110
|
-
'Transfer-Encoding': 'chunked',
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return { fetch, handleRequest };
|
|
116
|
-
}
|
|
117
|
-
// contentChoiceDeltas returns an async iterator which mocks a delta stream of a by splitting the
|
|
118
|
-
// argument into chunks separated by whitespace.
|
|
119
|
-
function* contentChoiceDeltas(content, { index = 0, role = 'assistant', } = {}) {
|
|
120
|
-
const deltas = content.split(/\s+/g);
|
|
121
|
-
for (let i = 0; i < deltas.length; i++) {
|
|
122
|
-
yield {
|
|
123
|
-
index,
|
|
124
|
-
finish_reason: i === deltas.length - 1 ? 'stop' : null,
|
|
125
|
-
logprobs: null,
|
|
126
|
-
delta: {
|
|
127
|
-
role,
|
|
128
|
-
content: deltas[i] ? `${deltas[i]}${i === deltas.length - 1 ? '' : ' '}` : null,
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// functionCallDeltas returns an async iterator which mocks a delta stream of a functionCall by splitting
|
|
134
|
-
// the argument into chunks separated by whitespace.
|
|
135
|
-
function* functionCallDeltas(args, { index = 0, id = '123', name, role = 'assistant', }) {
|
|
136
|
-
const deltas = args.split(/\s+/g);
|
|
137
|
-
for (let i = 0; i < deltas.length; i++) {
|
|
138
|
-
yield {
|
|
139
|
-
index,
|
|
140
|
-
finish_reason: i === deltas.length - 1 ? 'function_call' : null,
|
|
141
|
-
delta: {
|
|
142
|
-
role,
|
|
143
|
-
tool_calls: [
|
|
144
|
-
{
|
|
145
|
-
type: 'function',
|
|
146
|
-
index: 0,
|
|
147
|
-
id,
|
|
148
|
-
function: {
|
|
149
|
-
arguments: `${deltas[i] || ''}${i === deltas.length - 1 ? '' : ' '}`,
|
|
150
|
-
...(i === deltas.length - 1 ? { name } : null),
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
class RunnerListener {
|
|
159
|
-
constructor(runner) {
|
|
160
|
-
this.runner = runner;
|
|
161
|
-
this.contents = [];
|
|
162
|
-
this.messages = [];
|
|
163
|
-
this.chatCompletions = [];
|
|
164
|
-
this.functionCalls = [];
|
|
165
|
-
this.functionCallResults = [];
|
|
166
|
-
this.finalContent = null;
|
|
167
|
-
this.gotConnect = false;
|
|
168
|
-
this.gotAbort = false;
|
|
169
|
-
this.gotEnd = false;
|
|
170
|
-
this.onceMessageCallCount = 0;
|
|
171
|
-
runner
|
|
172
|
-
.on('connect', () => (this.gotConnect = true))
|
|
173
|
-
.on('content', (content) => this.contents.push(content))
|
|
174
|
-
.on('message', (message) => this.messages.push(message))
|
|
175
|
-
.on('chatCompletion', (completion) => this.chatCompletions.push(completion))
|
|
176
|
-
.on('functionCall', (functionCall) => this.functionCalls.push(functionCall))
|
|
177
|
-
.on('functionCallResult', (result) => this.functionCallResults.push(result))
|
|
178
|
-
.on('finalContent', (content) => (this.finalContent = content))
|
|
179
|
-
.on('finalMessage', (message) => (this.finalMessage = message))
|
|
180
|
-
.on('finalChatCompletion', (completion) => (this.finalChatCompletion = completion))
|
|
181
|
-
.on('finalFunctionCall', (functionCall) => (this.finalFunctionCall = functionCall))
|
|
182
|
-
.on('finalFunctionCallResult', (result) => (this.finalFunctionCallResult = result))
|
|
183
|
-
.on('totalUsage', (usage) => (this.totalUsage = usage))
|
|
184
|
-
.on('error', (error) => (this.error = error))
|
|
185
|
-
.on('abort', (error) => ((this.error = error), (this.gotAbort = true)))
|
|
186
|
-
.on('end', () => (this.gotEnd = true))
|
|
187
|
-
.once('message', () => this.onceMessageCallCount++);
|
|
188
|
-
}
|
|
189
|
-
async sanityCheck({ error } = {}) {
|
|
190
|
-
expect(this.onceMessageCallCount).toBeLessThanOrEqual(1);
|
|
191
|
-
expect(this.gotAbort).toEqual(this.runner.aborted);
|
|
192
|
-
if (this.runner.aborted)
|
|
193
|
-
expect(this.runner.errored).toBe(true);
|
|
194
|
-
if (error) {
|
|
195
|
-
expect(this.error?.message).toEqual(error);
|
|
196
|
-
expect(this.runner.errored).toBe(true);
|
|
197
|
-
await expect(this.runner.finalChatCompletion()).rejects.toThrow(error);
|
|
198
|
-
await expect(this.runner.finalMessage()).rejects.toThrow(error);
|
|
199
|
-
await expect(this.runner.finalContent()).rejects.toThrow(error);
|
|
200
|
-
await expect(this.runner.finalFunctionCall()).rejects.toThrow(error);
|
|
201
|
-
await expect(this.runner.finalFunctionCallResult()).rejects.toThrow(error);
|
|
202
|
-
await expect(this.runner.totalUsage()).rejects.toThrow(error);
|
|
203
|
-
await expect(this.runner.done()).rejects.toThrow(error);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
expect(this.error).toBeUndefined();
|
|
207
|
-
expect(this.runner.errored).toBe(false);
|
|
208
|
-
}
|
|
209
|
-
if (!this.gotConnect) {
|
|
210
|
-
expect(this.contents).toEqual([]);
|
|
211
|
-
expect(this.messages).toEqual([]);
|
|
212
|
-
expect(this.chatCompletions).toEqual([]);
|
|
213
|
-
expect(this.functionCalls).toEqual([]);
|
|
214
|
-
expect(this.functionCallResults).toEqual([]);
|
|
215
|
-
expect(this.finalContent).toBeUndefined();
|
|
216
|
-
expect(this.finalMessage).toBeUndefined();
|
|
217
|
-
expect(this.finalChatCompletion).toBeUndefined();
|
|
218
|
-
expect(this.finalFunctionCall).toBeUndefined();
|
|
219
|
-
expect(this.finalFunctionCallResult).toBeUndefined();
|
|
220
|
-
expect(this.totalUsage).toBeUndefined();
|
|
221
|
-
expect(this.gotEnd).toBe(true);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (error)
|
|
225
|
-
return;
|
|
226
|
-
const expectedContents = this.messages
|
|
227
|
-
.filter(chatCompletionUtils_1.isAssistantMessage)
|
|
228
|
-
.map((m) => m.content)
|
|
229
|
-
.filter(Boolean);
|
|
230
|
-
expect(this.contents).toEqual(expectedContents);
|
|
231
|
-
expect(this.finalMessage).toEqual([...this.messages].reverse().find((x) => x.role === 'assistant'));
|
|
232
|
-
expect(await this.runner.finalMessage()).toEqual(this.finalMessage);
|
|
233
|
-
expect(this.finalContent).toEqual(expectedContents[expectedContents.length - 1] ?? null);
|
|
234
|
-
expect(await this.runner.finalContent()).toEqual(this.finalContent);
|
|
235
|
-
expect(this.finalChatCompletion).toEqual(this.chatCompletions[this.chatCompletions.length - 1]);
|
|
236
|
-
expect(await this.runner.finalChatCompletion()).toEqual(this.finalChatCompletion);
|
|
237
|
-
expect(this.finalFunctionCall).toEqual(this.functionCalls[this.functionCalls.length - 1]);
|
|
238
|
-
expect(await this.runner.finalFunctionCall()).toEqual(this.finalFunctionCall);
|
|
239
|
-
expect(this.finalFunctionCallResult).toEqual(this.functionCallResults[this.functionCallResults.length - 1]);
|
|
240
|
-
expect(await this.runner.finalFunctionCallResult()).toEqual(this.finalFunctionCallResult);
|
|
241
|
-
expect(this.chatCompletions).toEqual(this.runner.allChatCompletions());
|
|
242
|
-
expect(this.messages).toEqual(this.runner.messages.slice(-this.messages.length));
|
|
243
|
-
if (this.chatCompletions.some((c) => c.usage)) {
|
|
244
|
-
const totalUsage = {
|
|
245
|
-
completion_tokens: 0,
|
|
246
|
-
prompt_tokens: 0,
|
|
247
|
-
total_tokens: 0,
|
|
248
|
-
};
|
|
249
|
-
for (const { usage } of this.chatCompletions) {
|
|
250
|
-
if (usage) {
|
|
251
|
-
totalUsage.completion_tokens += usage.completion_tokens;
|
|
252
|
-
totalUsage.prompt_tokens += usage.prompt_tokens;
|
|
253
|
-
totalUsage.total_tokens += usage.total_tokens;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
expect(this.totalUsage).toEqual(totalUsage);
|
|
257
|
-
expect(await this.runner.totalUsage()).toEqual(totalUsage);
|
|
258
|
-
}
|
|
259
|
-
expect(this.gotEnd).toBe(true);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
class StreamingRunnerListener {
|
|
263
|
-
constructor(runner) {
|
|
264
|
-
this.runner = runner;
|
|
265
|
-
this.eventChunks = [];
|
|
266
|
-
this.eventContents = [];
|
|
267
|
-
this.eventMessages = [];
|
|
268
|
-
this.eventChatCompletions = [];
|
|
269
|
-
this.eventFunctionCalls = [];
|
|
270
|
-
this.eventFunctionCallResults = [];
|
|
271
|
-
this.finalContent = null;
|
|
272
|
-
this.gotConnect = false;
|
|
273
|
-
this.gotEnd = false;
|
|
274
|
-
runner
|
|
275
|
-
.on('connect', () => (this.gotConnect = true))
|
|
276
|
-
.on('chunk', (chunk) => this.eventChunks.push(chunk))
|
|
277
|
-
.on('content', (delta, snapshot) => this.eventContents.push([delta, snapshot]))
|
|
278
|
-
.on('message', (message) => this.eventMessages.push(message))
|
|
279
|
-
.on('chatCompletion', (completion) => this.eventChatCompletions.push(completion))
|
|
280
|
-
.on('functionCall', (functionCall) => this.eventFunctionCalls.push(functionCall))
|
|
281
|
-
.on('functionCallResult', (result) => this.eventFunctionCallResults.push(result))
|
|
282
|
-
.on('finalContent', (content) => (this.finalContent = content))
|
|
283
|
-
.on('finalMessage', (message) => (this.finalMessage = message))
|
|
284
|
-
.on('finalChatCompletion', (completion) => (this.finalChatCompletion = completion))
|
|
285
|
-
.on('finalFunctionCall', (functionCall) => (this.finalFunctionCall = functionCall))
|
|
286
|
-
.on('finalFunctionCallResult', (result) => (this.finalFunctionCallResult = result))
|
|
287
|
-
.on('error', (error) => (this.error = error))
|
|
288
|
-
.on('abort', (abort) => (this.error = abort))
|
|
289
|
-
.on('end', () => (this.gotEnd = true));
|
|
290
|
-
}
|
|
291
|
-
async sanityCheck({ error } = {}) {
|
|
292
|
-
if (error) {
|
|
293
|
-
expect(this.error?.message).toEqual(error);
|
|
294
|
-
expect(this.runner.errored).toBe(true);
|
|
295
|
-
await expect(this.runner.finalChatCompletion()).rejects.toThrow(error);
|
|
296
|
-
await expect(this.runner.finalMessage()).rejects.toThrow(error);
|
|
297
|
-
await expect(this.runner.finalContent()).rejects.toThrow(error);
|
|
298
|
-
await expect(this.runner.finalFunctionCall()).rejects.toThrow(error);
|
|
299
|
-
await expect(this.runner.finalFunctionCallResult()).rejects.toThrow(error);
|
|
300
|
-
await expect(this.runner.done()).rejects.toThrow(error);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
expect(this.error).toBeUndefined();
|
|
304
|
-
expect(this.runner.errored).toBe(false);
|
|
305
|
-
}
|
|
306
|
-
if (!this.gotConnect) {
|
|
307
|
-
expect(this.eventContents).toEqual([]);
|
|
308
|
-
expect(this.eventMessages).toEqual([]);
|
|
309
|
-
expect(this.eventChatCompletions).toEqual([]);
|
|
310
|
-
expect(this.eventFunctionCalls).toEqual([]);
|
|
311
|
-
expect(this.eventFunctionCallResults).toEqual([]);
|
|
312
|
-
expect(this.finalContent).toBeUndefined();
|
|
313
|
-
expect(this.finalMessage).toBeUndefined();
|
|
314
|
-
expect(this.finalChatCompletion).toBeUndefined();
|
|
315
|
-
expect(this.finalFunctionCall).toBeUndefined();
|
|
316
|
-
expect(this.finalFunctionCallResult).toBeUndefined();
|
|
317
|
-
expect(this.gotEnd).toBe(true);
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
if (error)
|
|
321
|
-
return;
|
|
322
|
-
if (this.eventContents.length)
|
|
323
|
-
expect(this.eventChunks.length).toBeGreaterThan(0);
|
|
324
|
-
expect(this.finalMessage).toEqual([...this.eventMessages].reverse().find((x) => x.role === 'assistant'));
|
|
325
|
-
expect(await this.runner.finalMessage()).toEqual(this.finalMessage);
|
|
326
|
-
expect(this.finalContent).toEqual(this.eventContents[this.eventContents.length - 1]?.[1] ?? null);
|
|
327
|
-
expect(await this.runner.finalContent()).toEqual(this.finalContent);
|
|
328
|
-
expect(this.finalChatCompletion).toEqual(this.eventChatCompletions[this.eventChatCompletions.length - 1]);
|
|
329
|
-
expect(await this.runner.finalChatCompletion()).toEqual(this.finalChatCompletion);
|
|
330
|
-
expect(this.finalFunctionCall).toEqual(this.eventFunctionCalls[this.eventFunctionCalls.length - 1]);
|
|
331
|
-
expect(await this.runner.finalFunctionCall()).toEqual(this.finalFunctionCall);
|
|
332
|
-
expect(this.finalFunctionCallResult).toEqual(this.eventFunctionCallResults[this.eventFunctionCallResults.length - 1]);
|
|
333
|
-
expect(await this.runner.finalFunctionCallResult()).toEqual(this.finalFunctionCallResult);
|
|
334
|
-
expect(this.eventChatCompletions).toEqual(this.runner.allChatCompletions());
|
|
335
|
-
expect(this.eventMessages).toEqual(this.runner.messages.slice(-this.eventMessages.length));
|
|
336
|
-
if (error) {
|
|
337
|
-
expect(this.error?.message).toEqual(error);
|
|
338
|
-
expect(this.runner.errored).toBe(true);
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
expect(this.error).toBeUndefined();
|
|
342
|
-
expect(this.runner.errored).toBe(false);
|
|
343
|
-
}
|
|
344
|
-
expect(this.gotEnd).toBe(true);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
function _typeTests() {
|
|
348
|
-
const openai = new openai_1.default();
|
|
349
|
-
openai.beta.chat.completions.runTools({
|
|
350
|
-
messages: [
|
|
351
|
-
{ role: 'user', content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}' },
|
|
352
|
-
],
|
|
353
|
-
model: 'gpt-3.5-turbo',
|
|
354
|
-
tools: [
|
|
355
|
-
{
|
|
356
|
-
type: 'function',
|
|
357
|
-
function: {
|
|
358
|
-
name: 'numProperties',
|
|
359
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
360
|
-
parameters: { type: 'object' },
|
|
361
|
-
parse: (str) => {
|
|
362
|
-
const result = JSON.parse(str);
|
|
363
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
364
|
-
throw new Error('must be an object');
|
|
365
|
-
}
|
|
366
|
-
return result;
|
|
367
|
-
},
|
|
368
|
-
description: 'gets the number of properties on an object',
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
type: 'function',
|
|
373
|
-
function: {
|
|
374
|
-
function: (str) => String(str.length),
|
|
375
|
-
parameters: { type: 'string' },
|
|
376
|
-
description: 'gets the length of a string',
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
type: 'function',
|
|
381
|
-
// @ts-expect-error function must accept string if parse is omitted
|
|
382
|
-
function: {
|
|
383
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
384
|
-
parameters: { type: 'object' },
|
|
385
|
-
description: 'gets the number of properties on an object',
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
],
|
|
389
|
-
});
|
|
390
|
-
openai.beta.chat.completions.runTools({
|
|
391
|
-
messages: [
|
|
392
|
-
{ role: 'user', content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}' },
|
|
393
|
-
],
|
|
394
|
-
model: 'gpt-3.5-turbo',
|
|
395
|
-
tools: [
|
|
396
|
-
new completions_1.ParsingToolFunction({
|
|
397
|
-
name: 'numProperties',
|
|
398
|
-
// @ts-expect-error parse and function don't match
|
|
399
|
-
parse: (str) => str,
|
|
400
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
401
|
-
parameters: { type: 'object' },
|
|
402
|
-
description: 'gets the number of properties on an object',
|
|
403
|
-
}),
|
|
404
|
-
],
|
|
405
|
-
});
|
|
406
|
-
openai.beta.chat.completions.runTools({
|
|
407
|
-
messages: [
|
|
408
|
-
{ role: 'user', content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}' },
|
|
409
|
-
],
|
|
410
|
-
model: 'gpt-3.5-turbo',
|
|
411
|
-
tools: [
|
|
412
|
-
new completions_1.ParsingToolFunction({
|
|
413
|
-
name: 'numProperties',
|
|
414
|
-
parse: (str) => {
|
|
415
|
-
const result = JSON.parse(str);
|
|
416
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
417
|
-
throw new Error('must be an object');
|
|
418
|
-
}
|
|
419
|
-
return result;
|
|
420
|
-
},
|
|
421
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
422
|
-
parameters: { type: 'object' },
|
|
423
|
-
description: 'gets the number of properties on an object',
|
|
424
|
-
}),
|
|
425
|
-
new completions_1.ParsingToolFunction({
|
|
426
|
-
name: 'keys',
|
|
427
|
-
parse: (str) => {
|
|
428
|
-
const result = JSON.parse(str);
|
|
429
|
-
if (!(result instanceof Object)) {
|
|
430
|
-
throw new Error('must be an Object');
|
|
431
|
-
}
|
|
432
|
-
return result;
|
|
433
|
-
},
|
|
434
|
-
function: (obj) => Object.keys(obj).join(', '),
|
|
435
|
-
parameters: { type: 'object' },
|
|
436
|
-
description: 'gets the number of properties on an object',
|
|
437
|
-
}),
|
|
438
|
-
new completions_1.ParsingToolFunction({
|
|
439
|
-
name: 'len2',
|
|
440
|
-
// @ts-expect-error parse and function don't match
|
|
441
|
-
parse: (str) => str,
|
|
442
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
443
|
-
parameters: { type: 'object' },
|
|
444
|
-
description: 'gets the number of properties on an object',
|
|
445
|
-
}),
|
|
446
|
-
],
|
|
447
|
-
});
|
|
448
|
-
openai.beta.chat.completions.runTools({
|
|
449
|
-
messages: [
|
|
450
|
-
{ role: 'user', content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}' },
|
|
451
|
-
],
|
|
452
|
-
model: 'gpt-3.5-turbo',
|
|
453
|
-
// @ts-ignore error occurs here in TS 4
|
|
454
|
-
tools: [
|
|
455
|
-
{
|
|
456
|
-
type: 'function',
|
|
457
|
-
function: {
|
|
458
|
-
name: 'numProperties',
|
|
459
|
-
parse: (str) => {
|
|
460
|
-
const result = JSON.parse(str);
|
|
461
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
462
|
-
throw new Error('must be an object');
|
|
463
|
-
}
|
|
464
|
-
return result;
|
|
465
|
-
},
|
|
466
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
467
|
-
parameters: { type: 'object' },
|
|
468
|
-
description: 'gets the number of properties on an object',
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
type: 'function',
|
|
473
|
-
function: {
|
|
474
|
-
name: 'keys',
|
|
475
|
-
parse: (str) => {
|
|
476
|
-
const result = JSON.parse(str);
|
|
477
|
-
if (!(result instanceof Object)) {
|
|
478
|
-
throw new Error('must be an Object');
|
|
479
|
-
}
|
|
480
|
-
return result;
|
|
481
|
-
},
|
|
482
|
-
function: (obj) => Object.keys(obj).join(', '),
|
|
483
|
-
parameters: { type: 'object' },
|
|
484
|
-
description: 'gets the number of properties on an object',
|
|
485
|
-
},
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
type: 'function',
|
|
489
|
-
function: {
|
|
490
|
-
name: 'len2',
|
|
491
|
-
parse: (str) => str,
|
|
492
|
-
// @ts-ignore error occurs here in TS 5
|
|
493
|
-
// function input doesn't match parse output
|
|
494
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
495
|
-
parameters: { type: 'object' },
|
|
496
|
-
description: 'gets the number of properties on an object',
|
|
497
|
-
},
|
|
498
|
-
},
|
|
499
|
-
],
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
describe('resource completions', () => {
|
|
503
|
-
describe('runTools with stream: false', () => {
|
|
504
|
-
test('successful flow', async () => {
|
|
505
|
-
const { fetch, handleRequest } = mockChatCompletionFetch();
|
|
506
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
507
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
508
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
509
|
-
model: 'gpt-3.5-turbo',
|
|
510
|
-
tools: [
|
|
511
|
-
{
|
|
512
|
-
type: 'function',
|
|
513
|
-
function: {
|
|
514
|
-
function: function getWeather() {
|
|
515
|
-
return `it's raining`;
|
|
516
|
-
},
|
|
517
|
-
parameters: {},
|
|
518
|
-
description: 'gets the weather',
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
],
|
|
522
|
-
});
|
|
523
|
-
const listener = new RunnerListener(runner);
|
|
524
|
-
await handleRequest(async (request) => {
|
|
525
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
526
|
-
return {
|
|
527
|
-
id: '1',
|
|
528
|
-
choices: [
|
|
529
|
-
{
|
|
530
|
-
index: 0,
|
|
531
|
-
finish_reason: 'function_call',
|
|
532
|
-
logprobs: null,
|
|
533
|
-
message: {
|
|
534
|
-
role: 'assistant',
|
|
535
|
-
content: null,
|
|
536
|
-
tool_calls: [
|
|
537
|
-
{
|
|
538
|
-
type: 'function',
|
|
539
|
-
id: '123',
|
|
540
|
-
function: {
|
|
541
|
-
arguments: '',
|
|
542
|
-
name: 'getWeather',
|
|
543
|
-
},
|
|
544
|
-
},
|
|
545
|
-
],
|
|
546
|
-
},
|
|
547
|
-
},
|
|
548
|
-
],
|
|
549
|
-
created: Math.floor(Date.now() / 1000),
|
|
550
|
-
model: 'gpt-3.5-turbo',
|
|
551
|
-
object: 'chat.completion',
|
|
552
|
-
};
|
|
553
|
-
});
|
|
554
|
-
await handleRequest(async (request) => {
|
|
555
|
-
expect(request.messages).toEqual([
|
|
556
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
557
|
-
{
|
|
558
|
-
role: 'assistant',
|
|
559
|
-
content: null,
|
|
560
|
-
tool_calls: [
|
|
561
|
-
{
|
|
562
|
-
type: 'function',
|
|
563
|
-
id: '123',
|
|
564
|
-
function: {
|
|
565
|
-
arguments: '',
|
|
566
|
-
name: 'getWeather',
|
|
567
|
-
},
|
|
568
|
-
},
|
|
569
|
-
],
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
role: 'tool',
|
|
573
|
-
content: `it's raining`,
|
|
574
|
-
tool_call_id: '123',
|
|
575
|
-
},
|
|
576
|
-
]);
|
|
577
|
-
return {
|
|
578
|
-
id: '2',
|
|
579
|
-
choices: [
|
|
580
|
-
{
|
|
581
|
-
index: 0,
|
|
582
|
-
finish_reason: 'stop',
|
|
583
|
-
logprobs: null,
|
|
584
|
-
message: {
|
|
585
|
-
role: 'assistant',
|
|
586
|
-
content: `it's raining`,
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
],
|
|
590
|
-
created: Math.floor(Date.now() / 1000),
|
|
591
|
-
model: 'gpt-3.5-turbo',
|
|
592
|
-
object: 'chat.completion',
|
|
593
|
-
};
|
|
594
|
-
});
|
|
595
|
-
await runner.done();
|
|
596
|
-
expect(listener.messages).toEqual([
|
|
597
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
598
|
-
{
|
|
599
|
-
role: 'assistant',
|
|
600
|
-
content: null,
|
|
601
|
-
tool_calls: [
|
|
602
|
-
{
|
|
603
|
-
type: 'function',
|
|
604
|
-
id: '123',
|
|
605
|
-
function: {
|
|
606
|
-
arguments: '',
|
|
607
|
-
name: 'getWeather',
|
|
608
|
-
},
|
|
609
|
-
},
|
|
610
|
-
],
|
|
611
|
-
},
|
|
612
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '123' },
|
|
613
|
-
{ role: 'assistant', content: "it's raining" },
|
|
614
|
-
]);
|
|
615
|
-
expect(listener.functionCallResults).toEqual([`it's raining`]);
|
|
616
|
-
await listener.sanityCheck();
|
|
617
|
-
});
|
|
618
|
-
test('flow with abort', async () => {
|
|
619
|
-
const { fetch, handleRequest } = mockChatCompletionFetch();
|
|
620
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
621
|
-
const controller = new AbortController();
|
|
622
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
623
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
624
|
-
model: 'gpt-3.5-turbo',
|
|
625
|
-
tools: [
|
|
626
|
-
{
|
|
627
|
-
type: 'function',
|
|
628
|
-
function: {
|
|
629
|
-
function: function getWeather() {
|
|
630
|
-
return `it's raining`;
|
|
631
|
-
},
|
|
632
|
-
parameters: {},
|
|
633
|
-
description: 'gets the weather',
|
|
634
|
-
},
|
|
635
|
-
},
|
|
636
|
-
],
|
|
637
|
-
}, { signal: controller.signal });
|
|
638
|
-
const listener = new RunnerListener(runner);
|
|
639
|
-
await handleRequest(async (request) => {
|
|
640
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
641
|
-
return {
|
|
642
|
-
id: '1',
|
|
643
|
-
choices: [
|
|
644
|
-
{
|
|
645
|
-
index: 0,
|
|
646
|
-
finish_reason: 'function_call',
|
|
647
|
-
logprobs: null,
|
|
648
|
-
message: {
|
|
649
|
-
role: 'assistant',
|
|
650
|
-
content: null,
|
|
651
|
-
tool_calls: [
|
|
652
|
-
{
|
|
653
|
-
type: 'function',
|
|
654
|
-
id: '123',
|
|
655
|
-
function: {
|
|
656
|
-
arguments: '',
|
|
657
|
-
name: 'getWeather',
|
|
658
|
-
},
|
|
659
|
-
},
|
|
660
|
-
],
|
|
661
|
-
},
|
|
662
|
-
},
|
|
663
|
-
],
|
|
664
|
-
created: Math.floor(Date.now() / 1000),
|
|
665
|
-
model: 'gpt-3.5-turbo',
|
|
666
|
-
object: 'chat.completion',
|
|
667
|
-
};
|
|
668
|
-
});
|
|
669
|
-
controller.abort();
|
|
670
|
-
await runner.done().catch(() => { });
|
|
671
|
-
expect(listener.messages).toEqual([
|
|
672
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
673
|
-
{
|
|
674
|
-
role: 'assistant',
|
|
675
|
-
content: null,
|
|
676
|
-
tool_calls: [
|
|
677
|
-
{
|
|
678
|
-
type: 'function',
|
|
679
|
-
id: '123',
|
|
680
|
-
function: {
|
|
681
|
-
arguments: '',
|
|
682
|
-
name: 'getWeather',
|
|
683
|
-
},
|
|
684
|
-
},
|
|
685
|
-
],
|
|
686
|
-
},
|
|
687
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '123' },
|
|
688
|
-
]);
|
|
689
|
-
expect(listener.functionCallResults).toEqual([`it's raining`]);
|
|
690
|
-
await listener.sanityCheck({ error: 'Request was aborted.' });
|
|
691
|
-
expect(runner.aborted).toBe(true);
|
|
692
|
-
});
|
|
693
|
-
test('successful flow with parse', async () => {
|
|
694
|
-
const { fetch, handleRequest } = mockChatCompletionFetch();
|
|
695
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
696
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
697
|
-
messages: [
|
|
698
|
-
{
|
|
699
|
-
role: 'user',
|
|
700
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
701
|
-
},
|
|
702
|
-
],
|
|
703
|
-
model: 'gpt-3.5-turbo',
|
|
704
|
-
tools: [
|
|
705
|
-
new completions_1.ParsingToolFunction({
|
|
706
|
-
name: 'numProperties',
|
|
707
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
708
|
-
parameters: { type: 'object' },
|
|
709
|
-
parse: (str) => {
|
|
710
|
-
const result = JSON.parse(str);
|
|
711
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
712
|
-
throw new Error('must be an object');
|
|
713
|
-
}
|
|
714
|
-
return result;
|
|
715
|
-
},
|
|
716
|
-
description: 'gets the number of properties on an object',
|
|
717
|
-
}),
|
|
718
|
-
],
|
|
719
|
-
});
|
|
720
|
-
const listener = new RunnerListener(runner);
|
|
721
|
-
await handleRequest(async (request) => {
|
|
722
|
-
expect(request.messages).toEqual([
|
|
723
|
-
{
|
|
724
|
-
role: 'user',
|
|
725
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
726
|
-
},
|
|
727
|
-
]);
|
|
728
|
-
return {
|
|
729
|
-
id: '1',
|
|
730
|
-
choices: [
|
|
731
|
-
{
|
|
732
|
-
index: 0,
|
|
733
|
-
finish_reason: 'function_call',
|
|
734
|
-
logprobs: null,
|
|
735
|
-
message: {
|
|
736
|
-
role: 'assistant',
|
|
737
|
-
content: null,
|
|
738
|
-
tool_calls: [
|
|
739
|
-
{
|
|
740
|
-
type: 'function',
|
|
741
|
-
id: '123',
|
|
742
|
-
function: {
|
|
743
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
744
|
-
name: 'numProperties',
|
|
745
|
-
},
|
|
746
|
-
},
|
|
747
|
-
],
|
|
748
|
-
},
|
|
749
|
-
},
|
|
750
|
-
],
|
|
751
|
-
created: Math.floor(Date.now() / 1000),
|
|
752
|
-
model: 'gpt-3.5-turbo',
|
|
753
|
-
object: 'chat.completion',
|
|
754
|
-
usage: {
|
|
755
|
-
completion_tokens: 5,
|
|
756
|
-
prompt_tokens: 20,
|
|
757
|
-
total_tokens: 25,
|
|
758
|
-
},
|
|
759
|
-
};
|
|
760
|
-
});
|
|
761
|
-
await handleRequest(async (request) => {
|
|
762
|
-
expect(request.messages).toEqual([
|
|
763
|
-
{
|
|
764
|
-
role: 'user',
|
|
765
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
role: 'assistant',
|
|
769
|
-
content: null,
|
|
770
|
-
tool_calls: [
|
|
771
|
-
{
|
|
772
|
-
type: 'function',
|
|
773
|
-
id: '123',
|
|
774
|
-
function: {
|
|
775
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
776
|
-
name: 'numProperties',
|
|
777
|
-
},
|
|
778
|
-
},
|
|
779
|
-
],
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
role: 'tool',
|
|
783
|
-
content: '3',
|
|
784
|
-
tool_call_id: '123',
|
|
785
|
-
},
|
|
786
|
-
]);
|
|
787
|
-
return {
|
|
788
|
-
id: '2',
|
|
789
|
-
choices: [
|
|
790
|
-
{
|
|
791
|
-
index: 0,
|
|
792
|
-
finish_reason: 'stop',
|
|
793
|
-
logprobs: null,
|
|
794
|
-
message: {
|
|
795
|
-
role: 'assistant',
|
|
796
|
-
content: `there are 3 properties in {"a": 1, "b": 2, "c": 3}`,
|
|
797
|
-
},
|
|
798
|
-
},
|
|
799
|
-
],
|
|
800
|
-
created: Math.floor(Date.now() / 1000),
|
|
801
|
-
model: 'gpt-3.5-turbo',
|
|
802
|
-
object: 'chat.completion',
|
|
803
|
-
usage: {
|
|
804
|
-
completion_tokens: 10,
|
|
805
|
-
prompt_tokens: 25,
|
|
806
|
-
total_tokens: 35,
|
|
807
|
-
},
|
|
808
|
-
};
|
|
809
|
-
});
|
|
810
|
-
await runner.done();
|
|
811
|
-
expect(listener.messages).toEqual([
|
|
812
|
-
{
|
|
813
|
-
role: 'user',
|
|
814
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
role: 'assistant',
|
|
818
|
-
content: null,
|
|
819
|
-
tool_calls: [
|
|
820
|
-
{
|
|
821
|
-
type: 'function',
|
|
822
|
-
id: '123',
|
|
823
|
-
function: { name: 'numProperties', arguments: '{"a": 1, "b": 2, "c": 3}' },
|
|
824
|
-
},
|
|
825
|
-
],
|
|
826
|
-
},
|
|
827
|
-
{ role: 'tool', content: '3', tool_call_id: '123' },
|
|
828
|
-
{ role: 'assistant', content: 'there are 3 properties in {"a": 1, "b": 2, "c": 3}' },
|
|
829
|
-
]);
|
|
830
|
-
expect(listener.functionCallResults).toEqual(['3']);
|
|
831
|
-
await listener.sanityCheck();
|
|
832
|
-
});
|
|
833
|
-
test('flow with parse error', async () => {
|
|
834
|
-
const { fetch, handleRequest } = mockChatCompletionFetch();
|
|
835
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
836
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
837
|
-
messages: [
|
|
838
|
-
{
|
|
839
|
-
role: 'user',
|
|
840
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
841
|
-
},
|
|
842
|
-
],
|
|
843
|
-
model: 'gpt-3.5-turbo',
|
|
844
|
-
tools: [
|
|
845
|
-
new completions_1.ParsingToolFunction({
|
|
846
|
-
name: 'numProperties',
|
|
847
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
848
|
-
parameters: { type: 'object' },
|
|
849
|
-
parse: (str) => {
|
|
850
|
-
const result = JSON.parse(str);
|
|
851
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
852
|
-
throw new Error('must be an object');
|
|
853
|
-
}
|
|
854
|
-
return result;
|
|
855
|
-
},
|
|
856
|
-
description: 'gets the number of properties on an object',
|
|
857
|
-
}),
|
|
858
|
-
],
|
|
859
|
-
});
|
|
860
|
-
const listener = new RunnerListener(runner);
|
|
861
|
-
await Promise.all([
|
|
862
|
-
handleRequest(async (request) => {
|
|
863
|
-
expect(request.messages).toEqual([
|
|
864
|
-
{
|
|
865
|
-
role: 'user',
|
|
866
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
867
|
-
},
|
|
868
|
-
]);
|
|
869
|
-
return {
|
|
870
|
-
id: '1',
|
|
871
|
-
choices: [
|
|
872
|
-
{
|
|
873
|
-
index: 0,
|
|
874
|
-
finish_reason: 'function_call',
|
|
875
|
-
logprobs: null,
|
|
876
|
-
message: {
|
|
877
|
-
role: 'assistant',
|
|
878
|
-
content: null,
|
|
879
|
-
tool_calls: [
|
|
880
|
-
{
|
|
881
|
-
type: 'function',
|
|
882
|
-
id: '123',
|
|
883
|
-
function: {
|
|
884
|
-
arguments: '[{"a": 1, "b": 2, "c": 3}]',
|
|
885
|
-
name: 'numProperties',
|
|
886
|
-
},
|
|
887
|
-
},
|
|
888
|
-
],
|
|
889
|
-
},
|
|
890
|
-
},
|
|
891
|
-
],
|
|
892
|
-
created: Math.floor(Date.now() / 1000),
|
|
893
|
-
model: 'gpt-3.5-turbo',
|
|
894
|
-
object: 'chat.completion',
|
|
895
|
-
};
|
|
896
|
-
}),
|
|
897
|
-
handleRequest(async (request) => {
|
|
898
|
-
expect(request.messages).toEqual([
|
|
899
|
-
{
|
|
900
|
-
role: 'user',
|
|
901
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
role: 'assistant',
|
|
905
|
-
content: null,
|
|
906
|
-
tool_calls: [
|
|
907
|
-
{
|
|
908
|
-
type: 'function',
|
|
909
|
-
id: '123',
|
|
910
|
-
function: {
|
|
911
|
-
arguments: '[{"a": 1, "b": 2, "c": 3}]',
|
|
912
|
-
name: 'numProperties',
|
|
913
|
-
},
|
|
914
|
-
},
|
|
915
|
-
],
|
|
916
|
-
},
|
|
917
|
-
{
|
|
918
|
-
role: 'tool',
|
|
919
|
-
content: `must be an object`,
|
|
920
|
-
tool_call_id: '123',
|
|
921
|
-
},
|
|
922
|
-
]);
|
|
923
|
-
return {
|
|
924
|
-
id: '2',
|
|
925
|
-
choices: [
|
|
926
|
-
{
|
|
927
|
-
index: 0,
|
|
928
|
-
finish_reason: 'function_call',
|
|
929
|
-
logprobs: null,
|
|
930
|
-
message: {
|
|
931
|
-
role: 'assistant',
|
|
932
|
-
content: null,
|
|
933
|
-
tool_calls: [
|
|
934
|
-
{
|
|
935
|
-
type: 'function',
|
|
936
|
-
id: '1234',
|
|
937
|
-
function: {
|
|
938
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
939
|
-
name: 'numProperties',
|
|
940
|
-
},
|
|
941
|
-
},
|
|
942
|
-
],
|
|
943
|
-
},
|
|
944
|
-
},
|
|
945
|
-
],
|
|
946
|
-
created: Math.floor(Date.now() / 1000),
|
|
947
|
-
model: 'gpt-3.5-turbo',
|
|
948
|
-
object: 'chat.completion',
|
|
949
|
-
};
|
|
950
|
-
}),
|
|
951
|
-
handleRequest(async (request) => {
|
|
952
|
-
expect(request.messages).toEqual([
|
|
953
|
-
{
|
|
954
|
-
role: 'user',
|
|
955
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
956
|
-
},
|
|
957
|
-
{
|
|
958
|
-
role: 'assistant',
|
|
959
|
-
content: null,
|
|
960
|
-
tool_calls: [
|
|
961
|
-
{
|
|
962
|
-
type: 'function',
|
|
963
|
-
id: '123',
|
|
964
|
-
function: {
|
|
965
|
-
arguments: '[{"a": 1, "b": 2, "c": 3}]',
|
|
966
|
-
name: 'numProperties',
|
|
967
|
-
},
|
|
968
|
-
},
|
|
969
|
-
],
|
|
970
|
-
},
|
|
971
|
-
{
|
|
972
|
-
role: 'tool',
|
|
973
|
-
content: `must be an object`,
|
|
974
|
-
tool_call_id: '123',
|
|
975
|
-
},
|
|
976
|
-
{
|
|
977
|
-
role: 'assistant',
|
|
978
|
-
content: null,
|
|
979
|
-
tool_calls: [
|
|
980
|
-
{
|
|
981
|
-
type: 'function',
|
|
982
|
-
id: '1234',
|
|
983
|
-
function: {
|
|
984
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
985
|
-
name: 'numProperties',
|
|
986
|
-
},
|
|
987
|
-
},
|
|
988
|
-
],
|
|
989
|
-
},
|
|
990
|
-
{
|
|
991
|
-
role: 'tool',
|
|
992
|
-
content: '3',
|
|
993
|
-
tool_call_id: '1234',
|
|
994
|
-
},
|
|
995
|
-
]);
|
|
996
|
-
return {
|
|
997
|
-
id: '3',
|
|
998
|
-
choices: [
|
|
999
|
-
{
|
|
1000
|
-
index: 0,
|
|
1001
|
-
finish_reason: 'stop',
|
|
1002
|
-
logprobs: null,
|
|
1003
|
-
message: {
|
|
1004
|
-
role: 'assistant',
|
|
1005
|
-
content: `there are 3 properties in {"a": 1, "b": 2, "c": 3}`,
|
|
1006
|
-
},
|
|
1007
|
-
},
|
|
1008
|
-
],
|
|
1009
|
-
created: Math.floor(Date.now() / 1000),
|
|
1010
|
-
model: 'gpt-3.5-turbo',
|
|
1011
|
-
object: 'chat.completion',
|
|
1012
|
-
};
|
|
1013
|
-
}),
|
|
1014
|
-
runner.done(),
|
|
1015
|
-
]);
|
|
1016
|
-
expect(listener.messages).toEqual([
|
|
1017
|
-
{
|
|
1018
|
-
role: 'user',
|
|
1019
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1020
|
-
},
|
|
1021
|
-
{
|
|
1022
|
-
role: 'assistant',
|
|
1023
|
-
content: null,
|
|
1024
|
-
tool_calls: [
|
|
1025
|
-
{
|
|
1026
|
-
type: 'function',
|
|
1027
|
-
id: '123',
|
|
1028
|
-
function: { name: 'numProperties', arguments: '[{"a": 1, "b": 2, "c": 3}]' },
|
|
1029
|
-
},
|
|
1030
|
-
],
|
|
1031
|
-
},
|
|
1032
|
-
{ role: 'tool', content: `must be an object`, tool_call_id: '123' },
|
|
1033
|
-
{
|
|
1034
|
-
role: 'assistant',
|
|
1035
|
-
content: null,
|
|
1036
|
-
tool_calls: [
|
|
1037
|
-
{
|
|
1038
|
-
type: 'function',
|
|
1039
|
-
id: '1234',
|
|
1040
|
-
function: { name: 'numProperties', arguments: '{"a": 1, "b": 2, "c": 3}' },
|
|
1041
|
-
},
|
|
1042
|
-
],
|
|
1043
|
-
},
|
|
1044
|
-
{ role: 'tool', content: '3', tool_call_id: '1234' },
|
|
1045
|
-
{ role: 'assistant', content: 'there are 3 properties in {"a": 1, "b": 2, "c": 3}' },
|
|
1046
|
-
]);
|
|
1047
|
-
expect(listener.functionCallResults).toEqual([`must be an object`, '3']);
|
|
1048
|
-
await listener.sanityCheck();
|
|
1049
|
-
});
|
|
1050
|
-
test('single function call', async () => {
|
|
1051
|
-
const { fetch, handleRequest } = mockChatCompletionFetch();
|
|
1052
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1053
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1054
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
1055
|
-
model: 'gpt-3.5-turbo',
|
|
1056
|
-
tool_choice: {
|
|
1057
|
-
type: 'function',
|
|
1058
|
-
function: {
|
|
1059
|
-
name: 'getWeather',
|
|
1060
|
-
},
|
|
1061
|
-
},
|
|
1062
|
-
tools: [
|
|
1063
|
-
{
|
|
1064
|
-
type: 'function',
|
|
1065
|
-
function: {
|
|
1066
|
-
function: function getWeather() {
|
|
1067
|
-
return `it's raining`;
|
|
1068
|
-
},
|
|
1069
|
-
parameters: {},
|
|
1070
|
-
description: 'gets the weather',
|
|
1071
|
-
},
|
|
1072
|
-
},
|
|
1073
|
-
],
|
|
1074
|
-
});
|
|
1075
|
-
const listener = new RunnerListener(runner);
|
|
1076
|
-
await Promise.all([
|
|
1077
|
-
handleRequest(async (request) => {
|
|
1078
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
1079
|
-
return {
|
|
1080
|
-
id: '1',
|
|
1081
|
-
choices: [
|
|
1082
|
-
{
|
|
1083
|
-
index: 0,
|
|
1084
|
-
finish_reason: 'function_call',
|
|
1085
|
-
logprobs: null,
|
|
1086
|
-
message: {
|
|
1087
|
-
role: 'assistant',
|
|
1088
|
-
content: null,
|
|
1089
|
-
tool_calls: [
|
|
1090
|
-
{
|
|
1091
|
-
type: 'function',
|
|
1092
|
-
id: '123',
|
|
1093
|
-
function: {
|
|
1094
|
-
arguments: '',
|
|
1095
|
-
name: 'getWeather',
|
|
1096
|
-
},
|
|
1097
|
-
},
|
|
1098
|
-
],
|
|
1099
|
-
},
|
|
1100
|
-
},
|
|
1101
|
-
],
|
|
1102
|
-
created: Math.floor(Date.now() / 1000),
|
|
1103
|
-
model: 'gpt-3.5-turbo',
|
|
1104
|
-
object: 'chat.completion',
|
|
1105
|
-
};
|
|
1106
|
-
}),
|
|
1107
|
-
runner.done(),
|
|
1108
|
-
]);
|
|
1109
|
-
expect(listener.messages).toEqual([
|
|
1110
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1111
|
-
{
|
|
1112
|
-
role: 'assistant',
|
|
1113
|
-
content: null,
|
|
1114
|
-
tool_calls: [
|
|
1115
|
-
{
|
|
1116
|
-
type: 'function',
|
|
1117
|
-
id: '123',
|
|
1118
|
-
function: {
|
|
1119
|
-
arguments: '',
|
|
1120
|
-
name: 'getWeather',
|
|
1121
|
-
},
|
|
1122
|
-
},
|
|
1123
|
-
],
|
|
1124
|
-
},
|
|
1125
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '123' },
|
|
1126
|
-
]);
|
|
1127
|
-
expect(listener.functionCallResults).toEqual([`it's raining`]);
|
|
1128
|
-
await listener.sanityCheck();
|
|
1129
|
-
});
|
|
1130
|
-
test('wrong function name', async () => {
|
|
1131
|
-
const { fetch, handleRequest } = mockChatCompletionFetch();
|
|
1132
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1133
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1134
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
1135
|
-
model: 'gpt-3.5-turbo',
|
|
1136
|
-
tools: [
|
|
1137
|
-
{
|
|
1138
|
-
type: 'function',
|
|
1139
|
-
function: {
|
|
1140
|
-
function: function getWeather() {
|
|
1141
|
-
return `it's raining`;
|
|
1142
|
-
},
|
|
1143
|
-
parameters: {},
|
|
1144
|
-
description: 'gets the weather',
|
|
1145
|
-
},
|
|
1146
|
-
},
|
|
1147
|
-
],
|
|
1148
|
-
});
|
|
1149
|
-
const listener = new RunnerListener(runner);
|
|
1150
|
-
await Promise.all([
|
|
1151
|
-
handleRequest(async (request) => {
|
|
1152
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
1153
|
-
return {
|
|
1154
|
-
id: '1',
|
|
1155
|
-
choices: [
|
|
1156
|
-
{
|
|
1157
|
-
index: 0,
|
|
1158
|
-
finish_reason: 'function_call',
|
|
1159
|
-
logprobs: null,
|
|
1160
|
-
message: {
|
|
1161
|
-
role: 'assistant',
|
|
1162
|
-
content: null,
|
|
1163
|
-
tool_calls: [
|
|
1164
|
-
{
|
|
1165
|
-
type: 'function',
|
|
1166
|
-
id: '123',
|
|
1167
|
-
function: {
|
|
1168
|
-
arguments: '',
|
|
1169
|
-
name: 'get_weather',
|
|
1170
|
-
},
|
|
1171
|
-
},
|
|
1172
|
-
],
|
|
1173
|
-
},
|
|
1174
|
-
},
|
|
1175
|
-
],
|
|
1176
|
-
created: Math.floor(Date.now() / 1000),
|
|
1177
|
-
model: 'gpt-3.5-turbo',
|
|
1178
|
-
object: 'chat.completion',
|
|
1179
|
-
};
|
|
1180
|
-
}),
|
|
1181
|
-
handleRequest(async (request) => {
|
|
1182
|
-
expect(request.messages).toEqual([
|
|
1183
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1184
|
-
{
|
|
1185
|
-
role: 'assistant',
|
|
1186
|
-
content: null,
|
|
1187
|
-
tool_calls: [
|
|
1188
|
-
{
|
|
1189
|
-
type: 'function',
|
|
1190
|
-
id: '123',
|
|
1191
|
-
function: {
|
|
1192
|
-
arguments: '',
|
|
1193
|
-
name: 'get_weather',
|
|
1194
|
-
},
|
|
1195
|
-
},
|
|
1196
|
-
],
|
|
1197
|
-
},
|
|
1198
|
-
{
|
|
1199
|
-
role: 'tool',
|
|
1200
|
-
content: `Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
1201
|
-
tool_call_id: '123',
|
|
1202
|
-
},
|
|
1203
|
-
]);
|
|
1204
|
-
return {
|
|
1205
|
-
id: '2',
|
|
1206
|
-
choices: [
|
|
1207
|
-
{
|
|
1208
|
-
index: 0,
|
|
1209
|
-
finish_reason: 'function_call',
|
|
1210
|
-
logprobs: null,
|
|
1211
|
-
message: {
|
|
1212
|
-
role: 'assistant',
|
|
1213
|
-
content: null,
|
|
1214
|
-
tool_calls: [
|
|
1215
|
-
{
|
|
1216
|
-
type: 'function',
|
|
1217
|
-
id: '1234',
|
|
1218
|
-
function: {
|
|
1219
|
-
arguments: '',
|
|
1220
|
-
name: 'getWeather',
|
|
1221
|
-
},
|
|
1222
|
-
},
|
|
1223
|
-
],
|
|
1224
|
-
},
|
|
1225
|
-
},
|
|
1226
|
-
],
|
|
1227
|
-
created: Math.floor(Date.now() / 1000),
|
|
1228
|
-
model: 'gpt-3.5-turbo',
|
|
1229
|
-
object: 'chat.completion',
|
|
1230
|
-
};
|
|
1231
|
-
}),
|
|
1232
|
-
handleRequest(async (request) => {
|
|
1233
|
-
expect(request.messages).toEqual([
|
|
1234
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1235
|
-
{
|
|
1236
|
-
role: 'assistant',
|
|
1237
|
-
content: null,
|
|
1238
|
-
tool_calls: [
|
|
1239
|
-
{
|
|
1240
|
-
type: 'function',
|
|
1241
|
-
id: '123',
|
|
1242
|
-
function: {
|
|
1243
|
-
arguments: '',
|
|
1244
|
-
name: 'get_weather',
|
|
1245
|
-
},
|
|
1246
|
-
},
|
|
1247
|
-
],
|
|
1248
|
-
},
|
|
1249
|
-
{
|
|
1250
|
-
role: 'tool',
|
|
1251
|
-
content: `Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
1252
|
-
tool_call_id: '123',
|
|
1253
|
-
},
|
|
1254
|
-
{
|
|
1255
|
-
role: 'assistant',
|
|
1256
|
-
content: null,
|
|
1257
|
-
tool_calls: [
|
|
1258
|
-
{
|
|
1259
|
-
type: 'function',
|
|
1260
|
-
id: '1234',
|
|
1261
|
-
function: {
|
|
1262
|
-
arguments: '',
|
|
1263
|
-
name: 'getWeather',
|
|
1264
|
-
},
|
|
1265
|
-
},
|
|
1266
|
-
],
|
|
1267
|
-
},
|
|
1268
|
-
{
|
|
1269
|
-
role: 'tool',
|
|
1270
|
-
content: `it's raining`,
|
|
1271
|
-
tool_call_id: '1234',
|
|
1272
|
-
},
|
|
1273
|
-
]);
|
|
1274
|
-
return {
|
|
1275
|
-
id: '3',
|
|
1276
|
-
choices: [
|
|
1277
|
-
{
|
|
1278
|
-
index: 0,
|
|
1279
|
-
finish_reason: 'stop',
|
|
1280
|
-
logprobs: null,
|
|
1281
|
-
message: {
|
|
1282
|
-
role: 'assistant',
|
|
1283
|
-
content: `it's raining`,
|
|
1284
|
-
},
|
|
1285
|
-
},
|
|
1286
|
-
],
|
|
1287
|
-
created: Math.floor(Date.now() / 1000),
|
|
1288
|
-
model: 'gpt-3.5-turbo',
|
|
1289
|
-
object: 'chat.completion',
|
|
1290
|
-
};
|
|
1291
|
-
}),
|
|
1292
|
-
runner.done(),
|
|
1293
|
-
]);
|
|
1294
|
-
expect(listener.messages).toEqual([
|
|
1295
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1296
|
-
{
|
|
1297
|
-
role: 'assistant',
|
|
1298
|
-
content: null,
|
|
1299
|
-
tool_calls: [{ type: 'function', id: '123', function: { name: 'get_weather', arguments: '' } }],
|
|
1300
|
-
},
|
|
1301
|
-
{
|
|
1302
|
-
role: 'tool',
|
|
1303
|
-
content: `Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
1304
|
-
tool_call_id: '123',
|
|
1305
|
-
},
|
|
1306
|
-
{
|
|
1307
|
-
role: 'assistant',
|
|
1308
|
-
content: null,
|
|
1309
|
-
tool_calls: [{ type: 'function', id: '1234', function: { name: 'getWeather', arguments: '' } }],
|
|
1310
|
-
},
|
|
1311
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '1234' },
|
|
1312
|
-
{ role: 'assistant', content: "it's raining" },
|
|
1313
|
-
]);
|
|
1314
|
-
expect(listener.functionCallResults).toEqual([
|
|
1315
|
-
`Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
1316
|
-
`it's raining`,
|
|
1317
|
-
]);
|
|
1318
|
-
await listener.sanityCheck();
|
|
1319
|
-
});
|
|
1320
|
-
});
|
|
1321
|
-
describe('runTools with stream: true', () => {
|
|
1322
|
-
test('successful flow', async () => {
|
|
1323
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
1324
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1325
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1326
|
-
stream: true,
|
|
1327
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
1328
|
-
model: 'gpt-3.5-turbo',
|
|
1329
|
-
tools: [
|
|
1330
|
-
{
|
|
1331
|
-
type: 'function',
|
|
1332
|
-
function: {
|
|
1333
|
-
function: function getWeather() {
|
|
1334
|
-
return `it's raining`;
|
|
1335
|
-
},
|
|
1336
|
-
parameters: {},
|
|
1337
|
-
description: 'gets the weather',
|
|
1338
|
-
},
|
|
1339
|
-
},
|
|
1340
|
-
],
|
|
1341
|
-
});
|
|
1342
|
-
const listener = new StreamingRunnerListener(runner);
|
|
1343
|
-
await Promise.all([
|
|
1344
|
-
handleRequest(async function* (request) {
|
|
1345
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
1346
|
-
yield {
|
|
1347
|
-
id: '1',
|
|
1348
|
-
choices: [
|
|
1349
|
-
{
|
|
1350
|
-
index: 0,
|
|
1351
|
-
finish_reason: 'function_call',
|
|
1352
|
-
logprobs: null,
|
|
1353
|
-
delta: {
|
|
1354
|
-
role: 'assistant',
|
|
1355
|
-
content: null,
|
|
1356
|
-
tool_calls: [
|
|
1357
|
-
{
|
|
1358
|
-
type: 'function',
|
|
1359
|
-
index: 0,
|
|
1360
|
-
id: '123',
|
|
1361
|
-
function: {
|
|
1362
|
-
arguments: '',
|
|
1363
|
-
name: 'getWeather',
|
|
1364
|
-
},
|
|
1365
|
-
},
|
|
1366
|
-
],
|
|
1367
|
-
},
|
|
1368
|
-
},
|
|
1369
|
-
],
|
|
1370
|
-
created: Math.floor(Date.now() / 1000),
|
|
1371
|
-
model: 'gpt-3.5-turbo',
|
|
1372
|
-
object: 'chat.completion.chunk',
|
|
1373
|
-
};
|
|
1374
|
-
}),
|
|
1375
|
-
handleRequest(async function* (request) {
|
|
1376
|
-
expect(request.messages).toEqual([
|
|
1377
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1378
|
-
{
|
|
1379
|
-
role: 'assistant',
|
|
1380
|
-
content: null,
|
|
1381
|
-
tool_calls: [
|
|
1382
|
-
{
|
|
1383
|
-
type: 'function',
|
|
1384
|
-
id: '123',
|
|
1385
|
-
function: {
|
|
1386
|
-
arguments: '',
|
|
1387
|
-
name: 'getWeather',
|
|
1388
|
-
},
|
|
1389
|
-
},
|
|
1390
|
-
],
|
|
1391
|
-
},
|
|
1392
|
-
{
|
|
1393
|
-
role: 'tool',
|
|
1394
|
-
content: `it's raining`,
|
|
1395
|
-
tool_call_id: '123',
|
|
1396
|
-
},
|
|
1397
|
-
]);
|
|
1398
|
-
for (const choice of contentChoiceDeltas(`it's raining`)) {
|
|
1399
|
-
yield {
|
|
1400
|
-
id: '2',
|
|
1401
|
-
choices: [choice],
|
|
1402
|
-
created: Math.floor(Date.now() / 1000),
|
|
1403
|
-
model: 'gpt-3.5-turbo',
|
|
1404
|
-
object: 'chat.completion.chunk',
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
}),
|
|
1408
|
-
runner.done(),
|
|
1409
|
-
]);
|
|
1410
|
-
expect(listener.eventMessages).toEqual([
|
|
1411
|
-
{
|
|
1412
|
-
role: 'assistant',
|
|
1413
|
-
content: null,
|
|
1414
|
-
tool_calls: [
|
|
1415
|
-
{
|
|
1416
|
-
type: 'function',
|
|
1417
|
-
id: '123',
|
|
1418
|
-
function: {
|
|
1419
|
-
arguments: '',
|
|
1420
|
-
name: 'getWeather',
|
|
1421
|
-
},
|
|
1422
|
-
},
|
|
1423
|
-
],
|
|
1424
|
-
},
|
|
1425
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '123' },
|
|
1426
|
-
{ role: 'assistant', content: "it's raining" },
|
|
1427
|
-
]);
|
|
1428
|
-
expect(listener.eventFunctionCallResults).toEqual([`it's raining`]);
|
|
1429
|
-
await listener.sanityCheck();
|
|
1430
|
-
});
|
|
1431
|
-
test('flow with abort', async () => {
|
|
1432
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
1433
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1434
|
-
const controller = new AbortController();
|
|
1435
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1436
|
-
stream: true,
|
|
1437
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
1438
|
-
model: 'gpt-3.5-turbo',
|
|
1439
|
-
tools: [
|
|
1440
|
-
{
|
|
1441
|
-
type: 'function',
|
|
1442
|
-
function: {
|
|
1443
|
-
function: function getWeather() {
|
|
1444
|
-
return `it's raining`;
|
|
1445
|
-
},
|
|
1446
|
-
parameters: {},
|
|
1447
|
-
description: 'gets the weather',
|
|
1448
|
-
},
|
|
1449
|
-
},
|
|
1450
|
-
],
|
|
1451
|
-
}, { signal: controller.signal });
|
|
1452
|
-
runner.on('functionCallResult', () => controller.abort());
|
|
1453
|
-
const listener = new StreamingRunnerListener(runner);
|
|
1454
|
-
await handleRequest(async function* (request) {
|
|
1455
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
1456
|
-
yield {
|
|
1457
|
-
id: '1',
|
|
1458
|
-
choices: [
|
|
1459
|
-
{
|
|
1460
|
-
index: 0,
|
|
1461
|
-
finish_reason: 'function_call',
|
|
1462
|
-
delta: {
|
|
1463
|
-
role: 'assistant',
|
|
1464
|
-
content: null,
|
|
1465
|
-
tool_calls: [
|
|
1466
|
-
{
|
|
1467
|
-
type: 'function',
|
|
1468
|
-
index: 0,
|
|
1469
|
-
id: '123',
|
|
1470
|
-
function: {
|
|
1471
|
-
arguments: '',
|
|
1472
|
-
name: 'getWeather',
|
|
1473
|
-
},
|
|
1474
|
-
},
|
|
1475
|
-
],
|
|
1476
|
-
},
|
|
1477
|
-
},
|
|
1478
|
-
],
|
|
1479
|
-
created: Math.floor(Date.now() / 1000),
|
|
1480
|
-
model: 'gpt-3.5-turbo',
|
|
1481
|
-
object: 'chat.completion.chunk',
|
|
1482
|
-
};
|
|
1483
|
-
});
|
|
1484
|
-
await runner.done().catch(() => { });
|
|
1485
|
-
expect(listener.eventMessages).toEqual([
|
|
1486
|
-
{
|
|
1487
|
-
role: 'assistant',
|
|
1488
|
-
content: null,
|
|
1489
|
-
tool_calls: [
|
|
1490
|
-
{
|
|
1491
|
-
type: 'function',
|
|
1492
|
-
id: '123',
|
|
1493
|
-
function: {
|
|
1494
|
-
arguments: '',
|
|
1495
|
-
name: 'getWeather',
|
|
1496
|
-
},
|
|
1497
|
-
},
|
|
1498
|
-
],
|
|
1499
|
-
},
|
|
1500
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '123' },
|
|
1501
|
-
]);
|
|
1502
|
-
expect(listener.eventFunctionCallResults).toEqual([`it's raining`]);
|
|
1503
|
-
await listener.sanityCheck({ error: 'Request was aborted.' });
|
|
1504
|
-
expect(runner.aborted).toBe(true);
|
|
1505
|
-
});
|
|
1506
|
-
test('successful flow with parse', async () => {
|
|
1507
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
1508
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1509
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1510
|
-
stream: true,
|
|
1511
|
-
messages: [
|
|
1512
|
-
{
|
|
1513
|
-
role: 'user',
|
|
1514
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1515
|
-
},
|
|
1516
|
-
],
|
|
1517
|
-
model: 'gpt-3.5-turbo',
|
|
1518
|
-
tools: [
|
|
1519
|
-
new completions_1.ParsingToolFunction({
|
|
1520
|
-
name: 'numProperties',
|
|
1521
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
1522
|
-
parameters: { type: 'object' },
|
|
1523
|
-
parse: (str) => {
|
|
1524
|
-
const result = JSON.parse(str);
|
|
1525
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
1526
|
-
throw new Error('must be an object');
|
|
1527
|
-
}
|
|
1528
|
-
return result;
|
|
1529
|
-
},
|
|
1530
|
-
description: 'gets the number of properties on an object',
|
|
1531
|
-
}),
|
|
1532
|
-
],
|
|
1533
|
-
});
|
|
1534
|
-
const listener = new StreamingRunnerListener(runner);
|
|
1535
|
-
await Promise.all([
|
|
1536
|
-
handleRequest(async function* (request) {
|
|
1537
|
-
expect(request.messages).toEqual([
|
|
1538
|
-
{
|
|
1539
|
-
role: 'user',
|
|
1540
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1541
|
-
},
|
|
1542
|
-
]);
|
|
1543
|
-
yield {
|
|
1544
|
-
id: '1',
|
|
1545
|
-
choices: [
|
|
1546
|
-
{
|
|
1547
|
-
index: 0,
|
|
1548
|
-
finish_reason: 'function_call',
|
|
1549
|
-
delta: {
|
|
1550
|
-
role: 'assistant',
|
|
1551
|
-
content: null,
|
|
1552
|
-
tool_calls: [
|
|
1553
|
-
{
|
|
1554
|
-
type: 'function',
|
|
1555
|
-
id: '123',
|
|
1556
|
-
index: 0,
|
|
1557
|
-
function: {
|
|
1558
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
1559
|
-
name: 'numProperties',
|
|
1560
|
-
},
|
|
1561
|
-
},
|
|
1562
|
-
],
|
|
1563
|
-
},
|
|
1564
|
-
},
|
|
1565
|
-
],
|
|
1566
|
-
created: Math.floor(Date.now() / 1000),
|
|
1567
|
-
model: 'gpt-3.5-turbo',
|
|
1568
|
-
object: 'chat.completion.chunk',
|
|
1569
|
-
};
|
|
1570
|
-
}),
|
|
1571
|
-
handleRequest(async function* (request) {
|
|
1572
|
-
expect(request.messages).toEqual([
|
|
1573
|
-
{
|
|
1574
|
-
role: 'user',
|
|
1575
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1576
|
-
},
|
|
1577
|
-
{
|
|
1578
|
-
role: 'assistant',
|
|
1579
|
-
content: null,
|
|
1580
|
-
tool_calls: [
|
|
1581
|
-
{
|
|
1582
|
-
type: 'function',
|
|
1583
|
-
id: '123',
|
|
1584
|
-
function: {
|
|
1585
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
1586
|
-
name: 'numProperties',
|
|
1587
|
-
},
|
|
1588
|
-
},
|
|
1589
|
-
],
|
|
1590
|
-
},
|
|
1591
|
-
{
|
|
1592
|
-
role: 'tool',
|
|
1593
|
-
content: '3',
|
|
1594
|
-
tool_call_id: '123',
|
|
1595
|
-
},
|
|
1596
|
-
]);
|
|
1597
|
-
for (const choice of contentChoiceDeltas(`there are 3 properties in {"a": 1, "b": 2, "c": 3}`)) {
|
|
1598
|
-
yield {
|
|
1599
|
-
id: '2',
|
|
1600
|
-
choices: [choice],
|
|
1601
|
-
created: Math.floor(Date.now() / 1000),
|
|
1602
|
-
model: 'gpt-3.5-turbo',
|
|
1603
|
-
object: 'chat.completion.chunk',
|
|
1604
|
-
};
|
|
1605
|
-
}
|
|
1606
|
-
}),
|
|
1607
|
-
runner.done(),
|
|
1608
|
-
]);
|
|
1609
|
-
expect(listener.eventMessages).toEqual([
|
|
1610
|
-
{
|
|
1611
|
-
role: 'assistant',
|
|
1612
|
-
content: null,
|
|
1613
|
-
tool_calls: [
|
|
1614
|
-
{
|
|
1615
|
-
type: 'function',
|
|
1616
|
-
id: '123',
|
|
1617
|
-
function: { name: 'numProperties', arguments: '{"a": 1, "b": 2, "c": 3}' },
|
|
1618
|
-
},
|
|
1619
|
-
],
|
|
1620
|
-
},
|
|
1621
|
-
{ role: 'tool', content: '3', tool_call_id: '123' },
|
|
1622
|
-
{ role: 'assistant', content: 'there are 3 properties in {"a": 1, "b": 2, "c": 3}' },
|
|
1623
|
-
]);
|
|
1624
|
-
expect(listener.eventFunctionCallResults).toEqual(['3']);
|
|
1625
|
-
await listener.sanityCheck();
|
|
1626
|
-
});
|
|
1627
|
-
test('flow with parse error', async () => {
|
|
1628
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
1629
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1630
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1631
|
-
stream: true,
|
|
1632
|
-
messages: [
|
|
1633
|
-
{
|
|
1634
|
-
role: 'user',
|
|
1635
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1636
|
-
},
|
|
1637
|
-
],
|
|
1638
|
-
model: 'gpt-3.5-turbo',
|
|
1639
|
-
tools: [
|
|
1640
|
-
new completions_1.ParsingToolFunction({
|
|
1641
|
-
name: 'numProperties',
|
|
1642
|
-
function: (obj) => String(Object.keys(obj).length),
|
|
1643
|
-
parameters: { type: 'object' },
|
|
1644
|
-
parse: (str) => {
|
|
1645
|
-
const result = JSON.parse(str);
|
|
1646
|
-
if (!(result instanceof Object) || Array.isArray(result)) {
|
|
1647
|
-
throw new Error('must be an object');
|
|
1648
|
-
}
|
|
1649
|
-
return result;
|
|
1650
|
-
},
|
|
1651
|
-
description: 'gets the number of properties on an object',
|
|
1652
|
-
}),
|
|
1653
|
-
],
|
|
1654
|
-
});
|
|
1655
|
-
const listener = new StreamingRunnerListener(runner);
|
|
1656
|
-
await Promise.all([
|
|
1657
|
-
handleRequest(async function* (request) {
|
|
1658
|
-
expect(request.messages).toEqual([
|
|
1659
|
-
{
|
|
1660
|
-
role: 'user',
|
|
1661
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1662
|
-
},
|
|
1663
|
-
]);
|
|
1664
|
-
for (const choice of functionCallDeltas('[{"a": 1, "b": 2, "c": 3}]', {
|
|
1665
|
-
name: 'numProperties',
|
|
1666
|
-
id: '123',
|
|
1667
|
-
})) {
|
|
1668
|
-
yield {
|
|
1669
|
-
id: '1',
|
|
1670
|
-
choices: [choice],
|
|
1671
|
-
created: Math.floor(Date.now() / 1000),
|
|
1672
|
-
model: 'gpt-3.5-turbo',
|
|
1673
|
-
object: 'chat.completion.chunk',
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
}),
|
|
1677
|
-
handleRequest(async function* (request) {
|
|
1678
|
-
expect(request.messages).toEqual([
|
|
1679
|
-
{
|
|
1680
|
-
role: 'user',
|
|
1681
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1682
|
-
},
|
|
1683
|
-
{
|
|
1684
|
-
role: 'assistant',
|
|
1685
|
-
content: null,
|
|
1686
|
-
tool_calls: [
|
|
1687
|
-
{
|
|
1688
|
-
type: 'function',
|
|
1689
|
-
id: '123',
|
|
1690
|
-
function: {
|
|
1691
|
-
arguments: '[{"a": 1, "b": 2, "c": 3}]',
|
|
1692
|
-
name: 'numProperties',
|
|
1693
|
-
},
|
|
1694
|
-
},
|
|
1695
|
-
],
|
|
1696
|
-
},
|
|
1697
|
-
{
|
|
1698
|
-
role: 'tool',
|
|
1699
|
-
content: `must be an object`,
|
|
1700
|
-
tool_call_id: '123',
|
|
1701
|
-
},
|
|
1702
|
-
]);
|
|
1703
|
-
for (const choice of functionCallDeltas('{"a": 1, "b": 2, "c": 3}', {
|
|
1704
|
-
name: 'numProperties',
|
|
1705
|
-
id: '1234',
|
|
1706
|
-
})) {
|
|
1707
|
-
yield {
|
|
1708
|
-
id: '2',
|
|
1709
|
-
choices: [choice],
|
|
1710
|
-
created: Math.floor(Date.now() / 1000),
|
|
1711
|
-
model: 'gpt-3.5-turbo',
|
|
1712
|
-
object: 'chat.completion.chunk',
|
|
1713
|
-
};
|
|
1714
|
-
}
|
|
1715
|
-
}),
|
|
1716
|
-
handleRequest(async function* (request) {
|
|
1717
|
-
expect(request.messages).toEqual([
|
|
1718
|
-
{
|
|
1719
|
-
role: 'user',
|
|
1720
|
-
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
|
|
1721
|
-
},
|
|
1722
|
-
{
|
|
1723
|
-
role: 'assistant',
|
|
1724
|
-
content: null,
|
|
1725
|
-
tool_calls: [
|
|
1726
|
-
{
|
|
1727
|
-
type: 'function',
|
|
1728
|
-
id: '123',
|
|
1729
|
-
function: {
|
|
1730
|
-
arguments: '[{"a": 1, "b": 2, "c": 3}]',
|
|
1731
|
-
name: 'numProperties',
|
|
1732
|
-
},
|
|
1733
|
-
},
|
|
1734
|
-
],
|
|
1735
|
-
},
|
|
1736
|
-
{
|
|
1737
|
-
role: 'tool',
|
|
1738
|
-
content: `must be an object`,
|
|
1739
|
-
tool_call_id: '123',
|
|
1740
|
-
},
|
|
1741
|
-
{
|
|
1742
|
-
role: 'assistant',
|
|
1743
|
-
content: null,
|
|
1744
|
-
tool_calls: [
|
|
1745
|
-
{
|
|
1746
|
-
type: 'function',
|
|
1747
|
-
id: '1234',
|
|
1748
|
-
function: {
|
|
1749
|
-
arguments: '{"a": 1, "b": 2, "c": 3}',
|
|
1750
|
-
name: 'numProperties',
|
|
1751
|
-
},
|
|
1752
|
-
},
|
|
1753
|
-
],
|
|
1754
|
-
},
|
|
1755
|
-
{
|
|
1756
|
-
role: 'tool',
|
|
1757
|
-
content: '3',
|
|
1758
|
-
tool_call_id: '1234',
|
|
1759
|
-
},
|
|
1760
|
-
]);
|
|
1761
|
-
for (const choice of contentChoiceDeltas(`there are 3 properties in {"a": 1, "b": 2, "c": 3}`)) {
|
|
1762
|
-
yield {
|
|
1763
|
-
id: '3',
|
|
1764
|
-
choices: [choice],
|
|
1765
|
-
created: Math.floor(Date.now() / 1000),
|
|
1766
|
-
model: 'gpt-3.5-turbo',
|
|
1767
|
-
object: 'chat.completion.chunk',
|
|
1768
|
-
};
|
|
1769
|
-
}
|
|
1770
|
-
}),
|
|
1771
|
-
runner.done(),
|
|
1772
|
-
]);
|
|
1773
|
-
expect(listener.eventMessages).toEqual([
|
|
1774
|
-
{
|
|
1775
|
-
role: 'assistant',
|
|
1776
|
-
content: null,
|
|
1777
|
-
tool_calls: [
|
|
1778
|
-
{
|
|
1779
|
-
type: 'function',
|
|
1780
|
-
id: '123',
|
|
1781
|
-
function: { name: 'numProperties', arguments: '[{"a": 1, "b": 2, "c": 3}]' },
|
|
1782
|
-
},
|
|
1783
|
-
],
|
|
1784
|
-
},
|
|
1785
|
-
{ role: 'tool', content: `must be an object`, tool_call_id: '123' },
|
|
1786
|
-
{
|
|
1787
|
-
role: 'assistant',
|
|
1788
|
-
content: null,
|
|
1789
|
-
tool_calls: [
|
|
1790
|
-
{
|
|
1791
|
-
type: 'function',
|
|
1792
|
-
id: '1234',
|
|
1793
|
-
function: { name: 'numProperties', arguments: '{"a": 1, "b": 2, "c": 3}' },
|
|
1794
|
-
},
|
|
1795
|
-
],
|
|
1796
|
-
},
|
|
1797
|
-
{ role: 'tool', content: '3', tool_call_id: '1234' },
|
|
1798
|
-
{ role: 'assistant', content: 'there are 3 properties in {"a": 1, "b": 2, "c": 3}' },
|
|
1799
|
-
]);
|
|
1800
|
-
expect(listener.eventFunctionCallResults).toEqual([`must be an object`, '3']);
|
|
1801
|
-
await listener.sanityCheck();
|
|
1802
|
-
});
|
|
1803
|
-
test('single function call', async () => {
|
|
1804
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
1805
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1806
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1807
|
-
stream: true,
|
|
1808
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
1809
|
-
model: 'gpt-3.5-turbo',
|
|
1810
|
-
tool_choice: {
|
|
1811
|
-
type: 'function',
|
|
1812
|
-
function: {
|
|
1813
|
-
name: 'getWeather',
|
|
1814
|
-
},
|
|
1815
|
-
},
|
|
1816
|
-
tools: [
|
|
1817
|
-
{
|
|
1818
|
-
type: 'function',
|
|
1819
|
-
function: {
|
|
1820
|
-
function: function getWeather() {
|
|
1821
|
-
return `it's raining`;
|
|
1822
|
-
},
|
|
1823
|
-
parameters: {},
|
|
1824
|
-
description: 'gets the weather',
|
|
1825
|
-
},
|
|
1826
|
-
},
|
|
1827
|
-
],
|
|
1828
|
-
});
|
|
1829
|
-
const listener = new StreamingRunnerListener(runner);
|
|
1830
|
-
await Promise.all([
|
|
1831
|
-
handleRequest(async function* (request) {
|
|
1832
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
1833
|
-
yield {
|
|
1834
|
-
id: '1',
|
|
1835
|
-
choices: [
|
|
1836
|
-
{
|
|
1837
|
-
index: 0,
|
|
1838
|
-
finish_reason: 'function_call',
|
|
1839
|
-
delta: {
|
|
1840
|
-
role: 'assistant',
|
|
1841
|
-
content: null,
|
|
1842
|
-
tool_calls: [
|
|
1843
|
-
{
|
|
1844
|
-
type: 'function',
|
|
1845
|
-
index: 0,
|
|
1846
|
-
id: '123',
|
|
1847
|
-
function: {
|
|
1848
|
-
arguments: '',
|
|
1849
|
-
name: 'getWeather',
|
|
1850
|
-
},
|
|
1851
|
-
},
|
|
1852
|
-
],
|
|
1853
|
-
},
|
|
1854
|
-
},
|
|
1855
|
-
],
|
|
1856
|
-
created: Math.floor(Date.now() / 1000),
|
|
1857
|
-
model: 'gpt-3.5-turbo',
|
|
1858
|
-
object: 'chat.completion.chunk',
|
|
1859
|
-
};
|
|
1860
|
-
}),
|
|
1861
|
-
runner.done(),
|
|
1862
|
-
]);
|
|
1863
|
-
expect(listener.eventMessages).toEqual([
|
|
1864
|
-
{
|
|
1865
|
-
role: 'assistant',
|
|
1866
|
-
content: null,
|
|
1867
|
-
tool_calls: [
|
|
1868
|
-
{
|
|
1869
|
-
type: 'function',
|
|
1870
|
-
id: '123',
|
|
1871
|
-
function: {
|
|
1872
|
-
arguments: '',
|
|
1873
|
-
name: 'getWeather',
|
|
1874
|
-
},
|
|
1875
|
-
},
|
|
1876
|
-
],
|
|
1877
|
-
},
|
|
1878
|
-
{ role: 'tool', tool_call_id: '123', content: `it's raining` },
|
|
1879
|
-
]);
|
|
1880
|
-
expect(listener.eventFunctionCallResults).toEqual([`it's raining`]);
|
|
1881
|
-
await listener.sanityCheck();
|
|
1882
|
-
});
|
|
1883
|
-
test('wrong function name', async () => {
|
|
1884
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
1885
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
1886
|
-
const runner = openai.beta.chat.completions.runTools({
|
|
1887
|
-
stream: true,
|
|
1888
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
1889
|
-
model: 'gpt-3.5-turbo',
|
|
1890
|
-
tools: [
|
|
1891
|
-
{
|
|
1892
|
-
type: 'function',
|
|
1893
|
-
function: {
|
|
1894
|
-
function: function getWeather() {
|
|
1895
|
-
return `it's raining`;
|
|
1896
|
-
},
|
|
1897
|
-
parameters: {},
|
|
1898
|
-
description: 'gets the weather',
|
|
1899
|
-
},
|
|
1900
|
-
},
|
|
1901
|
-
],
|
|
1902
|
-
});
|
|
1903
|
-
const listener = new StreamingRunnerListener(runner);
|
|
1904
|
-
await Promise.all([
|
|
1905
|
-
handleRequest(async function* (request) {
|
|
1906
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
1907
|
-
yield {
|
|
1908
|
-
id: '1',
|
|
1909
|
-
choices: [
|
|
1910
|
-
{
|
|
1911
|
-
index: 0,
|
|
1912
|
-
finish_reason: 'function_call',
|
|
1913
|
-
delta: {
|
|
1914
|
-
role: 'assistant',
|
|
1915
|
-
content: null,
|
|
1916
|
-
tool_calls: [
|
|
1917
|
-
{
|
|
1918
|
-
type: 'function',
|
|
1919
|
-
index: 0,
|
|
1920
|
-
id: '123',
|
|
1921
|
-
function: {
|
|
1922
|
-
arguments: '',
|
|
1923
|
-
name: 'get_weather',
|
|
1924
|
-
},
|
|
1925
|
-
},
|
|
1926
|
-
],
|
|
1927
|
-
},
|
|
1928
|
-
},
|
|
1929
|
-
],
|
|
1930
|
-
created: Math.floor(Date.now() / 1000),
|
|
1931
|
-
model: 'gpt-3.5-turbo',
|
|
1932
|
-
object: 'chat.completion.chunk',
|
|
1933
|
-
};
|
|
1934
|
-
}),
|
|
1935
|
-
handleRequest(async function* (request) {
|
|
1936
|
-
expect(request.messages).toEqual([
|
|
1937
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1938
|
-
{
|
|
1939
|
-
role: 'assistant',
|
|
1940
|
-
content: null,
|
|
1941
|
-
tool_calls: [
|
|
1942
|
-
{
|
|
1943
|
-
type: 'function',
|
|
1944
|
-
id: '123',
|
|
1945
|
-
function: {
|
|
1946
|
-
arguments: '',
|
|
1947
|
-
name: 'get_weather',
|
|
1948
|
-
},
|
|
1949
|
-
},
|
|
1950
|
-
],
|
|
1951
|
-
},
|
|
1952
|
-
{
|
|
1953
|
-
role: 'tool',
|
|
1954
|
-
content: `Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
1955
|
-
tool_call_id: '123',
|
|
1956
|
-
},
|
|
1957
|
-
]);
|
|
1958
|
-
yield {
|
|
1959
|
-
id: '2',
|
|
1960
|
-
choices: [
|
|
1961
|
-
{
|
|
1962
|
-
index: 0,
|
|
1963
|
-
finish_reason: 'function_call',
|
|
1964
|
-
logprobs: null,
|
|
1965
|
-
delta: {
|
|
1966
|
-
role: 'assistant',
|
|
1967
|
-
content: null,
|
|
1968
|
-
tool_calls: [
|
|
1969
|
-
{
|
|
1970
|
-
type: 'function',
|
|
1971
|
-
index: 0,
|
|
1972
|
-
id: '1234',
|
|
1973
|
-
function: {
|
|
1974
|
-
arguments: '',
|
|
1975
|
-
name: 'getWeather',
|
|
1976
|
-
},
|
|
1977
|
-
},
|
|
1978
|
-
],
|
|
1979
|
-
},
|
|
1980
|
-
},
|
|
1981
|
-
],
|
|
1982
|
-
created: Math.floor(Date.now() / 1000),
|
|
1983
|
-
model: 'gpt-3.5-turbo',
|
|
1984
|
-
object: 'chat.completion.chunk',
|
|
1985
|
-
};
|
|
1986
|
-
}),
|
|
1987
|
-
handleRequest(async function* (request) {
|
|
1988
|
-
expect(request.messages).toEqual([
|
|
1989
|
-
{ role: 'user', content: 'tell me what the weather is like' },
|
|
1990
|
-
{
|
|
1991
|
-
role: 'assistant',
|
|
1992
|
-
content: null,
|
|
1993
|
-
tool_calls: [
|
|
1994
|
-
{
|
|
1995
|
-
type: 'function',
|
|
1996
|
-
id: '123',
|
|
1997
|
-
function: {
|
|
1998
|
-
arguments: '',
|
|
1999
|
-
name: 'get_weather',
|
|
2000
|
-
},
|
|
2001
|
-
},
|
|
2002
|
-
],
|
|
2003
|
-
},
|
|
2004
|
-
{
|
|
2005
|
-
role: 'tool',
|
|
2006
|
-
content: `Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
2007
|
-
tool_call_id: '123',
|
|
2008
|
-
},
|
|
2009
|
-
{
|
|
2010
|
-
role: 'assistant',
|
|
2011
|
-
content: null,
|
|
2012
|
-
tool_calls: [
|
|
2013
|
-
{
|
|
2014
|
-
type: 'function',
|
|
2015
|
-
id: '1234',
|
|
2016
|
-
function: {
|
|
2017
|
-
arguments: '',
|
|
2018
|
-
name: 'getWeather',
|
|
2019
|
-
},
|
|
2020
|
-
},
|
|
2021
|
-
],
|
|
2022
|
-
},
|
|
2023
|
-
{
|
|
2024
|
-
role: 'tool',
|
|
2025
|
-
content: `it's raining`,
|
|
2026
|
-
tool_call_id: '1234',
|
|
2027
|
-
},
|
|
2028
|
-
]);
|
|
2029
|
-
for (const choice of contentChoiceDeltas(`it's raining`)) {
|
|
2030
|
-
yield {
|
|
2031
|
-
id: '3',
|
|
2032
|
-
choices: [choice],
|
|
2033
|
-
created: Math.floor(Date.now() / 1000),
|
|
2034
|
-
model: 'gpt-3.5-turbo',
|
|
2035
|
-
object: 'chat.completion.chunk',
|
|
2036
|
-
};
|
|
2037
|
-
}
|
|
2038
|
-
}),
|
|
2039
|
-
runner.done(),
|
|
2040
|
-
]);
|
|
2041
|
-
expect(listener.eventMessages).toEqual([
|
|
2042
|
-
{
|
|
2043
|
-
role: 'assistant',
|
|
2044
|
-
content: null,
|
|
2045
|
-
tool_calls: [
|
|
2046
|
-
{
|
|
2047
|
-
type: 'function',
|
|
2048
|
-
id: '123',
|
|
2049
|
-
function: {
|
|
2050
|
-
arguments: '',
|
|
2051
|
-
name: 'get_weather',
|
|
2052
|
-
},
|
|
2053
|
-
},
|
|
2054
|
-
],
|
|
2055
|
-
},
|
|
2056
|
-
{
|
|
2057
|
-
role: 'tool',
|
|
2058
|
-
content: `Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
2059
|
-
tool_call_id: '123',
|
|
2060
|
-
},
|
|
2061
|
-
{
|
|
2062
|
-
role: 'assistant',
|
|
2063
|
-
content: null,
|
|
2064
|
-
tool_calls: [
|
|
2065
|
-
{
|
|
2066
|
-
type: 'function',
|
|
2067
|
-
id: '1234',
|
|
2068
|
-
function: {
|
|
2069
|
-
arguments: '',
|
|
2070
|
-
name: 'getWeather',
|
|
2071
|
-
},
|
|
2072
|
-
},
|
|
2073
|
-
],
|
|
2074
|
-
},
|
|
2075
|
-
{ role: 'tool', content: `it's raining`, tool_call_id: '1234' },
|
|
2076
|
-
{ role: 'assistant', content: "it's raining" },
|
|
2077
|
-
]);
|
|
2078
|
-
expect(listener.eventFunctionCallResults).toEqual([
|
|
2079
|
-
`Invalid tool_call: "get_weather". Available options are: "getWeather". Please try again`,
|
|
2080
|
-
`it's raining`,
|
|
2081
|
-
]);
|
|
2082
|
-
await listener.sanityCheck();
|
|
2083
|
-
});
|
|
2084
|
-
});
|
|
2085
|
-
describe('stream', () => {
|
|
2086
|
-
test('successful flow', async () => {
|
|
2087
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
2088
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
2089
|
-
const runner = openai.beta.chat.completions.stream({
|
|
2090
|
-
stream: true,
|
|
2091
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
2092
|
-
model: 'gpt-3.5-turbo',
|
|
2093
|
-
});
|
|
2094
|
-
const listener = new StreamingRunnerListener(runner);
|
|
2095
|
-
await Promise.all([
|
|
2096
|
-
handleRequest(async function* (request) {
|
|
2097
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
2098
|
-
for (const choice of contentChoiceDeltas(`The weather is great today!`)) {
|
|
2099
|
-
yield {
|
|
2100
|
-
id: '1',
|
|
2101
|
-
choices: [choice],
|
|
2102
|
-
created: Math.floor(Date.now() / 1000),
|
|
2103
|
-
model: 'gpt-3.5-turbo',
|
|
2104
|
-
object: 'chat.completion.chunk',
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
}),
|
|
2108
|
-
runner.done(),
|
|
2109
|
-
]);
|
|
2110
|
-
expect(listener.finalMessage).toEqual({ role: 'assistant', content: 'The weather is great today!' });
|
|
2111
|
-
await listener.sanityCheck();
|
|
2112
|
-
});
|
|
2113
|
-
test('toReadableStream and fromReadableStream', async () => {
|
|
2114
|
-
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
2115
|
-
const openai = new openai_1.default({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010', fetch });
|
|
2116
|
-
const runner = openai.beta.chat.completions.stream({
|
|
2117
|
-
stream: true,
|
|
2118
|
-
messages: [{ role: 'user', content: 'tell me what the weather is like' }],
|
|
2119
|
-
model: 'gpt-3.5-turbo',
|
|
2120
|
-
});
|
|
2121
|
-
const proxied = completions_1.ChatCompletionStreamingRunner.fromReadableStream(runner.toReadableStream());
|
|
2122
|
-
const listener = new StreamingRunnerListener(proxied);
|
|
2123
|
-
await Promise.all([
|
|
2124
|
-
handleRequest(async function* (request) {
|
|
2125
|
-
expect(request.messages).toEqual([{ role: 'user', content: 'tell me what the weather is like' }]);
|
|
2126
|
-
for (const choice of contentChoiceDeltas(`The weather is great today!`)) {
|
|
2127
|
-
yield {
|
|
2128
|
-
id: '1',
|
|
2129
|
-
choices: [choice],
|
|
2130
|
-
created: Math.floor(Date.now() / 1000),
|
|
2131
|
-
model: 'gpt-3.5-turbo',
|
|
2132
|
-
object: 'chat.completion.chunk',
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
}),
|
|
2136
|
-
proxied.done(),
|
|
2137
|
-
]);
|
|
2138
|
-
expect(listener.finalMessage).toEqual({ role: 'assistant', content: 'The weather is great today!' });
|
|
2139
|
-
await listener.sanityCheck();
|
|
2140
|
-
});
|
|
2141
|
-
test('handles network errors', async () => {
|
|
2142
|
-
const { fetch, handleRequest } = mockFetch();
|
|
2143
|
-
const openai = new openai_1.default({ apiKey: '...', fetch });
|
|
2144
|
-
const stream = openai.beta.chat.completions.stream({
|
|
2145
|
-
max_tokens: 1024,
|
|
2146
|
-
model: 'gpt-3.5-turbo',
|
|
2147
|
-
messages: [{ role: 'user', content: 'Say hello there!' }],
|
|
2148
|
-
}, { maxRetries: 0 });
|
|
2149
|
-
handleRequest(async () => {
|
|
2150
|
-
throw new Error('mock request error');
|
|
2151
|
-
}).catch(() => { });
|
|
2152
|
-
async function runStream() {
|
|
2153
|
-
await stream.done();
|
|
2154
|
-
}
|
|
2155
|
-
await expect(runStream).rejects.toThrow(error_1.APIConnectionError);
|
|
2156
|
-
});
|
|
2157
|
-
test('handles network errors on async iterator', async () => {
|
|
2158
|
-
const { fetch, handleRequest } = mockFetch();
|
|
2159
|
-
const openai = new openai_1.default({ apiKey: '...', fetch });
|
|
2160
|
-
const stream = openai.beta.chat.completions.stream({
|
|
2161
|
-
max_tokens: 1024,
|
|
2162
|
-
model: 'gpt-3.5-turbo',
|
|
2163
|
-
messages: [{ role: 'user', content: 'Say hello there!' }],
|
|
2164
|
-
}, { maxRetries: 0 });
|
|
2165
|
-
handleRequest(async () => {
|
|
2166
|
-
throw new Error('mock request error');
|
|
2167
|
-
}).catch(() => { });
|
|
2168
|
-
async function runStream() {
|
|
2169
|
-
for await (const _event of stream) {
|
|
2170
|
-
continue;
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
await expect(runStream).rejects.toThrow(error_1.APIConnectionError);
|
|
2174
|
-
});
|
|
2175
|
-
});
|
|
2176
|
-
});
|
|
2177
|
-
//# sourceMappingURL=ChatCompletionRunFunctions.test.js.map
|