@llumiverse/drivers 1.2.0 → 1.4.0-dev.20260629.090753Z

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 (403) hide show
  1. package/lib/{types/adobe → adobe}/firefly.d.ts +2 -1
  2. package/lib/adobe/firefly.d.ts.map +1 -0
  3. package/lib/adobe/firefly.js +120 -0
  4. package/lib/adobe/firefly.js.map +1 -0
  5. package/lib/anthropic/index.d.ts +23 -0
  6. package/lib/anthropic/index.d.ts.map +1 -0
  7. package/lib/anthropic/index.js +68 -0
  8. package/lib/anthropic/index.js.map +1 -0
  9. package/lib/{types/azure → azure}/azure_foundry.d.ts +9 -7
  10. package/lib/azure/azure_foundry.d.ts.map +1 -0
  11. package/lib/{esm/azure → azure}/azure_foundry.js +138 -124
  12. package/lib/azure/azure_foundry.js.map +1 -0
  13. package/lib/{types/bedrock → bedrock}/converse.d.ts +2 -2
  14. package/lib/bedrock/converse.d.ts.map +1 -0
  15. package/lib/{esm/bedrock → bedrock}/converse.js +86 -79
  16. package/lib/bedrock/converse.js.map +1 -0
  17. package/lib/bedrock/embeddings.d.ts +4 -0
  18. package/lib/bedrock/embeddings.d.ts.map +1 -0
  19. package/lib/bedrock/embeddings.js +359 -0
  20. package/lib/bedrock/embeddings.js.map +1 -0
  21. package/lib/{types/bedrock → bedrock}/index.d.ts +33 -9
  22. package/lib/bedrock/index.d.ts.map +1 -0
  23. package/lib/{esm/bedrock → bedrock}/index.js +599 -324
  24. package/lib/bedrock/index.js.map +1 -0
  25. package/lib/{types/bedrock → bedrock}/nova-image-payload.d.ts +5 -5
  26. package/lib/bedrock/nova-image-payload.d.ts.map +1 -0
  27. package/lib/{esm/bedrock → bedrock}/nova-image-payload.js +31 -36
  28. package/lib/bedrock/nova-image-payload.js.map +1 -0
  29. package/lib/{types/bedrock → bedrock}/payloads.d.ts +1 -1
  30. package/lib/bedrock/payloads.d.ts.map +1 -0
  31. package/lib/{cjs/bedrock → bedrock}/payloads.js.map +1 -1
  32. package/lib/{types/bedrock → bedrock}/s3.d.ts +3 -2
  33. package/lib/bedrock/s3.d.ts.map +1 -0
  34. package/lib/{esm/bedrock → bedrock}/s3.js +27 -23
  35. package/lib/bedrock/s3.js.map +1 -0
  36. package/lib/{types/bedrock → bedrock}/twelvelabs.d.ts +8 -9
  37. package/lib/bedrock/twelvelabs.d.ts.map +1 -0
  38. package/lib/{esm/bedrock → bedrock}/twelvelabs.js +17 -21
  39. package/lib/bedrock/twelvelabs.js.map +1 -0
  40. package/lib/{types/groq → groq}/index.d.ts +6 -4
  41. package/lib/groq/index.d.ts.map +1 -0
  42. package/lib/{esm/groq → groq}/index.js +72 -39
  43. package/lib/groq/index.js.map +1 -0
  44. package/lib/{types/huggingface_ie.d.ts → huggingface_ie.d.ts} +4 -3
  45. package/lib/huggingface_ie.d.ts.map +1 -0
  46. package/lib/{esm/huggingface_ie.js → huggingface_ie.js} +32 -31
  47. package/lib/huggingface_ie.js.map +1 -0
  48. package/lib/index.d.ts +16 -0
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/index.js +16 -0
  51. package/lib/index.js.map +1 -0
  52. package/lib/{types/mistral → mistral}/index.d.ts +6 -5
  53. package/lib/mistral/index.d.ts.map +1 -0
  54. package/lib/{esm/mistral → mistral}/index.js +66 -38
  55. package/lib/mistral/index.js.map +1 -0
  56. package/lib/{types/mistral → mistral}/types.d.ts +1 -0
  57. package/lib/mistral/types.d.ts.map +1 -0
  58. package/lib/mistral/types.js.map +1 -0
  59. package/lib/{types/openai → openai}/azure_openai.d.ts +5 -4
  60. package/lib/openai/azure_openai.d.ts.map +1 -0
  61. package/lib/{esm/openai → openai}/azure_openai.js +17 -14
  62. package/lib/openai/azure_openai.js.map +1 -0
  63. package/lib/openai/drivers.d.ts +4 -0
  64. package/lib/openai/drivers.d.ts.map +1 -0
  65. package/lib/openai/drivers.js +9 -0
  66. package/lib/openai/drivers.js.map +1 -0
  67. package/lib/{types/openai → openai}/index.d.ts +17 -5
  68. package/lib/openai/index.d.ts.map +1 -0
  69. package/lib/{esm/openai → openai}/index.js +254 -148
  70. package/lib/openai/index.js.map +1 -0
  71. package/lib/{types/openai → openai}/openai.d.ts +3 -3
  72. package/lib/openai/openai.d.ts.map +1 -0
  73. package/lib/openai/openai.js +15 -0
  74. package/lib/openai/openai.js.map +1 -0
  75. package/lib/{types/openai → openai}/openai_compatible.d.ts +3 -3
  76. package/lib/openai/openai_compatible.d.ts.map +1 -0
  77. package/lib/{esm/openai → openai}/openai_compatible.js +14 -11
  78. package/lib/openai/openai_compatible.js.map +1 -0
  79. package/lib/{types/openai → openai}/openai_format.d.ts +3 -2
  80. package/lib/openai/openai_format.d.ts.map +1 -0
  81. package/lib/{esm/openai → openai}/openai_format.js +66 -24
  82. package/lib/openai/openai_format.js.map +1 -0
  83. package/lib/{types/replicate.d.ts → replicate.d.ts} +3 -2
  84. package/lib/replicate.d.ts.map +1 -0
  85. package/lib/{esm/replicate.js → replicate.js} +59 -49
  86. package/lib/replicate.js.map +1 -0
  87. package/lib/shared/claude-messages.d.ts +99 -0
  88. package/lib/shared/claude-messages.d.ts.map +1 -0
  89. package/lib/shared/claude-messages.js +869 -0
  90. package/lib/shared/claude-messages.js.map +1 -0
  91. package/lib/{types/shared → shared}/claude-thinking.d.ts +1 -1
  92. package/lib/shared/claude-thinking.d.ts.map +1 -0
  93. package/lib/{esm/shared → shared}/claude-thinking.js +5 -7
  94. package/lib/shared/claude-thinking.js.map +1 -0
  95. package/lib/shared/debug-prompt.d.ts +5 -0
  96. package/lib/shared/debug-prompt.d.ts.map +1 -0
  97. package/lib/shared/debug-prompt.js +25 -0
  98. package/lib/shared/debug-prompt.js.map +1 -0
  99. package/lib/{types/test-driver → test-driver}/TestErrorCompletionStream.d.ts +1 -1
  100. package/lib/test-driver/TestErrorCompletionStream.d.ts.map +1 -0
  101. package/lib/test-driver/TestErrorCompletionStream.js +16 -0
  102. package/lib/test-driver/TestErrorCompletionStream.js.map +1 -0
  103. package/lib/{types/test-driver → test-driver}/TestValidationErrorCompletionStream.d.ts +1 -1
  104. package/lib/test-driver/TestValidationErrorCompletionStream.d.ts.map +1 -0
  105. package/lib/{esm/test-driver → test-driver}/TestValidationErrorCompletionStream.js +4 -4
  106. package/lib/test-driver/TestValidationErrorCompletionStream.js.map +1 -0
  107. package/lib/{types/test-driver → test-driver}/index.d.ts +3 -3
  108. package/lib/test-driver/index.d.ts.map +1 -0
  109. package/lib/{esm/test-driver → test-driver}/index.js +20 -20
  110. package/lib/test-driver/index.js.map +1 -0
  111. package/lib/{types/test-driver → test-driver}/utils.d.ts +1 -1
  112. package/lib/test-driver/utils.d.ts.map +1 -0
  113. package/lib/{esm/test-driver → test-driver}/utils.js +4 -4
  114. package/lib/test-driver/utils.js.map +1 -0
  115. package/lib/togetherai/index.d.ts +15 -0
  116. package/lib/togetherai/index.d.ts.map +1 -0
  117. package/lib/togetherai/index.js +54 -0
  118. package/lib/togetherai/index.js.map +1 -0
  119. package/lib/{types/togetherai → togetherai}/interfaces.d.ts +1 -1
  120. package/lib/togetherai/interfaces.d.ts.map +1 -0
  121. package/lib/{cjs/watsonx → togetherai}/interfaces.js.map +1 -1
  122. package/lib/vertexai/debug.d.ts +2 -0
  123. package/lib/vertexai/debug.d.ts.map +1 -0
  124. package/lib/{esm/vertexai → vertexai}/debug.js +1 -1
  125. package/lib/vertexai/debug.js.map +1 -0
  126. package/lib/vertexai/embeddings/embed-legacy-multimodal.d.ts +9 -0
  127. package/lib/vertexai/embeddings/embed-legacy-multimodal.d.ts.map +1 -0
  128. package/lib/vertexai/embeddings/embed-legacy-multimodal.js +141 -0
  129. package/lib/vertexai/embeddings/embed-legacy-multimodal.js.map +1 -0
  130. package/lib/vertexai/embeddings/embed.d.ts +13 -0
  131. package/lib/vertexai/embeddings/embed.d.ts.map +1 -0
  132. package/lib/vertexai/embeddings/embed.js +162 -0
  133. package/lib/vertexai/embeddings/embed.js.map +1 -0
  134. package/lib/vertexai/embeddings/source-utils.d.ts +9 -0
  135. package/lib/vertexai/embeddings/source-utils.d.ts.map +1 -0
  136. package/lib/vertexai/embeddings/source-utils.js +18 -0
  137. package/lib/vertexai/embeddings/source-utils.js.map +1 -0
  138. package/lib/{types/vertexai → vertexai}/index.d.ts +31 -19
  139. package/lib/vertexai/index.d.ts.map +1 -0
  140. package/lib/{esm/vertexai → vertexai}/index.js +221 -159
  141. package/lib/vertexai/index.js.map +1 -0
  142. package/lib/vertexai/models/claude.d.ts +16 -0
  143. package/lib/vertexai/models/claude.d.ts.map +1 -0
  144. package/lib/vertexai/models/claude.js +65 -0
  145. package/lib/vertexai/models/claude.js.map +1 -0
  146. package/lib/{types/vertexai → vertexai}/models/gemini.d.ts +29 -5
  147. package/lib/vertexai/models/gemini.d.ts.map +1 -0
  148. package/lib/{esm/vertexai → vertexai}/models/gemini.js +255 -127
  149. package/lib/vertexai/models/gemini.js.map +1 -0
  150. package/lib/{types/vertexai → vertexai}/models/imagen.d.ts +12 -11
  151. package/lib/vertexai/models/imagen.d.ts.map +1 -0
  152. package/lib/{esm/vertexai → vertexai}/models/imagen.js +74 -47
  153. package/lib/vertexai/models/imagen.js.map +1 -0
  154. package/lib/{types/vertexai → vertexai}/models/llama.d.ts +4 -4
  155. package/lib/vertexai/models/llama.d.ts.map +1 -0
  156. package/lib/{esm/vertexai → vertexai}/models/llama.js +37 -33
  157. package/lib/vertexai/models/llama.js.map +1 -0
  158. package/lib/vertexai/models.d.ts +21 -0
  159. package/lib/vertexai/models.d.ts.map +1 -0
  160. package/lib/{esm/vertexai → vertexai}/models.js +12 -9
  161. package/lib/vertexai/models.js.map +1 -0
  162. package/lib/{types/watsonx → watsonx}/index.d.ts +4 -3
  163. package/lib/watsonx/index.d.ts.map +1 -0
  164. package/lib/{esm/watsonx → watsonx}/index.js +69 -41
  165. package/lib/watsonx/index.js.map +1 -0
  166. package/lib/watsonx/interfaces.d.ts.map +1 -0
  167. package/lib/{esm/watsonx → watsonx}/interfaces.js.map +1 -1
  168. package/lib/{types/xai → xai}/index.d.ts +4 -4
  169. package/lib/xai/index.d.ts.map +1 -0
  170. package/lib/{esm/xai → xai}/index.js +22 -18
  171. package/lib/xai/index.js.map +1 -0
  172. package/package.json +88 -36
  173. package/src/adobe/firefly.ts +60 -43
  174. package/src/anthropic/index.ts +121 -0
  175. package/src/azure/azure_foundry.ts +210 -165
  176. package/src/bedrock/converse.ts +124 -101
  177. package/src/bedrock/embeddings.test.ts +508 -0
  178. package/src/bedrock/embeddings.ts +517 -0
  179. package/src/bedrock/error-handling.test.ts +62 -14
  180. package/src/bedrock/index.ts +832 -466
  181. package/src/bedrock/nova-image-payload.ts +98 -91
  182. package/src/bedrock/payloads.ts +9 -9
  183. package/src/bedrock/s3.test.ts +39 -0
  184. package/src/bedrock/s3.ts +57 -38
  185. package/src/bedrock/streaming-tool-use.test.ts +86 -69
  186. package/src/bedrock/twelvelabs.ts +35 -32
  187. package/src/groq/index.ts +143 -60
  188. package/src/http-timeout-wiring.test.ts +263 -0
  189. package/src/huggingface_ie.ts +45 -61
  190. package/src/index.ts +15 -15
  191. package/src/mistral/index.ts +97 -48
  192. package/src/mistral/types.ts +13 -12
  193. package/src/openai/azure_openai.ts +35 -27
  194. package/src/openai/drivers.ts +9 -0
  195. package/src/openai/error-handling.test.ts +308 -113
  196. package/src/openai/index.ts +389 -254
  197. package/src/openai/openai.ts +6 -13
  198. package/src/openai/openai_compatible.ts +35 -25
  199. package/src/openai/openai_format.ts +90 -40
  200. package/src/replicate.ts +108 -86
  201. package/src/shared/claude-messages.test.ts +37 -0
  202. package/src/shared/claude-messages.ts +1085 -0
  203. package/src/shared/claude-thinking.ts +6 -12
  204. package/src/shared/debug-prompt.ts +28 -0
  205. package/src/test-driver/TestErrorCompletionStream.ts +9 -10
  206. package/src/test-driver/TestValidationErrorCompletionStream.ts +9 -10
  207. package/src/test-driver/index.ts +43 -27
  208. package/src/test-driver/utils.ts +8 -8
  209. package/src/togetherai/index.test.ts +32 -0
  210. package/src/togetherai/index.ts +64 -128
  211. package/src/togetherai/interfaces.ts +5 -5
  212. package/src/vertexai/debug.ts +3 -3
  213. package/src/vertexai/embeddings/embed-legacy-multimodal.ts +211 -0
  214. package/src/vertexai/embeddings/embed.ts +206 -0
  215. package/src/vertexai/embeddings/embeddings.test.ts +497 -0
  216. package/src/vertexai/embeddings/source-utils.test.ts +54 -0
  217. package/src/vertexai/embeddings/source-utils.ts +29 -0
  218. package/src/vertexai/index.ts +339 -253
  219. package/src/vertexai/models/claude-error-handling.test.ts +86 -39
  220. package/src/vertexai/models/claude-streaming-spacing.test.ts +82 -75
  221. package/src/vertexai/models/claude.ts +84 -1041
  222. package/src/vertexai/models/gemini-conversation-mutation.test.ts +65 -23
  223. package/src/vertexai/models/gemini-error-handling.test.ts +126 -10
  224. package/src/vertexai/models/gemini-orphaned-tool-result.test.ts +118 -0
  225. package/src/vertexai/models/gemini.ts +372 -182
  226. package/src/vertexai/models/imagen.ts +164 -100
  227. package/src/vertexai/models/llama.ts +70 -48
  228. package/src/vertexai/models.ts +36 -16
  229. package/src/watsonx/index.ts +101 -65
  230. package/src/watsonx/interfaces.ts +10 -15
  231. package/src/xai/index.ts +30 -30
  232. package/lib/cjs/adobe/firefly.js +0 -120
  233. package/lib/cjs/adobe/firefly.js.map +0 -1
  234. package/lib/cjs/azure/azure_foundry.js +0 -432
  235. package/lib/cjs/azure/azure_foundry.js.map +0 -1
  236. package/lib/cjs/bedrock/converse.js +0 -359
  237. package/lib/cjs/bedrock/converse.js.map +0 -1
  238. package/lib/cjs/bedrock/index.js +0 -1508
  239. package/lib/cjs/bedrock/index.js.map +0 -1
  240. package/lib/cjs/bedrock/nova-image-payload.js +0 -207
  241. package/lib/cjs/bedrock/nova-image-payload.js.map +0 -1
  242. package/lib/cjs/bedrock/payloads.js +0 -3
  243. package/lib/cjs/bedrock/s3.js +0 -107
  244. package/lib/cjs/bedrock/s3.js.map +0 -1
  245. package/lib/cjs/bedrock/twelvelabs.js +0 -87
  246. package/lib/cjs/bedrock/twelvelabs.js.map +0 -1
  247. package/lib/cjs/groq/index.js +0 -328
  248. package/lib/cjs/groq/index.js.map +0 -1
  249. package/lib/cjs/huggingface_ie.js +0 -201
  250. package/lib/cjs/huggingface_ie.js.map +0 -1
  251. package/lib/cjs/index.js +0 -31
  252. package/lib/cjs/index.js.map +0 -1
  253. package/lib/cjs/mistral/index.js +0 -176
  254. package/lib/cjs/mistral/index.js.map +0 -1
  255. package/lib/cjs/mistral/types.js +0 -83
  256. package/lib/cjs/mistral/types.js.map +0 -1
  257. package/lib/cjs/openai/azure_openai.js +0 -72
  258. package/lib/cjs/openai/azure_openai.js.map +0 -1
  259. package/lib/cjs/openai/index.js +0 -1129
  260. package/lib/cjs/openai/index.js.map +0 -1
  261. package/lib/cjs/openai/openai.js +0 -21
  262. package/lib/cjs/openai/openai.js.map +0 -1
  263. package/lib/cjs/openai/openai_compatible.js +0 -63
  264. package/lib/cjs/openai/openai_compatible.js.map +0 -1
  265. package/lib/cjs/openai/openai_format.js +0 -131
  266. package/lib/cjs/openai/openai_format.js.map +0 -1
  267. package/lib/cjs/package.json +0 -3
  268. package/lib/cjs/replicate.js +0 -275
  269. package/lib/cjs/replicate.js.map +0 -1
  270. package/lib/cjs/shared/claude-thinking.js +0 -60
  271. package/lib/cjs/shared/claude-thinking.js.map +0 -1
  272. package/lib/cjs/test-driver/TestErrorCompletionStream.js +0 -20
  273. package/lib/cjs/test-driver/TestErrorCompletionStream.js.map +0 -1
  274. package/lib/cjs/test-driver/TestValidationErrorCompletionStream.js +0 -24
  275. package/lib/cjs/test-driver/TestValidationErrorCompletionStream.js.map +0 -1
  276. package/lib/cjs/test-driver/index.js +0 -109
  277. package/lib/cjs/test-driver/index.js.map +0 -1
  278. package/lib/cjs/test-driver/utils.js +0 -30
  279. package/lib/cjs/test-driver/utils.js.map +0 -1
  280. package/lib/cjs/togetherai/index.js +0 -126
  281. package/lib/cjs/togetherai/index.js.map +0 -1
  282. package/lib/cjs/togetherai/interfaces.js +0 -3
  283. package/lib/cjs/togetherai/interfaces.js.map +0 -1
  284. package/lib/cjs/vertexai/debug.js +0 -12
  285. package/lib/cjs/vertexai/debug.js.map +0 -1
  286. package/lib/cjs/vertexai/embeddings/embeddings-image.js +0 -27
  287. package/lib/cjs/vertexai/embeddings/embeddings-image.js.map +0 -1
  288. package/lib/cjs/vertexai/embeddings/embeddings-text.js +0 -23
  289. package/lib/cjs/vertexai/embeddings/embeddings-text.js.map +0 -1
  290. package/lib/cjs/vertexai/index.js +0 -644
  291. package/lib/cjs/vertexai/index.js.map +0 -1
  292. package/lib/cjs/vertexai/models/claude.js +0 -917
  293. package/lib/cjs/vertexai/models/claude.js.map +0 -1
  294. package/lib/cjs/vertexai/models/gemini.js +0 -858
  295. package/lib/cjs/vertexai/models/gemini.js.map +0 -1
  296. package/lib/cjs/vertexai/models/imagen.js +0 -303
  297. package/lib/cjs/vertexai/models/imagen.js.map +0 -1
  298. package/lib/cjs/vertexai/models/llama.js +0 -183
  299. package/lib/cjs/vertexai/models/llama.js.map +0 -1
  300. package/lib/cjs/vertexai/models.js +0 -35
  301. package/lib/cjs/vertexai/models.js.map +0 -1
  302. package/lib/cjs/watsonx/index.js +0 -161
  303. package/lib/cjs/watsonx/index.js.map +0 -1
  304. package/lib/cjs/watsonx/interfaces.js +0 -3
  305. package/lib/cjs/xai/index.js +0 -65
  306. package/lib/cjs/xai/index.js.map +0 -1
  307. package/lib/esm/adobe/firefly.js +0 -116
  308. package/lib/esm/adobe/firefly.js.map +0 -1
  309. package/lib/esm/azure/azure_foundry.js.map +0 -1
  310. package/lib/esm/bedrock/converse.js.map +0 -1
  311. package/lib/esm/bedrock/index.js.map +0 -1
  312. package/lib/esm/bedrock/nova-image-payload.js.map +0 -1
  313. package/lib/esm/bedrock/payloads.js.map +0 -1
  314. package/lib/esm/bedrock/s3.js.map +0 -1
  315. package/lib/esm/bedrock/twelvelabs.js.map +0 -1
  316. package/lib/esm/groq/index.js.map +0 -1
  317. package/lib/esm/huggingface_ie.js.map +0 -1
  318. package/lib/esm/index.js +0 -15
  319. package/lib/esm/index.js.map +0 -1
  320. package/lib/esm/mistral/index.js.map +0 -1
  321. package/lib/esm/mistral/types.js.map +0 -1
  322. package/lib/esm/openai/azure_openai.js.map +0 -1
  323. package/lib/esm/openai/index.js.map +0 -1
  324. package/lib/esm/openai/openai.js +0 -14
  325. package/lib/esm/openai/openai.js.map +0 -1
  326. package/lib/esm/openai/openai_compatible.js.map +0 -1
  327. package/lib/esm/openai/openai_format.js.map +0 -1
  328. package/lib/esm/replicate.js.map +0 -1
  329. package/lib/esm/shared/claude-thinking.js.map +0 -1
  330. package/lib/esm/test-driver/TestErrorCompletionStream.js +0 -16
  331. package/lib/esm/test-driver/TestErrorCompletionStream.js.map +0 -1
  332. package/lib/esm/test-driver/TestValidationErrorCompletionStream.js.map +0 -1
  333. package/lib/esm/test-driver/index.js.map +0 -1
  334. package/lib/esm/test-driver/utils.js.map +0 -1
  335. package/lib/esm/togetherai/index.js +0 -122
  336. package/lib/esm/togetherai/index.js.map +0 -1
  337. package/lib/esm/togetherai/interfaces.js.map +0 -1
  338. package/lib/esm/vertexai/debug.js.map +0 -1
  339. package/lib/esm/vertexai/embeddings/embeddings-image.js +0 -24
  340. package/lib/esm/vertexai/embeddings/embeddings-image.js.map +0 -1
  341. package/lib/esm/vertexai/embeddings/embeddings-text.js +0 -20
  342. package/lib/esm/vertexai/embeddings/embeddings-text.js.map +0 -1
  343. package/lib/esm/vertexai/index.js.map +0 -1
  344. package/lib/esm/vertexai/models/claude.js +0 -906
  345. package/lib/esm/vertexai/models/claude.js.map +0 -1
  346. package/lib/esm/vertexai/models/gemini.js.map +0 -1
  347. package/lib/esm/vertexai/models/imagen.js.map +0 -1
  348. package/lib/esm/vertexai/models/llama.js.map +0 -1
  349. package/lib/esm/vertexai/models.js.map +0 -1
  350. package/lib/esm/watsonx/index.js.map +0 -1
  351. package/lib/esm/xai/index.js.map +0 -1
  352. package/lib/types/adobe/firefly.d.ts.map +0 -1
  353. package/lib/types/azure/azure_foundry.d.ts.map +0 -1
  354. package/lib/types/bedrock/converse.d.ts.map +0 -1
  355. package/lib/types/bedrock/index.d.ts.map +0 -1
  356. package/lib/types/bedrock/nova-image-payload.d.ts.map +0 -1
  357. package/lib/types/bedrock/payloads.d.ts.map +0 -1
  358. package/lib/types/bedrock/s3.d.ts.map +0 -1
  359. package/lib/types/bedrock/twelvelabs.d.ts.map +0 -1
  360. package/lib/types/groq/index.d.ts.map +0 -1
  361. package/lib/types/huggingface_ie.d.ts.map +0 -1
  362. package/lib/types/index.d.ts +0 -15
  363. package/lib/types/index.d.ts.map +0 -1
  364. package/lib/types/mistral/index.d.ts.map +0 -1
  365. package/lib/types/mistral/types.d.ts.map +0 -1
  366. package/lib/types/openai/azure_openai.d.ts.map +0 -1
  367. package/lib/types/openai/index.d.ts.map +0 -1
  368. package/lib/types/openai/openai.d.ts.map +0 -1
  369. package/lib/types/openai/openai_compatible.d.ts.map +0 -1
  370. package/lib/types/openai/openai_format.d.ts.map +0 -1
  371. package/lib/types/replicate.d.ts.map +0 -1
  372. package/lib/types/shared/claude-thinking.d.ts.map +0 -1
  373. package/lib/types/test-driver/TestErrorCompletionStream.d.ts.map +0 -1
  374. package/lib/types/test-driver/TestValidationErrorCompletionStream.d.ts.map +0 -1
  375. package/lib/types/test-driver/index.d.ts.map +0 -1
  376. package/lib/types/test-driver/utils.d.ts.map +0 -1
  377. package/lib/types/togetherai/index.d.ts +0 -23
  378. package/lib/types/togetherai/index.d.ts.map +0 -1
  379. package/lib/types/togetherai/interfaces.d.ts.map +0 -1
  380. package/lib/types/vertexai/debug.d.ts +0 -2
  381. package/lib/types/vertexai/debug.d.ts.map +0 -1
  382. package/lib/types/vertexai/embeddings/embeddings-image.d.ts +0 -11
  383. package/lib/types/vertexai/embeddings/embeddings-image.d.ts.map +0 -1
  384. package/lib/types/vertexai/embeddings/embeddings-text.d.ts +0 -10
  385. package/lib/types/vertexai/embeddings/embeddings-text.d.ts.map +0 -1
  386. package/lib/types/vertexai/index.d.ts.map +0 -1
  387. package/lib/types/vertexai/models/claude.d.ts +0 -119
  388. package/lib/types/vertexai/models/claude.d.ts.map +0 -1
  389. package/lib/types/vertexai/models/gemini.d.ts.map +0 -1
  390. package/lib/types/vertexai/models/imagen.d.ts.map +0 -1
  391. package/lib/types/vertexai/models/llama.d.ts.map +0 -1
  392. package/lib/types/vertexai/models.d.ts +0 -20
  393. package/lib/types/vertexai/models.d.ts.map +0 -1
  394. package/lib/types/watsonx/index.d.ts.map +0 -1
  395. package/lib/types/watsonx/interfaces.d.ts.map +0 -1
  396. package/lib/types/xai/index.d.ts.map +0 -1
  397. package/src/vertexai/embeddings/embeddings-image.ts +0 -52
  398. package/src/vertexai/embeddings/embeddings-text.ts +0 -54
  399. /package/lib/{esm/bedrock → bedrock}/payloads.js +0 -0
  400. /package/lib/{esm/mistral → mistral}/types.js +0 -0
  401. /package/lib/{esm/togetherai → togetherai}/interfaces.js +0 -0
  402. /package/lib/{types/watsonx → watsonx}/interfaces.d.ts +0 -0
  403. /package/lib/{esm/watsonx → watsonx}/interfaces.js +0 -0
@@ -1,644 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VertexAIDriver = void 0;
4
- exports.trimModelName = trimModelName;
5
- const vertex_sdk_1 = require("@anthropic-ai/vertex-sdk");
6
- const aiplatform_1 = require("@google-cloud/aiplatform");
7
- const genai_1 = require("@google/genai");
8
- const core_1 = require("@llumiverse/core");
9
- const api_fetch_client_1 = require("@vertesia/api-fetch-client");
10
- const google_auth_library_1 = require("google-auth-library");
11
- const embeddings_image_js_1 = require("./embeddings/embeddings-image.js");
12
- const embeddings_text_js_1 = require("./embeddings/embeddings-text.js");
13
- const models_js_1 = require("./models.js");
14
- const claude_js_1 = require("./models/claude.js");
15
- const imagen_js_1 = require("./models/imagen.js");
16
- function trimModelName(model) {
17
- const i = model.lastIndexOf("@");
18
- return i > -1 ? model.substring(0, i) : model;
19
- }
20
- class VertexAIDriver extends core_1.AbstractDriver {
21
- static PROVIDER = "vertexai";
22
- provider = VertexAIDriver.PROVIDER;
23
- aiplatform;
24
- anthropicClient;
25
- fetchClient;
26
- googleGenAI;
27
- googleGenAIRegion;
28
- googleGenAIFlex;
29
- llamaClient;
30
- modelGarden;
31
- imagenClient;
32
- googleAuth;
33
- authClientPromise;
34
- constructor(options) {
35
- super(options);
36
- this.aiplatform = undefined;
37
- this.anthropicClient = undefined;
38
- this.fetchClient = undefined;
39
- this.googleGenAI = undefined;
40
- this.googleGenAIRegion = undefined;
41
- this.googleGenAIFlex = undefined;
42
- this.modelGarden = undefined;
43
- this.llamaClient = undefined;
44
- this.imagenClient = undefined;
45
- this.googleAuth = new google_auth_library_1.GoogleAuth(options.googleAuthOptions);
46
- this.authClientPromise = undefined;
47
- }
48
- async getAuthClient() {
49
- if (!this.authClientPromise) {
50
- this.authClientPromise = this.googleAuth.getClient();
51
- }
52
- return this.authClientPromise;
53
- }
54
- getGoogleGenAIClient(region = this.options.region, flex = false) {
55
- if (this.googleGenAI &&
56
- this.googleGenAIRegion === region &&
57
- this.googleGenAIFlex === flex) {
58
- // Return existing client if region and flex settings match
59
- return this.googleGenAI;
60
- }
61
- this.googleGenAI = this.buildGoogleGenAIClient(region, flex);
62
- this.googleGenAIRegion = region;
63
- this.googleGenAIFlex = flex;
64
- return this.googleGenAI;
65
- }
66
- buildGoogleGenAIClient(region, flex) {
67
- return new genai_1.GoogleGenAI({
68
- project: this.options.project,
69
- location: region,
70
- vertexai: true,
71
- googleAuthOptions: this.options.googleAuthOptions || {
72
- scopes: ["https://www.googleapis.com/auth/cloud-platform"],
73
- },
74
- ...(flex ? {
75
- httpOptions: {
76
- headers: {
77
- "X-Vertex-AI-LLM-Request-Type": "shared",
78
- "X-Vertex-AI-LLM-Shared-Request-Type": "flex",
79
- }
80
- }
81
- } : {}),
82
- });
83
- }
84
- getFetchClient() {
85
- //Lazy initialization
86
- if (!this.fetchClient) {
87
- this.fetchClient = createFetchClient({
88
- region: this.options.region,
89
- project: this.options.project,
90
- }).withAuthCallback(async () => {
91
- const token = await this.googleAuth.getAccessToken();
92
- return `Bearer ${token}`;
93
- });
94
- }
95
- return this.fetchClient;
96
- }
97
- getLLamaClient(region = "us-central1") {
98
- //Lazy initialization
99
- if (!this.llamaClient || this.llamaClient["region"] !== region) {
100
- this.llamaClient = createFetchClient({
101
- region: region,
102
- project: this.options.project,
103
- apiVersion: "v1beta1",
104
- }).withAuthCallback(async () => {
105
- const token = await this.googleAuth.getAccessToken();
106
- return `Bearer ${token}`;
107
- });
108
- // Store the region for potential client reuse
109
- this.llamaClient["region"] = region;
110
- }
111
- return this.llamaClient;
112
- }
113
- async getAnthropicClient(region = this.options.region) {
114
- // Extract region prefix and map if it exists in ANTHROPIC_REGIONS, otherwise use as-is
115
- const getRegionPrefix = (r) => r.split('-')[0];
116
- const regionPrefix = getRegionPrefix(region);
117
- const mappedRegion = claude_js_1.ANTHROPIC_REGIONS[regionPrefix] || region;
118
- const defaultRegionPrefix = getRegionPrefix(this.options.region);
119
- const defaultMappedRegion = claude_js_1.ANTHROPIC_REGIONS[defaultRegionPrefix] || this.options.region;
120
- // Get auth client to avoid version mismatch with GoogleAuth generic types
121
- const authClient = await this.getAuthClient();
122
- // If mapped region is different from default mapped region, create one-off client
123
- if (mappedRegion !== defaultMappedRegion) {
124
- return new vertex_sdk_1.AnthropicVertex({
125
- timeout: 20 * 60 * 10000, // Set to 20 minutes, 10 minute default, setting this disables long request error: https://github.com/anthropics/anthropic-sdk-typescript?#long-requests
126
- region: mappedRegion,
127
- projectId: this.options.project,
128
- authClient: authClient,
129
- });
130
- }
131
- //Lazy initialization for default region
132
- if (!this.anthropicClient) {
133
- this.anthropicClient = new vertex_sdk_1.AnthropicVertex({
134
- timeout: 20 * 60 * 10000, // Set to 20 minutes, 10 minute default, setting this disables long request error: https://github.com/anthropics/anthropic-sdk-typescript?#long-requests
135
- region: mappedRegion,
136
- projectId: this.options.project,
137
- authClient: authClient,
138
- });
139
- }
140
- return this.anthropicClient;
141
- }
142
- async getAIPlatformClient() {
143
- //Lazy initialization
144
- if (!this.aiplatform) {
145
- const authClient = await this.getAuthClient();
146
- this.aiplatform = new aiplatform_1.v1beta1.ModelServiceClient({
147
- projectId: this.options.project,
148
- apiEndpoint: `${this.options.region}-${API_BASE_PATH}`,
149
- authClient,
150
- });
151
- }
152
- return this.aiplatform;
153
- }
154
- async getModelGardenClient() {
155
- //Lazy initialization
156
- if (!this.modelGarden) {
157
- const authClient = await this.getAuthClient();
158
- this.modelGarden = new aiplatform_1.v1beta1.ModelGardenServiceClient({
159
- projectId: this.options.project,
160
- apiEndpoint: `${this.options.region}-${API_BASE_PATH}`,
161
- authClient,
162
- });
163
- }
164
- return this.modelGarden;
165
- }
166
- async getImagenClient() {
167
- //Lazy initialization
168
- if (!this.imagenClient) {
169
- // TODO: make location configurable, fixed to us-central1 for now
170
- const authClient = await this.getAuthClient();
171
- this.imagenClient = new aiplatform_1.PredictionServiceClient({
172
- projectId: this.options.project,
173
- apiEndpoint: `us-central1-${API_BASE_PATH}`,
174
- authClient,
175
- });
176
- }
177
- return this.imagenClient;
178
- }
179
- validateResult(result, options) {
180
- // Optionally preprocess the result before validation
181
- const modelDef = (0, models_js_1.getModelDefinition)(options.model);
182
- if (typeof modelDef.preValidationProcessing === "function") {
183
- const processed = modelDef.preValidationProcessing(result, options);
184
- result = processed.result;
185
- options = processed.options;
186
- }
187
- super.validateResult(result, options);
188
- }
189
- canStream(options) {
190
- if (this.isImageModel(options.model)) {
191
- return Promise.resolve(false);
192
- }
193
- return Promise.resolve((0, models_js_1.getModelDefinition)(options.model).model.can_stream === true);
194
- }
195
- isImageModel(model) {
196
- return model.includes("imagen");
197
- }
198
- createPrompt(segments, options) {
199
- if (this.isImageModel(options.model)) {
200
- return new imagen_js_1.ImagenModelDefinition(options.model).createPrompt(this, segments, options);
201
- }
202
- return (0, models_js_1.getModelDefinition)(options.model).createPrompt(this, segments, options);
203
- }
204
- async requestTextCompletion(prompt, options) {
205
- return (0, models_js_1.getModelDefinition)(options.model).requestTextCompletion(this, prompt, options);
206
- }
207
- async requestTextCompletionStream(prompt, options) {
208
- return (0, models_js_1.getModelDefinition)(options.model).requestTextCompletionStream(this, prompt, options);
209
- }
210
- /**
211
- * Build conversation context after streaming completion.
212
- * Reconstructs the assistant message from accumulated results and applies stripping.
213
- * Handles both Gemini (Content[]) and Claude (ClaudePrompt) formats.
214
- */
215
- buildStreamingConversation(prompt, result, toolUse, options) {
216
- // Handle Claude-style prompts (has 'messages' array)
217
- if ('messages' in prompt && Array.isArray(prompt.messages)) {
218
- return this.buildClaudeStreamingConversation(prompt, result, toolUse, options);
219
- }
220
- // Only handle Gemini-style prompts with contents array
221
- if (!('contents' in prompt) || !Array.isArray(prompt.contents)) {
222
- return undefined;
223
- }
224
- const completionResults = result;
225
- // Convert accumulated results to text content for assistant message
226
- const textContent = completionResults
227
- .map(r => {
228
- switch (r.type) {
229
- case 'text':
230
- return r.value;
231
- case 'json':
232
- return typeof r.value === 'string' ? r.value : JSON.stringify(r.value);
233
- case 'image':
234
- // Skip images in conversation - they're in the result
235
- return '';
236
- default:
237
- return String(r.value || '');
238
- }
239
- })
240
- .join('');
241
- // Build parts array for assistant message
242
- const parts = [];
243
- if (textContent) {
244
- parts.push({ text: textContent });
245
- }
246
- // Add function calls if present (Gemini format)
247
- if (toolUse && toolUse.length > 0) {
248
- for (const tool of toolUse) {
249
- const functionCallPart = {
250
- functionCall: {
251
- name: tool.tool_name,
252
- args: tool.tool_input,
253
- }
254
- };
255
- // Include thought_signature for Gemini thinking models (2.5+/3.0+)
256
- // This must be preserved in the conversation for subsequent API calls
257
- if (tool.thought_signature) {
258
- functionCallPart.thoughtSignature = tool.thought_signature;
259
- }
260
- parts.push(functionCallPart);
261
- }
262
- }
263
- // prompt.contents already includes the conversation history
264
- // (merged in requestTextCompletionStream via updateConversation),
265
- // so we use it directly — do NOT prepend options.conversation again.
266
- let conversation = [
267
- ...prompt.contents,
268
- ];
269
- // Only add assistant message if there's actual content
270
- // (Empty text parts can cause API errors)
271
- if (parts.length > 0) {
272
- conversation.push({
273
- role: 'model',
274
- parts: parts
275
- });
276
- }
277
- // Increment turn counter
278
- conversation = (0, core_1.incrementConversationTurn)(conversation);
279
- // Apply stripping based on options
280
- const currentTurn = (0, core_1.getConversationMeta)(conversation).turnNumber;
281
- const stripOptions = {
282
- keepForTurns: options.stripImagesAfterTurns ?? Infinity,
283
- currentTurn,
284
- textMaxTokens: options.stripTextMaxTokens
285
- };
286
- let processedConversation = (0, core_1.stripBase64ImagesFromConversation)(conversation, stripOptions);
287
- processedConversation = (0, core_1.truncateLargeTextInConversation)(processedConversation, stripOptions);
288
- processedConversation = (0, core_1.stripHeartbeatsFromConversation)(processedConversation, {
289
- keepForTurns: options.stripHeartbeatsAfterTurns ?? 1,
290
- currentTurn,
291
- });
292
- // Preserve system instruction in conversation for Gemini multi-turn support.
293
- // The Gemini API takes system as a separate parameter (not in contents),
294
- // so we must store it in the conversation wrapper to survive serialization.
295
- const geminiPrompt = prompt;
296
- if (geminiPrompt.system) {
297
- if (typeof processedConversation === 'object' && processedConversation !== null) {
298
- processedConversation = { ...processedConversation, _llumiverse_system: geminiPrompt.system };
299
- }
300
- }
301
- return processedConversation;
302
- }
303
- /**
304
- * Build conversation for Claude streaming.
305
- * Creates assistant message with tool_use blocks in Claude's ContentBlock format.
306
- */
307
- buildClaudeStreamingConversation(prompt, result, toolUse, options) {
308
- const completionResults = result;
309
- // Convert accumulated results to text content
310
- const textContent = completionResults
311
- .map(r => {
312
- switch (r.type) {
313
- case 'text':
314
- return r.value;
315
- case 'json':
316
- return typeof r.value === 'string' ? r.value : JSON.stringify(r.value);
317
- case 'image':
318
- return '';
319
- default:
320
- return String(r.value || '');
321
- }
322
- })
323
- .join('');
324
- // Build Claude-style ContentBlock array for assistant message
325
- const content = [];
326
- // Add text block if there's text content
327
- if (textContent) {
328
- content.push({
329
- type: 'text',
330
- text: textContent
331
- });
332
- }
333
- // Add tool_use blocks in Claude format
334
- if (toolUse && toolUse.length > 0) {
335
- for (const tool of toolUse) {
336
- content.push({
337
- type: 'tool_use',
338
- id: tool.id,
339
- name: tool.tool_name,
340
- input: tool.tool_input ?? {}
341
- });
342
- }
343
- }
344
- // Claude's requestTextCompletionStream does NOT mutate prompt.messages
345
- // to include history, so we must prepend options.conversation here.
346
- const existingMessages = options.conversation?.messages ?? [];
347
- const existingSystem = options.conversation?.system ?? prompt.system;
348
- // Build the new messages array
349
- const newMessages = [
350
- ...existingMessages,
351
- ...prompt.messages,
352
- ];
353
- // Only add assistant message if there's actual content
354
- // (Claude API rejects empty text content blocks)
355
- if (content.length > 0) {
356
- newMessages.push({
357
- role: 'assistant',
358
- content: content
359
- });
360
- }
361
- // Build the new conversation in ClaudePrompt format
362
- const conversation = {
363
- messages: newMessages,
364
- system: existingSystem
365
- };
366
- // Increment turn counter
367
- const withTurn = (0, core_1.incrementConversationTurn)(conversation);
368
- // Apply stripping based on options
369
- const currentTurn = (0, core_1.getConversationMeta)(withTurn).turnNumber;
370
- const stripOptions = {
371
- keepForTurns: options.stripImagesAfterTurns ?? Infinity,
372
- currentTurn,
373
- textMaxTokens: options.stripTextMaxTokens
374
- };
375
- let processedConversation = (0, core_1.stripBase64ImagesFromConversation)(withTurn, stripOptions);
376
- processedConversation = (0, core_1.truncateLargeTextInConversation)(processedConversation, stripOptions);
377
- processedConversation = (0, core_1.stripHeartbeatsFromConversation)(processedConversation, {
378
- keepForTurns: options.stripHeartbeatsAfterTurns ?? 1,
379
- currentTurn,
380
- });
381
- return processedConversation;
382
- }
383
- async requestImageGeneration(_prompt, _options) {
384
- const splits = _options.model.split("/");
385
- const modelName = trimModelName(splits[splits.length - 1]);
386
- return new imagen_js_1.ImagenModelDefinition(modelName).requestImageGeneration(this, _prompt, _options);
387
- }
388
- async getGenAIModelsArray(client) {
389
- const models = [];
390
- const pager = await client.models.list();
391
- for await (const item of pager) {
392
- models.push(item);
393
- }
394
- return models;
395
- }
396
- async listModels(_params) {
397
- // Get clients
398
- const modelGarden = await this.getModelGardenClient();
399
- const aiplatform = await this.getAIPlatformClient();
400
- const globalGenAiClient = this.getGoogleGenAIClient("global");
401
- let models = [];
402
- //Model Garden Publisher models - Pretrained models
403
- const publishers = ["google", "anthropic", "meta"];
404
- // Meta "maas" models are LLama Models-As-A-Service. Non-maas models are not pre-deployed.
405
- const supportedModels = { google: ["gemini", "imagen"], anthropic: ["claude"], meta: ["maas"] };
406
- // Additional models not in the listings, but we want to include
407
- // TODO: Remove once the models are available in the listing API, or no longer needed
408
- const additionalModels = {
409
- google: [
410
- "imagen-3.0-fast-generate-001",
411
- ],
412
- anthropic: [],
413
- meta: [
414
- "llama-4-maverick-17b-128e-instruct-maas",
415
- "llama-4-scout-17b-16e-instruct-maas",
416
- "llama-3.3-70b-instruct-maas",
417
- "llama-3.2-90b-vision-instruct-maas",
418
- "llama-3.1-405b-instruct-maas",
419
- "llama-3.1-70b-instruct-maas",
420
- "llama-3.1-8b-instruct-maas",
421
- ],
422
- };
423
- //Used to exclude retired models that are still in the listing API but not available for use.
424
- //Or models we do not support yet
425
- const unsupportedModelsByPublisher = {
426
- google: ["gemini-pro", "gemini-ultra", "imagen-product-recontext-preview", "embedding", "gemini-live-2.5-flash-preview-native-audio", "computer-use-preview"],
427
- anthropic: [],
428
- meta: [],
429
- };
430
- // Start all network requests in parallel
431
- const aiplatformPromise = aiplatform.listModels({
432
- parent: `projects/${this.options.project}/locations/${this.options.region}`,
433
- });
434
- const publisherPromises = publishers.map(async (publisher) => {
435
- const [response] = await modelGarden.listPublisherModels({
436
- parent: `publishers/${publisher}`,
437
- orderBy: "name",
438
- listAllVersions: true,
439
- });
440
- return { publisher, response };
441
- });
442
- const globalGooglePromise = this.getGenAIModelsArray(globalGenAiClient);
443
- // Await all network requests
444
- const [aiplatformResult, globalGoogleResult, ...publisherResults] = await Promise.all([
445
- aiplatformPromise,
446
- globalGooglePromise,
447
- ...publisherPromises,
448
- ]);
449
- // Process aiplatform models, project specific models
450
- const [response] = aiplatformResult;
451
- models = models.concat(response.map((model) => ({
452
- id: model.name?.split("/").pop() ?? "",
453
- name: model.displayName ?? "",
454
- provider: "vertexai"
455
- })));
456
- // Process global google models from GenAI
457
- models = models.concat(globalGoogleResult.map((model) => {
458
- const modelCapability = (0, core_1.getModelCapabilities)(model.name ?? '', "vertexai");
459
- return {
460
- id: "locations/global/" + model.name,
461
- name: "Global " + model.name?.split('/').pop(),
462
- provider: "vertexai",
463
- owner: "google",
464
- input_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.input),
465
- output_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.output),
466
- tool_support: modelCapability.tool_support,
467
- };
468
- }));
469
- // Process publisher models
470
- for (const result of publisherResults) {
471
- const { publisher, response } = result;
472
- const modelFamily = supportedModels[publisher];
473
- const retiredModels = unsupportedModelsByPublisher[publisher];
474
- models = models.concat(response.filter((model) => {
475
- const modelName = model.name ?? "";
476
- // Exclude retired models
477
- if (retiredModels.some(retiredModel => modelName.includes(retiredModel))) {
478
- return false;
479
- }
480
- // Check if the model belongs to the supported model families
481
- if (modelFamily.some(family => modelName.includes(family))) {
482
- return true;
483
- }
484
- return false;
485
- }).map(model => {
486
- const modelCapability = (0, core_1.getModelCapabilities)(model.name ?? '', "vertexai");
487
- return {
488
- id: model.name ?? '',
489
- name: model.name?.split('/').pop() ?? '',
490
- provider: 'vertexai',
491
- owner: publisher,
492
- input_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.input),
493
- output_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.output),
494
- tool_support: modelCapability.tool_support,
495
- };
496
- }));
497
- // Create global google gemini models for Gemini 2.5 and later, if missing from GenAI listing
498
- if (publisher === 'google') {
499
- const globalGeminiModels = response.filter((model) => {
500
- const modelName = model.name ?? "";
501
- if (retiredModels.some(retiredModel => modelName.includes(retiredModel))) {
502
- return false;
503
- }
504
- if (modelFamily.some(family => modelName.includes(family))) {
505
- const versionMatch = modelName.match(/gemini-(\d+(?:\.\d+)?)/);
506
- if (versionMatch) {
507
- const version = parseFloat(versionMatch[1]);
508
- if (version >= 2.5) {
509
- // Check if already present
510
- const shortName = modelName.split('/').pop();
511
- const globalName = "Global " + shortName;
512
- if (models.some(m => m.name === globalName)) {
513
- return false;
514
- }
515
- return true;
516
- }
517
- }
518
- return false;
519
- }
520
- return false;
521
- }).map(model => {
522
- const modelCapability = (0, core_1.getModelCapabilities)(model.name ?? '', "vertexai");
523
- return {
524
- id: "locations/global/" + model.name,
525
- name: "Global " + model.name?.split('/').pop(),
526
- provider: 'vertexai',
527
- owner: publisher,
528
- input_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.input),
529
- output_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.output),
530
- tool_support: modelCapability.tool_support,
531
- };
532
- });
533
- models = models.concat(globalGeminiModels);
534
- }
535
- // Create global anthropic models for those not in NON_GLOBAL_ANTHROPIC_MODELS
536
- if (publisher === 'anthropic') {
537
- const globalAnthropicModels = response.filter((model) => {
538
- const modelName = model.name ?? "";
539
- if (retiredModels.some(retiredModel => modelName.includes(retiredModel))) {
540
- return false;
541
- }
542
- if (modelFamily.some(family => modelName.includes(family))) {
543
- if (modelName.includes("claude-3-7")) {
544
- return true;
545
- }
546
- return !claude_js_1.NON_GLOBAL_ANTHROPIC_MODELS.some(nonGlobalModel => modelName.includes(nonGlobalModel));
547
- }
548
- return false;
549
- }).map(model => {
550
- const modelCapability = (0, core_1.getModelCapabilities)(model.name ?? '', "vertexai");
551
- return {
552
- id: "locations/global/" + model.name,
553
- name: "Global " + model.name?.split('/').pop(),
554
- provider: 'vertexai',
555
- owner: publisher,
556
- input_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.input),
557
- output_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.output),
558
- tool_support: modelCapability.tool_support,
559
- };
560
- });
561
- models = models.concat(globalAnthropicModels);
562
- }
563
- // Add additional models that are not in the listing
564
- for (const additionalModel of additionalModels[publisher]) {
565
- const publisherModelName = `publishers/${publisher}/models/${additionalModel}`;
566
- const modelCapability = (0, core_1.getModelCapabilities)(additionalModel, "vertexai");
567
- models.push({
568
- id: publisherModelName,
569
- name: additionalModel,
570
- provider: 'vertexai',
571
- owner: publisher,
572
- input_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.input),
573
- output_modalities: (0, core_1.modelModalitiesToArray)(modelCapability.output),
574
- tool_support: modelCapability.tool_support,
575
- });
576
- }
577
- }
578
- //Remove duplicates
579
- const uniqueModels = Array.from(new Set(models.map(a => a.id)))
580
- .map(id => {
581
- return models.find(a => a.id === id) ?? {};
582
- }).sort((a, b) => a.id.localeCompare(b.id));
583
- return uniqueModels;
584
- }
585
- validateConnection() {
586
- throw new Error("Method not implemented.");
587
- }
588
- async generateEmbeddings(options) {
589
- if (options.image || options.model?.includes("multimodal")) {
590
- if (options.text && options.image) {
591
- throw new Error("Text and Image simultaneous embedding not implemented. Submit separately");
592
- }
593
- return (0, embeddings_image_js_1.getEmbeddingsForImages)(this, options);
594
- }
595
- const text_options = {
596
- content: options.text ?? "",
597
- model: options.model,
598
- };
599
- return (0, embeddings_text_js_1.getEmbeddingsForText)(this, text_options);
600
- }
601
- /**
602
- * Cleanup Google Cloud clients when the driver is evicted from the cache.
603
- */
604
- destroy() {
605
- this.aiplatform?.close();
606
- this.modelGarden?.close();
607
- this.imagenClient?.close();
608
- }
609
- /**
610
- * Format VertexAI errors by routing to model-specific error handlers.
611
- * Each model definition (Gemini, Claude, Llama) can provide custom error parsing
612
- * based on their specific SDK error structures.
613
- *
614
- * @param error - The error from the VertexAI/model SDK
615
- * @param context - Context about where the error occurred
616
- * @returns A standardized LlumiverseError
617
- */
618
- formatLlumiverseError(error, context) {
619
- // Get the model definition for this request
620
- const modelDef = (0, models_js_1.getModelDefinition)(context.model);
621
- // If the model definition provides custom error handling, use it
622
- if (modelDef.formatLlumiverseError) {
623
- try {
624
- return modelDef.formatLlumiverseError(this, error, context);
625
- }
626
- catch (formattingError) {
627
- // If model-specific handler throws, fall through to default handling
628
- // This allows model handlers to explicitly opt out for certain errors
629
- }
630
- }
631
- // Fall back to default AbstractDriver error handling
632
- return super.formatLlumiverseError(error, context);
633
- }
634
- }
635
- exports.VertexAIDriver = VertexAIDriver;
636
- //'us-central1-aiplatform.googleapis.com',
637
- const API_BASE_PATH = "aiplatform.googleapis.com";
638
- function createFetchClient({ region, project, apiEndpoint, apiVersion = "v1", }) {
639
- const vertexBaseEndpoint = apiEndpoint ?? `${region}-${API_BASE_PATH}`;
640
- return new api_fetch_client_1.FetchClient(`https://${vertexBaseEndpoint}/${apiVersion}/projects/${project}/locations/${region}`).withHeaders({
641
- "Content-Type": "application/json",
642
- });
643
- }
644
- //# sourceMappingURL=index.js.map