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