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