@mastra/server 0.0.0-vector-sources-20250516175436 → 0.0.0-vector-extension-schema-20250922130418

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 (333) hide show
  1. package/CHANGELOG.md +3745 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +0 -5
  4. package/dist/{chunk-H5PTF3Y4.js → chunk-4QCXUEAT.js} +11 -2
  5. package/dist/chunk-4QCXUEAT.js.map +1 -0
  6. package/dist/chunk-4RRMWXQ2.js +3522 -0
  7. package/dist/chunk-4RRMWXQ2.js.map +1 -0
  8. package/dist/chunk-57HWW2TY.cjs +587 -0
  9. package/dist/chunk-57HWW2TY.cjs.map +1 -0
  10. package/dist/chunk-5DP5XZH6.cjs +928 -0
  11. package/dist/chunk-5DP5XZH6.cjs.map +1 -0
  12. package/dist/chunk-66YYHFGF.js +761 -0
  13. package/dist/chunk-66YYHFGF.js.map +1 -0
  14. package/dist/chunk-6GMFZ5LK.js +2774 -0
  15. package/dist/chunk-6GMFZ5LK.js.map +1 -0
  16. package/dist/chunk-743UIDHI.cjs +2013 -0
  17. package/dist/chunk-743UIDHI.cjs.map +1 -0
  18. package/dist/chunk-7JYXPDM4.js +15712 -0
  19. package/dist/chunk-7JYXPDM4.js.map +1 -0
  20. package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
  21. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  22. package/dist/chunk-7QEJ5QG5.js +151 -0
  23. package/dist/chunk-7QEJ5QG5.js.map +1 -0
  24. package/dist/chunk-A3AL7EWJ.js +83 -0
  25. package/dist/chunk-A3AL7EWJ.js.map +1 -0
  26. package/dist/chunk-AK2FXLLB.cjs +849 -0
  27. package/dist/chunk-AK2FXLLB.cjs.map +1 -0
  28. package/dist/{chunk-5SN4U5AC.cjs → chunk-AVEPEUN4.cjs} +115 -138
  29. package/dist/chunk-AVEPEUN4.cjs.map +1 -0
  30. package/dist/chunk-CNU4A2XU.js +129 -0
  31. package/dist/chunk-CNU4A2XU.js.map +1 -0
  32. package/dist/chunk-CY4TP3FK.js +16 -0
  33. package/dist/chunk-CY4TP3FK.js.map +1 -0
  34. package/dist/chunk-EMMSS5I5.cjs +37 -0
  35. package/dist/chunk-EMMSS5I5.cjs.map +1 -0
  36. package/dist/chunk-EMNGA4R4.js +845 -0
  37. package/dist/chunk-EMNGA4R4.js.map +1 -0
  38. package/dist/chunk-FALVL2VV.cjs +3525 -0
  39. package/dist/chunk-FALVL2VV.cjs.map +1 -0
  40. package/dist/chunk-FQNT7PI4.js +937 -0
  41. package/dist/chunk-FQNT7PI4.js.map +1 -0
  42. package/dist/chunk-G3PMV62Z.js +33 -0
  43. package/dist/chunk-G3PMV62Z.js.map +1 -0
  44. package/dist/chunk-G4PUALCE.cjs +28 -0
  45. package/dist/chunk-G4PUALCE.cjs.map +1 -0
  46. package/dist/chunk-G662L2YZ.js +568 -0
  47. package/dist/chunk-G662L2YZ.js.map +1 -0
  48. package/dist/chunk-GDWMF6SB.cjs +133 -0
  49. package/dist/chunk-GDWMF6SB.cjs.map +1 -0
  50. package/dist/chunk-GU4EWMZB.cjs +769 -0
  51. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  52. package/dist/chunk-GUI3CROV.cjs +159 -0
  53. package/dist/chunk-GUI3CROV.cjs.map +1 -0
  54. package/dist/chunk-HJQKWRKQ.cjs +764 -0
  55. package/dist/chunk-HJQKWRKQ.cjs.map +1 -0
  56. package/dist/{chunk-YWLUOY3D.cjs → chunk-HVBBFCDH.cjs} +1110 -793
  57. package/dist/chunk-HVBBFCDH.cjs.map +1 -0
  58. package/dist/chunk-HZJRQ5L3.cjs +1411 -0
  59. package/dist/chunk-HZJRQ5L3.cjs.map +1 -0
  60. package/dist/chunk-IGFMAZZ5.cjs +1150 -0
  61. package/dist/chunk-IGFMAZZ5.cjs.map +1 -0
  62. package/dist/chunk-ILESGJ6N.js +524 -0
  63. package/dist/chunk-ILESGJ6N.js.map +1 -0
  64. package/dist/chunk-IOQGI4ML.js +931 -0
  65. package/dist/chunk-IOQGI4ML.js.map +1 -0
  66. package/dist/chunk-J7BPKKOG.cjs +163 -0
  67. package/dist/chunk-J7BPKKOG.cjs.map +1 -0
  68. package/dist/{chunk-HFWCEP5S.js → chunk-JRDEOHAJ.js} +47 -14
  69. package/dist/chunk-JRDEOHAJ.js.map +1 -0
  70. package/dist/chunk-KNGXRN26.cjs +335 -0
  71. package/dist/chunk-KNGXRN26.cjs.map +1 -0
  72. package/dist/{chunk-OR3CIE2H.js → chunk-KV6VHX4V.js} +29 -7
  73. package/dist/chunk-KV6VHX4V.js.map +1 -0
  74. package/dist/chunk-L265APUD.cjs +69 -0
  75. package/dist/chunk-L265APUD.cjs.map +1 -0
  76. package/dist/chunk-LF2ZLOFP.js +767 -0
  77. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  78. package/dist/chunk-LYPU75T6.js +1147 -0
  79. package/dist/chunk-LYPU75T6.js.map +1 -0
  80. package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
  81. package/dist/chunk-MMROOK5J.js.map +1 -0
  82. package/dist/chunk-N35YCWQ5.cjs +540 -0
  83. package/dist/chunk-N35YCWQ5.cjs.map +1 -0
  84. package/dist/{chunk-LIVAK2DM.js → chunk-N7F33WAD.js} +1083 -794
  85. package/dist/chunk-N7F33WAD.js.map +1 -0
  86. package/dist/chunk-NG5IVLEZ.js +1012 -0
  87. package/dist/chunk-NG5IVLEZ.js.map +1 -0
  88. package/dist/chunk-NLWACBE7.cjs +128 -0
  89. package/dist/chunk-NLWACBE7.cjs.map +1 -0
  90. package/dist/chunk-OGW6HHVI.js +1408 -0
  91. package/dist/chunk-OGW6HHVI.js.map +1 -0
  92. package/dist/chunk-OJQOYXHU.cjs +15748 -0
  93. package/dist/chunk-OJQOYXHU.cjs.map +1 -0
  94. package/dist/chunk-OZLRIVC4.cjs +588 -0
  95. package/dist/chunk-OZLRIVC4.cjs.map +1 -0
  96. package/dist/chunk-P7CIEIJ3.js +925 -0
  97. package/dist/chunk-P7CIEIJ3.js.map +1 -0
  98. package/dist/chunk-P7RBMCBE.cjs +934 -0
  99. package/dist/chunk-P7RBMCBE.cjs.map +1 -0
  100. package/dist/chunk-PPYGWINI.cjs +2777 -0
  101. package/dist/chunk-PPYGWINI.cjs.map +1 -0
  102. package/dist/{chunk-P6SCPDYW.js → chunk-PUYSH3IL.js} +114 -137
  103. package/dist/chunk-PUYSH3IL.js.map +1 -0
  104. package/dist/{chunk-MHKNLNAN.cjs → chunk-PWTXZZTR.cjs} +33 -10
  105. package/dist/chunk-PWTXZZTR.cjs.map +1 -0
  106. package/dist/chunk-R7NOGUZG.js +65 -0
  107. package/dist/chunk-R7NOGUZG.js.map +1 -0
  108. package/dist/chunk-RCHEPTZZ.js +2006 -0
  109. package/dist/chunk-RCHEPTZZ.js.map +1 -0
  110. package/dist/chunk-RE4RPXT2.cjs +18 -0
  111. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  112. package/dist/chunk-SIGXR3JT.cjs +1043 -0
  113. package/dist/chunk-SIGXR3JT.cjs.map +1 -0
  114. package/dist/chunk-SPLSYTYW.cjs +88 -0
  115. package/dist/chunk-SPLSYTYW.cjs.map +1 -0
  116. package/dist/chunk-SQY4T6EJ.js +571 -0
  117. package/dist/chunk-SQY4T6EJ.js.map +1 -0
  118. package/dist/{chunk-TJKLBTFB.js → chunk-SYRRSBGL.js} +51 -27
  119. package/dist/chunk-SYRRSBGL.js.map +1 -0
  120. package/dist/{chunk-BNEY4P4P.cjs → chunk-T3TIA3O6.cjs} +20 -18
  121. package/dist/chunk-T3TIA3O6.cjs.map +1 -0
  122. package/dist/{chunk-EJO45KYT.js → chunk-TTHEEIZ3.js} +53 -50
  123. package/dist/chunk-TTHEEIZ3.js.map +1 -0
  124. package/dist/chunk-TVSIG4JE.cjs +940 -0
  125. package/dist/chunk-TVSIG4JE.cjs.map +1 -0
  126. package/dist/{chunk-55DOQLP6.js → chunk-WHN4VX55.js} +5 -3
  127. package/dist/chunk-WHN4VX55.js.map +1 -0
  128. package/dist/dist-26HWEQY6.js +3 -0
  129. package/dist/dist-26HWEQY6.js.map +1 -0
  130. package/dist/dist-3A5DXB37.cjs +20 -0
  131. package/dist/dist-3A5DXB37.cjs.map +1 -0
  132. package/dist/dist-3SJKQJGY.cjs +16 -0
  133. package/dist/dist-3SJKQJGY.cjs.map +1 -0
  134. package/dist/dist-4ZQSPE5K.js +3 -0
  135. package/dist/dist-4ZQSPE5K.js.map +1 -0
  136. package/dist/dist-5W5QNRTD.js +3 -0
  137. package/dist/dist-5W5QNRTD.js.map +1 -0
  138. package/dist/dist-653SRMPL.js +3 -0
  139. package/dist/dist-653SRMPL.js.map +1 -0
  140. package/dist/dist-6U6EFC5C.cjs +16 -0
  141. package/dist/dist-6U6EFC5C.cjs.map +1 -0
  142. package/dist/dist-7IHNNYMF.cjs +16 -0
  143. package/dist/dist-7IHNNYMF.cjs.map +1 -0
  144. package/dist/dist-B5IPRF6W.js +3 -0
  145. package/dist/dist-B5IPRF6W.js.map +1 -0
  146. package/dist/dist-EOMYFT4Y.cjs +16 -0
  147. package/dist/dist-EOMYFT4Y.cjs.map +1 -0
  148. package/dist/dist-EZZMMMNT.cjs +16 -0
  149. package/dist/dist-EZZMMMNT.cjs.map +1 -0
  150. package/dist/dist-F2ET4MNO.cjs +16 -0
  151. package/dist/dist-F2ET4MNO.cjs.map +1 -0
  152. package/dist/dist-H64VX6DE.js +3 -0
  153. package/dist/dist-H64VX6DE.js.map +1 -0
  154. package/dist/dist-HY7RMLJQ.cjs +16 -0
  155. package/dist/dist-HY7RMLJQ.cjs.map +1 -0
  156. package/dist/dist-M6S4P3FJ.js +3 -0
  157. package/dist/dist-M6S4P3FJ.js.map +1 -0
  158. package/dist/dist-NR7QSCQT.js +3 -0
  159. package/dist/dist-NR7QSCQT.js.map +1 -0
  160. package/dist/dist-QLFMCMCX.js +3 -0
  161. package/dist/dist-QLFMCMCX.js.map +1 -0
  162. package/dist/dist-UY46BFRP.js +3 -0
  163. package/dist/dist-UY46BFRP.js.map +1 -0
  164. package/dist/dist-WCQDRTIV.cjs +16 -0
  165. package/dist/dist-WCQDRTIV.cjs.map +1 -0
  166. package/dist/dist-WKYB3LTJ.cjs +16 -0
  167. package/dist/dist-WKYB3LTJ.cjs.map +1 -0
  168. package/dist/index.cjs +6 -0
  169. package/dist/index.cjs.map +1 -0
  170. package/dist/index.d.ts +1 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +5 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/server/a2a/protocol.d.ts +8 -0
  175. package/dist/server/a2a/protocol.d.ts.map +1 -0
  176. package/dist/server/a2a/store.cjs +25 -0
  177. package/dist/server/a2a/store.cjs.map +1 -0
  178. package/dist/server/a2a/store.d.ts +14 -0
  179. package/dist/server/a2a/store.d.ts.map +1 -0
  180. package/dist/server/a2a/store.js +23 -0
  181. package/dist/server/a2a/store.js.map +1 -0
  182. package/dist/server/a2a/tasks.d.ts +20 -0
  183. package/dist/server/a2a/tasks.d.ts.map +1 -0
  184. package/dist/server/handlers/a2a.cjs +13 -11
  185. package/dist/server/handlers/a2a.cjs.map +1 -0
  186. package/dist/server/handlers/a2a.d.ts +68 -6
  187. package/dist/server/handlers/a2a.d.ts.map +1 -0
  188. package/dist/server/handlers/a2a.js +3 -1
  189. package/dist/server/handlers/a2a.js.map +1 -0
  190. package/dist/server/handlers/agent-builder.cjs +68 -0
  191. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  192. package/dist/server/handlers/agent-builder.d.ts +88 -0
  193. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  194. package/dist/server/handlers/agent-builder.js +3 -0
  195. package/dist/server/handlers/agent-builder.js.map +1 -0
  196. package/dist/server/handlers/agents.cjs +41 -7
  197. package/dist/server/handlers/agents.cjs.map +1 -0
  198. package/dist/server/handlers/agents.d.ts +139 -6
  199. package/dist/server/handlers/agents.d.ts.map +1 -0
  200. package/dist/server/handlers/agents.js +3 -1
  201. package/dist/server/handlers/agents.js.map +1 -0
  202. package/dist/server/handlers/error.cjs +4 -2
  203. package/dist/server/handlers/error.cjs.map +1 -0
  204. package/dist/server/handlers/error.d.ts +2 -1
  205. package/dist/server/handlers/error.d.ts.map +1 -0
  206. package/dist/server/handlers/error.js +3 -1
  207. package/dist/server/handlers/error.js.map +1 -0
  208. package/dist/server/handlers/legacyWorkflows.cjs +48 -0
  209. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  210. package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
  211. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  212. package/dist/server/handlers/legacyWorkflows.js +3 -0
  213. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  214. package/dist/server/handlers/logs.cjs +6 -4
  215. package/dist/server/handlers/logs.cjs.map +1 -0
  216. package/dist/server/handlers/logs.d.ts +34 -3
  217. package/dist/server/handlers/logs.d.ts.map +1 -0
  218. package/dist/server/handlers/logs.js +3 -1
  219. package/dist/server/handlers/logs.js.map +1 -0
  220. package/dist/server/handlers/memory.cjs +39 -9
  221. package/dist/server/handlers/memory.cjs.map +1 -0
  222. package/dist/server/handlers/memory.d.ts +118 -8
  223. package/dist/server/handlers/memory.d.ts.map +1 -0
  224. package/dist/server/handlers/memory.js +3 -1
  225. package/dist/server/handlers/memory.js.map +1 -0
  226. package/dist/server/handlers/observability.cjs +16 -0
  227. package/dist/server/handlers/observability.cjs.map +1 -0
  228. package/dist/server/handlers/observability.d.ts +23 -0
  229. package/dist/server/handlers/observability.d.ts.map +1 -0
  230. package/dist/server/handlers/observability.js +3 -0
  231. package/dist/server/handlers/observability.js.map +1 -0
  232. package/dist/server/handlers/scores.cjs +32 -0
  233. package/dist/server/handlers/scores.cjs.map +1 -0
  234. package/dist/server/handlers/scores.d.ts +49 -0
  235. package/dist/server/handlers/scores.d.ts.map +1 -0
  236. package/dist/server/handlers/scores.js +3 -0
  237. package/dist/server/handlers/scores.js.map +1 -0
  238. package/dist/server/handlers/telemetry.cjs +9 -3
  239. package/dist/server/handlers/telemetry.cjs.map +1 -0
  240. package/dist/server/handlers/telemetry.d.ts +33 -2
  241. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  242. package/dist/server/handlers/telemetry.js +3 -1
  243. package/dist/server/handlers/telemetry.js.map +1 -0
  244. package/dist/server/handlers/tools.cjs +11 -5
  245. package/dist/server/handlers/tools.cjs.map +1 -0
  246. package/dist/server/handlers/tools.d.ts +25 -4
  247. package/dist/server/handlers/tools.d.ts.map +1 -0
  248. package/dist/server/handlers/tools.js +3 -1
  249. package/dist/server/handlers/tools.js.map +1 -0
  250. package/dist/server/handlers/utils.cjs +8 -2
  251. package/dist/server/handlers/utils.cjs.map +1 -0
  252. package/dist/server/handlers/utils.d.ts +8 -1
  253. package/dist/server/handlers/utils.d.ts.map +1 -0
  254. package/dist/server/handlers/utils.js +3 -1
  255. package/dist/server/handlers/utils.js.map +1 -0
  256. package/dist/server/handlers/vNextNetwork.cjs +220 -0
  257. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  258. package/dist/server/handlers/vNextNetwork.d.ts +246 -0
  259. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  260. package/dist/server/handlers/vNextNetwork.js +213 -0
  261. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  262. package/dist/server/handlers/vector.cjs +9 -7
  263. package/dist/server/handlers/vector.cjs.map +1 -0
  264. package/dist/server/handlers/vector.d.ts +51 -6
  265. package/dist/server/handlers/vector.d.ts.map +1 -0
  266. package/dist/server/handlers/vector.js +3 -1
  267. package/dist/server/handlers/vector.js.map +1 -0
  268. package/dist/server/handlers/voice.cjs +10 -4
  269. package/dist/server/handlers/voice.cjs.map +1 -0
  270. package/dist/server/handlers/voice.d.ts +41 -3
  271. package/dist/server/handlers/voice.d.ts.map +1 -0
  272. package/dist/server/handlers/voice.js +3 -1
  273. package/dist/server/handlers/voice.js.map +1 -0
  274. package/dist/server/handlers/workflows.cjs +43 -13
  275. package/dist/server/handlers/workflows.cjs.map +1 -0
  276. package/dist/server/handlers/workflows.d.ts +82 -10
  277. package/dist/server/handlers/workflows.d.ts.map +1 -0
  278. package/dist/server/handlers/workflows.js +3 -1
  279. package/dist/server/handlers/workflows.js.map +1 -0
  280. package/dist/server/handlers.cjs +44 -32
  281. package/dist/server/handlers.cjs.map +1 -0
  282. package/dist/server/handlers.d.ts +14 -11
  283. package/dist/server/handlers.d.ts.map +1 -0
  284. package/dist/server/handlers.js +15 -11
  285. package/dist/server/handlers.js.map +1 -0
  286. package/dist/server/http-exception.d.ts +87 -0
  287. package/dist/server/http-exception.d.ts.map +1 -0
  288. package/dist/server/types.d.ts +10 -0
  289. package/dist/server/types.d.ts.map +1 -0
  290. package/dist/server/utils.d.ts +44 -0
  291. package/dist/server/utils.d.ts.map +1 -0
  292. package/package.json +51 -21
  293. package/dist/_tsup-dts-rollup.d.cts +0 -816
  294. package/dist/_tsup-dts-rollup.d.ts +0 -816
  295. package/dist/chunk-57CJTIPW.cjs +0 -18
  296. package/dist/chunk-64U3UDTH.cjs +0 -13
  297. package/dist/chunk-75ZPJI57.cjs +0 -9
  298. package/dist/chunk-C7564HUT.js +0 -142
  299. package/dist/chunk-D4IRYCUI.cjs +0 -235
  300. package/dist/chunk-DJJIUEL2.js +0 -211
  301. package/dist/chunk-HWZVAG3H.js +0 -49
  302. package/dist/chunk-I2B73Y4I.cjs +0 -332
  303. package/dist/chunk-M5ABIP7D.js +0 -11
  304. package/dist/chunk-MIQYDLLM.js +0 -329
  305. package/dist/chunk-MLKGABMK.js +0 -7
  306. package/dist/chunk-OGCNNUHF.cjs +0 -54
  307. package/dist/chunk-UCTEMO2Q.cjs +0 -341
  308. package/dist/chunk-VPNDC2DI.cjs +0 -148
  309. package/dist/chunk-WUC6LSTW.js +0 -227
  310. package/dist/chunk-Y7UWRW5X.cjs +0 -221
  311. package/dist/chunk-YBVOQN4M.cjs +0 -94
  312. package/dist/chunk-ZE5AAC4I.cjs +0 -138
  313. package/dist/index.d.cts +0 -1
  314. package/dist/server/handlers/a2a.d.cts +0 -6
  315. package/dist/server/handlers/agents.d.cts +0 -6
  316. package/dist/server/handlers/error.d.cts +0 -1
  317. package/dist/server/handlers/logs.d.cts +0 -3
  318. package/dist/server/handlers/memory.d.cts +0 -8
  319. package/dist/server/handlers/network.cjs +0 -22
  320. package/dist/server/handlers/network.d.cts +0 -4
  321. package/dist/server/handlers/network.d.ts +0 -4
  322. package/dist/server/handlers/network.js +0 -1
  323. package/dist/server/handlers/telemetry.d.cts +0 -2
  324. package/dist/server/handlers/tools.d.cts +0 -4
  325. package/dist/server/handlers/utils.d.cts +0 -1
  326. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  327. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  328. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  329. package/dist/server/handlers/vNextWorkflows.js +0 -1
  330. package/dist/server/handlers/vector.d.cts +0 -6
  331. package/dist/server/handlers/voice.d.cts +0 -3
  332. package/dist/server/handlers/workflows.d.cts +0 -10
  333. package/dist/server/handlers.d.cts +0 -11
@@ -0,0 +1,845 @@
1
+ import { createJsonErrorResponseHandler, createProviderDefinedToolFactory, withoutTrailingSlash, loadApiKey, parseProviderOptions, postJsonToApi, createJsonResponseHandler, combineHeaders, generateId, createEventSourceResponseHandler, InvalidResponseDataError, isParsableJson, UnsupportedFunctionalityError, convertToBase64, NoSuchModelError, convertBase64ToUint8Array, postFormDataToApi } from './chunk-N7F33WAD.js';
2
+ import { z } from 'zod/v4';
3
+
4
+ function convertToGroqChatMessages(prompt) {
5
+ const messages = [];
6
+ for (const { role, content } of prompt) {
7
+ switch (role) {
8
+ case "system": {
9
+ messages.push({ role: "system", content });
10
+ break;
11
+ }
12
+ case "user": {
13
+ if (content.length === 1 && content[0].type === "text") {
14
+ messages.push({ role: "user", content: content[0].text });
15
+ break;
16
+ }
17
+ messages.push({
18
+ role: "user",
19
+ content: content.map((part) => {
20
+ switch (part.type) {
21
+ case "text": {
22
+ return { type: "text", text: part.text };
23
+ }
24
+ case "file": {
25
+ if (!part.mediaType.startsWith("image/")) {
26
+ throw new UnsupportedFunctionalityError({
27
+ functionality: "Non-image file content parts"
28
+ });
29
+ }
30
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
31
+ return {
32
+ type: "image_url",
33
+ image_url: {
34
+ url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
35
+ }
36
+ };
37
+ }
38
+ }
39
+ })
40
+ });
41
+ break;
42
+ }
43
+ case "assistant": {
44
+ let text = "";
45
+ let reasoning = "";
46
+ const toolCalls = [];
47
+ for (const part of content) {
48
+ switch (part.type) {
49
+ // groq supports reasoning for tool-calls in multi-turn conversations
50
+ // https://github.com/vercel/ai/issues/7860
51
+ case "reasoning": {
52
+ reasoning += part.text;
53
+ break;
54
+ }
55
+ case "text": {
56
+ text += part.text;
57
+ break;
58
+ }
59
+ case "tool-call": {
60
+ toolCalls.push({
61
+ id: part.toolCallId,
62
+ type: "function",
63
+ function: {
64
+ name: part.toolName,
65
+ arguments: JSON.stringify(part.input)
66
+ }
67
+ });
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ messages.push({
73
+ role: "assistant",
74
+ content: text,
75
+ ...reasoning.length > 0 ? { reasoning } : null,
76
+ ...toolCalls.length > 0 ? { tool_calls: toolCalls } : null
77
+ });
78
+ break;
79
+ }
80
+ case "tool": {
81
+ for (const toolResponse of content) {
82
+ const output = toolResponse.output;
83
+ let contentValue;
84
+ switch (output.type) {
85
+ case "text":
86
+ case "error-text":
87
+ contentValue = output.value;
88
+ break;
89
+ case "content":
90
+ case "json":
91
+ case "error-json":
92
+ contentValue = JSON.stringify(output.value);
93
+ break;
94
+ }
95
+ messages.push({
96
+ role: "tool",
97
+ tool_call_id: toolResponse.toolCallId,
98
+ content: contentValue
99
+ });
100
+ }
101
+ break;
102
+ }
103
+ default: {
104
+ const _exhaustiveCheck = role;
105
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
106
+ }
107
+ }
108
+ }
109
+ return messages;
110
+ }
111
+ function getResponseMetadata({
112
+ id,
113
+ model,
114
+ created
115
+ }) {
116
+ return {
117
+ id: id != null ? id : void 0,
118
+ modelId: model != null ? model : void 0,
119
+ timestamp: created != null ? new Date(created * 1e3) : void 0
120
+ };
121
+ }
122
+ var groqProviderOptions = z.object({
123
+ reasoningFormat: z.enum(["parsed", "raw", "hidden"]).optional(),
124
+ reasoningEffort: z.string().optional(),
125
+ /**
126
+ * Whether to enable parallel function calling during tool use. Default to true.
127
+ */
128
+ parallelToolCalls: z.boolean().optional(),
129
+ /**
130
+ * A unique identifier representing your end-user, which can help OpenAI to
131
+ * monitor and detect abuse. Learn more.
132
+ */
133
+ user: z.string().optional(),
134
+ /**
135
+ * Whether to use structured outputs.
136
+ *
137
+ * @default true
138
+ */
139
+ structuredOutputs: z.boolean().optional()
140
+ });
141
+ var groqErrorDataSchema = z.object({
142
+ error: z.object({
143
+ message: z.string(),
144
+ type: z.string()
145
+ })
146
+ });
147
+ var groqFailedResponseHandler = createJsonErrorResponseHandler({
148
+ errorSchema: groqErrorDataSchema,
149
+ errorToMessage: (data) => data.error.message
150
+ });
151
+ var BROWSER_SEARCH_SUPPORTED_MODELS = [
152
+ "openai/gpt-oss-20b",
153
+ "openai/gpt-oss-120b"
154
+ ];
155
+ function isBrowserSearchSupportedModel(modelId) {
156
+ return BROWSER_SEARCH_SUPPORTED_MODELS.includes(modelId);
157
+ }
158
+ function getSupportedModelsString() {
159
+ return BROWSER_SEARCH_SUPPORTED_MODELS.join(", ");
160
+ }
161
+ function prepareTools({
162
+ tools,
163
+ toolChoice,
164
+ modelId
165
+ }) {
166
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
167
+ const toolWarnings = [];
168
+ if (tools == null) {
169
+ return { tools: void 0, toolChoice: void 0, toolWarnings };
170
+ }
171
+ const groqTools2 = [];
172
+ for (const tool of tools) {
173
+ if (tool.type === "provider-defined") {
174
+ if (tool.id === "groq.browser_search") {
175
+ if (!isBrowserSearchSupportedModel(modelId)) {
176
+ toolWarnings.push({
177
+ type: "unsupported-tool",
178
+ tool,
179
+ details: `Browser search is only supported on the following models: ${getSupportedModelsString()}. Current model: ${modelId}`
180
+ });
181
+ } else {
182
+ groqTools2.push({
183
+ type: "browser_search"
184
+ });
185
+ }
186
+ } else {
187
+ toolWarnings.push({ type: "unsupported-tool", tool });
188
+ }
189
+ } else {
190
+ groqTools2.push({
191
+ type: "function",
192
+ function: {
193
+ name: tool.name,
194
+ description: tool.description,
195
+ parameters: tool.inputSchema
196
+ }
197
+ });
198
+ }
199
+ }
200
+ if (toolChoice == null) {
201
+ return { tools: groqTools2, toolChoice: void 0, toolWarnings };
202
+ }
203
+ const type = toolChoice.type;
204
+ switch (type) {
205
+ case "auto":
206
+ case "none":
207
+ case "required":
208
+ return { tools: groqTools2, toolChoice: type, toolWarnings };
209
+ case "tool":
210
+ return {
211
+ tools: groqTools2,
212
+ toolChoice: {
213
+ type: "function",
214
+ function: {
215
+ name: toolChoice.toolName
216
+ }
217
+ },
218
+ toolWarnings
219
+ };
220
+ default: {
221
+ const _exhaustiveCheck = type;
222
+ throw new UnsupportedFunctionalityError({
223
+ functionality: `tool choice type: ${_exhaustiveCheck}`
224
+ });
225
+ }
226
+ }
227
+ }
228
+ function mapGroqFinishReason(finishReason) {
229
+ switch (finishReason) {
230
+ case "stop":
231
+ return "stop";
232
+ case "length":
233
+ return "length";
234
+ case "content_filter":
235
+ return "content-filter";
236
+ case "function_call":
237
+ case "tool_calls":
238
+ return "tool-calls";
239
+ default:
240
+ return "unknown";
241
+ }
242
+ }
243
+ var GroqChatLanguageModel = class {
244
+ constructor(modelId, config) {
245
+ this.specificationVersion = "v2";
246
+ this.supportedUrls = {
247
+ "image/*": [/^https?:\/\/.*$/]
248
+ };
249
+ this.modelId = modelId;
250
+ this.config = config;
251
+ }
252
+ get provider() {
253
+ return this.config.provider;
254
+ }
255
+ async getArgs({
256
+ prompt,
257
+ maxOutputTokens,
258
+ temperature,
259
+ topP,
260
+ topK,
261
+ frequencyPenalty,
262
+ presencePenalty,
263
+ stopSequences,
264
+ responseFormat,
265
+ seed,
266
+ stream,
267
+ tools,
268
+ toolChoice,
269
+ providerOptions
270
+ }) {
271
+ var _a, _b;
272
+ const warnings = [];
273
+ const groqOptions = await parseProviderOptions({
274
+ provider: "groq",
275
+ providerOptions,
276
+ schema: groqProviderOptions
277
+ });
278
+ const structuredOutputs = (_a = groqOptions == null ? void 0 : groqOptions.structuredOutputs) != null ? _a : true;
279
+ if (topK != null) {
280
+ warnings.push({
281
+ type: "unsupported-setting",
282
+ setting: "topK"
283
+ });
284
+ }
285
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !structuredOutputs) {
286
+ warnings.push({
287
+ type: "unsupported-setting",
288
+ setting: "responseFormat",
289
+ details: "JSON response format schema is only supported with structuredOutputs"
290
+ });
291
+ }
292
+ const {
293
+ tools: groqTools2,
294
+ toolChoice: groqToolChoice,
295
+ toolWarnings
296
+ } = prepareTools({ tools, toolChoice, modelId: this.modelId });
297
+ return {
298
+ args: {
299
+ // model id:
300
+ model: this.modelId,
301
+ // model specific settings:
302
+ user: groqOptions == null ? void 0 : groqOptions.user,
303
+ parallel_tool_calls: groqOptions == null ? void 0 : groqOptions.parallelToolCalls,
304
+ // standardized settings:
305
+ max_tokens: maxOutputTokens,
306
+ temperature,
307
+ top_p: topP,
308
+ frequency_penalty: frequencyPenalty,
309
+ presence_penalty: presencePenalty,
310
+ stop: stopSequences,
311
+ seed,
312
+ // response format:
313
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
314
+ type: "json_schema",
315
+ json_schema: {
316
+ schema: responseFormat.schema,
317
+ name: (_b = responseFormat.name) != null ? _b : "response",
318
+ description: responseFormat.description
319
+ }
320
+ } : { type: "json_object" } : void 0,
321
+ // provider options:
322
+ reasoning_format: groqOptions == null ? void 0 : groqOptions.reasoningFormat,
323
+ reasoning_effort: groqOptions == null ? void 0 : groqOptions.reasoningEffort,
324
+ // messages:
325
+ messages: convertToGroqChatMessages(prompt),
326
+ // tools:
327
+ tools: groqTools2,
328
+ tool_choice: groqToolChoice
329
+ },
330
+ warnings: [...warnings, ...toolWarnings]
331
+ };
332
+ }
333
+ async doGenerate(options) {
334
+ var _a, _b, _c, _d, _e, _f, _g;
335
+ const { args, warnings } = await this.getArgs({
336
+ ...options,
337
+ stream: false
338
+ });
339
+ const body = JSON.stringify(args);
340
+ const {
341
+ responseHeaders,
342
+ value: response,
343
+ rawValue: rawResponse
344
+ } = await postJsonToApi({
345
+ url: this.config.url({
346
+ path: "/chat/completions",
347
+ modelId: this.modelId
348
+ }),
349
+ headers: combineHeaders(this.config.headers(), options.headers),
350
+ body: args,
351
+ failedResponseHandler: groqFailedResponseHandler,
352
+ successfulResponseHandler: createJsonResponseHandler(
353
+ groqChatResponseSchema
354
+ ),
355
+ abortSignal: options.abortSignal,
356
+ fetch: this.config.fetch
357
+ });
358
+ const choice = response.choices[0];
359
+ const content = [];
360
+ const text = choice.message.content;
361
+ if (text != null && text.length > 0) {
362
+ content.push({ type: "text", text });
363
+ }
364
+ const reasoning = choice.message.reasoning;
365
+ if (reasoning != null && reasoning.length > 0) {
366
+ content.push({
367
+ type: "reasoning",
368
+ text: reasoning
369
+ });
370
+ }
371
+ if (choice.message.tool_calls != null) {
372
+ for (const toolCall of choice.message.tool_calls) {
373
+ content.push({
374
+ type: "tool-call",
375
+ toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
376
+ toolName: toolCall.function.name,
377
+ input: toolCall.function.arguments
378
+ });
379
+ }
380
+ }
381
+ return {
382
+ content,
383
+ finishReason: mapGroqFinishReason(choice.finish_reason),
384
+ usage: {
385
+ inputTokens: (_c = (_b = response.usage) == null ? void 0 : _b.prompt_tokens) != null ? _c : void 0,
386
+ outputTokens: (_e = (_d = response.usage) == null ? void 0 : _d.completion_tokens) != null ? _e : void 0,
387
+ totalTokens: (_g = (_f = response.usage) == null ? void 0 : _f.total_tokens) != null ? _g : void 0
388
+ },
389
+ response: {
390
+ ...getResponseMetadata(response),
391
+ headers: responseHeaders,
392
+ body: rawResponse
393
+ },
394
+ warnings,
395
+ request: { body }
396
+ };
397
+ }
398
+ async doStream(options) {
399
+ const { args, warnings } = await this.getArgs({ ...options, stream: true });
400
+ const body = JSON.stringify({ ...args, stream: true });
401
+ const { responseHeaders, value: response } = await postJsonToApi({
402
+ url: this.config.url({
403
+ path: "/chat/completions",
404
+ modelId: this.modelId
405
+ }),
406
+ headers: combineHeaders(this.config.headers(), options.headers),
407
+ body: {
408
+ ...args,
409
+ stream: true
410
+ },
411
+ failedResponseHandler: groqFailedResponseHandler,
412
+ successfulResponseHandler: createEventSourceResponseHandler(groqChatChunkSchema),
413
+ abortSignal: options.abortSignal,
414
+ fetch: this.config.fetch
415
+ });
416
+ const toolCalls = [];
417
+ let finishReason = "unknown";
418
+ const usage = {
419
+ inputTokens: void 0,
420
+ outputTokens: void 0,
421
+ totalTokens: void 0
422
+ };
423
+ let isFirstChunk = true;
424
+ let isActiveText = false;
425
+ let isActiveReasoning = false;
426
+ return {
427
+ stream: response.pipeThrough(
428
+ new TransformStream({
429
+ start(controller) {
430
+ controller.enqueue({ type: "stream-start", warnings });
431
+ },
432
+ transform(chunk, controller) {
433
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
434
+ if (options.includeRawChunks) {
435
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
436
+ }
437
+ if (!chunk.success) {
438
+ finishReason = "error";
439
+ controller.enqueue({ type: "error", error: chunk.error });
440
+ return;
441
+ }
442
+ const value = chunk.value;
443
+ if ("error" in value) {
444
+ finishReason = "error";
445
+ controller.enqueue({ type: "error", error: value.error });
446
+ return;
447
+ }
448
+ if (isFirstChunk) {
449
+ isFirstChunk = false;
450
+ controller.enqueue({
451
+ type: "response-metadata",
452
+ ...getResponseMetadata(value)
453
+ });
454
+ }
455
+ if (((_a = value.x_groq) == null ? void 0 : _a.usage) != null) {
456
+ usage.inputTokens = (_b = value.x_groq.usage.prompt_tokens) != null ? _b : void 0;
457
+ usage.outputTokens = (_c = value.x_groq.usage.completion_tokens) != null ? _c : void 0;
458
+ usage.totalTokens = (_d = value.x_groq.usage.total_tokens) != null ? _d : void 0;
459
+ }
460
+ const choice = value.choices[0];
461
+ if ((choice == null ? void 0 : choice.finish_reason) != null) {
462
+ finishReason = mapGroqFinishReason(choice.finish_reason);
463
+ }
464
+ if ((choice == null ? void 0 : choice.delta) == null) {
465
+ return;
466
+ }
467
+ const delta = choice.delta;
468
+ if (delta.reasoning != null && delta.reasoning.length > 0) {
469
+ if (!isActiveReasoning) {
470
+ controller.enqueue({
471
+ type: "reasoning-start",
472
+ id: "reasoning-0"
473
+ });
474
+ isActiveReasoning = true;
475
+ }
476
+ controller.enqueue({
477
+ type: "reasoning-delta",
478
+ id: "reasoning-0",
479
+ delta: delta.reasoning
480
+ });
481
+ }
482
+ if (delta.content != null && delta.content.length > 0) {
483
+ if (!isActiveText) {
484
+ controller.enqueue({ type: "text-start", id: "txt-0" });
485
+ isActiveText = true;
486
+ }
487
+ controller.enqueue({
488
+ type: "text-delta",
489
+ id: "txt-0",
490
+ delta: delta.content
491
+ });
492
+ }
493
+ if (delta.tool_calls != null) {
494
+ for (const toolCallDelta of delta.tool_calls) {
495
+ const index = toolCallDelta.index;
496
+ if (toolCalls[index] == null) {
497
+ if (toolCallDelta.type !== "function") {
498
+ throw new InvalidResponseDataError({
499
+ data: toolCallDelta,
500
+ message: `Expected 'function' type.`
501
+ });
502
+ }
503
+ if (toolCallDelta.id == null) {
504
+ throw new InvalidResponseDataError({
505
+ data: toolCallDelta,
506
+ message: `Expected 'id' to be a string.`
507
+ });
508
+ }
509
+ if (((_e = toolCallDelta.function) == null ? void 0 : _e.name) == null) {
510
+ throw new InvalidResponseDataError({
511
+ data: toolCallDelta,
512
+ message: `Expected 'function.name' to be a string.`
513
+ });
514
+ }
515
+ controller.enqueue({
516
+ type: "tool-input-start",
517
+ id: toolCallDelta.id,
518
+ toolName: toolCallDelta.function.name
519
+ });
520
+ toolCalls[index] = {
521
+ id: toolCallDelta.id,
522
+ type: "function",
523
+ function: {
524
+ name: toolCallDelta.function.name,
525
+ arguments: (_f = toolCallDelta.function.arguments) != null ? _f : ""
526
+ },
527
+ hasFinished: false
528
+ };
529
+ const toolCall2 = toolCalls[index];
530
+ if (((_g = toolCall2.function) == null ? void 0 : _g.name) != null && ((_h = toolCall2.function) == null ? void 0 : _h.arguments) != null) {
531
+ if (toolCall2.function.arguments.length > 0) {
532
+ controller.enqueue({
533
+ type: "tool-input-delta",
534
+ id: toolCall2.id,
535
+ delta: toolCall2.function.arguments
536
+ });
537
+ }
538
+ if (isParsableJson(toolCall2.function.arguments)) {
539
+ controller.enqueue({
540
+ type: "tool-input-end",
541
+ id: toolCall2.id
542
+ });
543
+ controller.enqueue({
544
+ type: "tool-call",
545
+ toolCallId: (_i = toolCall2.id) != null ? _i : generateId(),
546
+ toolName: toolCall2.function.name,
547
+ input: toolCall2.function.arguments
548
+ });
549
+ toolCall2.hasFinished = true;
550
+ }
551
+ }
552
+ continue;
553
+ }
554
+ const toolCall = toolCalls[index];
555
+ if (toolCall.hasFinished) {
556
+ continue;
557
+ }
558
+ if (((_j = toolCallDelta.function) == null ? void 0 : _j.arguments) != null) {
559
+ toolCall.function.arguments += (_l = (_k = toolCallDelta.function) == null ? void 0 : _k.arguments) != null ? _l : "";
560
+ }
561
+ controller.enqueue({
562
+ type: "tool-input-delta",
563
+ id: toolCall.id,
564
+ delta: (_m = toolCallDelta.function.arguments) != null ? _m : ""
565
+ });
566
+ if (((_n = toolCall.function) == null ? void 0 : _n.name) != null && ((_o = toolCall.function) == null ? void 0 : _o.arguments) != null && isParsableJson(toolCall.function.arguments)) {
567
+ controller.enqueue({
568
+ type: "tool-input-end",
569
+ id: toolCall.id
570
+ });
571
+ controller.enqueue({
572
+ type: "tool-call",
573
+ toolCallId: (_p = toolCall.id) != null ? _p : generateId(),
574
+ toolName: toolCall.function.name,
575
+ input: toolCall.function.arguments
576
+ });
577
+ toolCall.hasFinished = true;
578
+ }
579
+ }
580
+ }
581
+ },
582
+ flush(controller) {
583
+ if (isActiveReasoning) {
584
+ controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
585
+ }
586
+ if (isActiveText) {
587
+ controller.enqueue({ type: "text-end", id: "txt-0" });
588
+ }
589
+ controller.enqueue({
590
+ type: "finish",
591
+ finishReason,
592
+ usage,
593
+ ...{}
594
+ });
595
+ }
596
+ })
597
+ ),
598
+ request: { body },
599
+ response: { headers: responseHeaders }
600
+ };
601
+ }
602
+ };
603
+ var groqChatResponseSchema = z.object({
604
+ id: z.string().nullish(),
605
+ created: z.number().nullish(),
606
+ model: z.string().nullish(),
607
+ choices: z.array(
608
+ z.object({
609
+ message: z.object({
610
+ content: z.string().nullish(),
611
+ reasoning: z.string().nullish(),
612
+ tool_calls: z.array(
613
+ z.object({
614
+ id: z.string().nullish(),
615
+ type: z.literal("function"),
616
+ function: z.object({
617
+ name: z.string(),
618
+ arguments: z.string()
619
+ })
620
+ })
621
+ ).nullish()
622
+ }),
623
+ index: z.number(),
624
+ finish_reason: z.string().nullish()
625
+ })
626
+ ),
627
+ usage: z.object({
628
+ prompt_tokens: z.number().nullish(),
629
+ completion_tokens: z.number().nullish(),
630
+ total_tokens: z.number().nullish()
631
+ }).nullish()
632
+ });
633
+ var groqChatChunkSchema = z.union([
634
+ z.object({
635
+ id: z.string().nullish(),
636
+ created: z.number().nullish(),
637
+ model: z.string().nullish(),
638
+ choices: z.array(
639
+ z.object({
640
+ delta: z.object({
641
+ content: z.string().nullish(),
642
+ reasoning: z.string().nullish(),
643
+ tool_calls: z.array(
644
+ z.object({
645
+ index: z.number(),
646
+ id: z.string().nullish(),
647
+ type: z.literal("function").optional(),
648
+ function: z.object({
649
+ name: z.string().nullish(),
650
+ arguments: z.string().nullish()
651
+ })
652
+ })
653
+ ).nullish()
654
+ }).nullish(),
655
+ finish_reason: z.string().nullable().optional(),
656
+ index: z.number()
657
+ })
658
+ ),
659
+ x_groq: z.object({
660
+ usage: z.object({
661
+ prompt_tokens: z.number().nullish(),
662
+ completion_tokens: z.number().nullish(),
663
+ total_tokens: z.number().nullish()
664
+ }).nullish()
665
+ }).nullish()
666
+ }),
667
+ groqErrorDataSchema
668
+ ]);
669
+ var groqProviderOptionsSchema = z.object({
670
+ language: z.string().nullish(),
671
+ prompt: z.string().nullish(),
672
+ responseFormat: z.string().nullish(),
673
+ temperature: z.number().min(0).max(1).nullish(),
674
+ timestampGranularities: z.array(z.string()).nullish()
675
+ });
676
+ var GroqTranscriptionModel = class {
677
+ constructor(modelId, config) {
678
+ this.modelId = modelId;
679
+ this.config = config;
680
+ this.specificationVersion = "v2";
681
+ }
682
+ get provider() {
683
+ return this.config.provider;
684
+ }
685
+ async getArgs({
686
+ audio,
687
+ mediaType,
688
+ providerOptions
689
+ }) {
690
+ var _a, _b, _c, _d, _e;
691
+ const warnings = [];
692
+ const groqOptions = await parseProviderOptions({
693
+ provider: "groq",
694
+ providerOptions,
695
+ schema: groqProviderOptionsSchema
696
+ });
697
+ const formData = new FormData();
698
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
699
+ formData.append("model", this.modelId);
700
+ formData.append("file", new File([blob], "audio", { type: mediaType }));
701
+ if (groqOptions) {
702
+ const transcriptionModelOptions = {
703
+ language: (_a = groqOptions.language) != null ? _a : void 0,
704
+ prompt: (_b = groqOptions.prompt) != null ? _b : void 0,
705
+ response_format: (_c = groqOptions.responseFormat) != null ? _c : void 0,
706
+ temperature: (_d = groqOptions.temperature) != null ? _d : void 0,
707
+ timestamp_granularities: (_e = groqOptions.timestampGranularities) != null ? _e : void 0
708
+ };
709
+ for (const key in transcriptionModelOptions) {
710
+ const value = transcriptionModelOptions[key];
711
+ if (value !== void 0) {
712
+ formData.append(key, String(value));
713
+ }
714
+ }
715
+ }
716
+ return {
717
+ formData,
718
+ warnings
719
+ };
720
+ }
721
+ async doGenerate(options) {
722
+ var _a, _b, _c, _d, _e;
723
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
724
+ const { formData, warnings } = await this.getArgs(options);
725
+ const {
726
+ value: response,
727
+ responseHeaders,
728
+ rawValue: rawResponse
729
+ } = await postFormDataToApi({
730
+ url: this.config.url({
731
+ path: "/audio/transcriptions",
732
+ modelId: this.modelId
733
+ }),
734
+ headers: combineHeaders(this.config.headers(), options.headers),
735
+ formData,
736
+ failedResponseHandler: groqFailedResponseHandler,
737
+ successfulResponseHandler: createJsonResponseHandler(
738
+ groqTranscriptionResponseSchema
739
+ ),
740
+ abortSignal: options.abortSignal,
741
+ fetch: this.config.fetch
742
+ });
743
+ return {
744
+ text: response.text,
745
+ segments: (_e = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
746
+ text: segment.text,
747
+ startSecond: segment.start,
748
+ endSecond: segment.end
749
+ }))) != null ? _e : [],
750
+ language: response.language,
751
+ durationInSeconds: response.duration,
752
+ warnings,
753
+ response: {
754
+ timestamp: currentDate,
755
+ modelId: this.modelId,
756
+ headers: responseHeaders,
757
+ body: rawResponse
758
+ }
759
+ };
760
+ }
761
+ };
762
+ var groqTranscriptionResponseSchema = z.object({
763
+ task: z.string(),
764
+ language: z.string(),
765
+ duration: z.number(),
766
+ text: z.string(),
767
+ segments: z.array(
768
+ z.object({
769
+ id: z.number(),
770
+ seek: z.number(),
771
+ start: z.number(),
772
+ end: z.number(),
773
+ text: z.string(),
774
+ tokens: z.array(z.number()),
775
+ temperature: z.number(),
776
+ avg_logprob: z.number(),
777
+ compression_ratio: z.number(),
778
+ no_speech_prob: z.number()
779
+ })
780
+ ),
781
+ x_groq: z.object({
782
+ id: z.string()
783
+ })
784
+ });
785
+ var browserSearch = createProviderDefinedToolFactory({
786
+ id: "groq.browser_search",
787
+ name: "browser_search",
788
+ inputSchema: z.object({})
789
+ });
790
+ var groqTools = {
791
+ browserSearch
792
+ };
793
+ function createGroq(options = {}) {
794
+ var _a;
795
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.groq.com/openai/v1";
796
+ const getHeaders = () => ({
797
+ Authorization: `Bearer ${loadApiKey({
798
+ apiKey: options.apiKey,
799
+ environmentVariableName: "GROQ_API_KEY",
800
+ description: "Groq"
801
+ })}`,
802
+ ...options.headers
803
+ });
804
+ const createChatModel = (modelId) => new GroqChatLanguageModel(modelId, {
805
+ provider: "groq.chat",
806
+ url: ({ path }) => `${baseURL}${path}`,
807
+ headers: getHeaders,
808
+ fetch: options.fetch
809
+ });
810
+ const createLanguageModel = (modelId) => {
811
+ if (new.target) {
812
+ throw new Error(
813
+ "The Groq model function cannot be called with the new keyword."
814
+ );
815
+ }
816
+ return createChatModel(modelId);
817
+ };
818
+ const createTranscriptionModel = (modelId) => {
819
+ return new GroqTranscriptionModel(modelId, {
820
+ provider: "groq.transcription",
821
+ url: ({ path }) => `${baseURL}${path}`,
822
+ headers: getHeaders,
823
+ fetch: options.fetch
824
+ });
825
+ };
826
+ const provider = function(modelId) {
827
+ return createLanguageModel(modelId);
828
+ };
829
+ provider.languageModel = createLanguageModel;
830
+ provider.chat = createChatModel;
831
+ provider.textEmbeddingModel = (modelId) => {
832
+ throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
833
+ };
834
+ provider.imageModel = (modelId) => {
835
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
836
+ };
837
+ provider.transcription = createTranscriptionModel;
838
+ provider.tools = groqTools;
839
+ return provider;
840
+ }
841
+ var groq = createGroq();
842
+
843
+ export { browserSearch, createGroq, groq };
844
+ //# sourceMappingURL=chunk-EMNGA4R4.js.map
845
+ //# sourceMappingURL=chunk-EMNGA4R4.js.map