@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.
- 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/anthropic/index.d.ts +23 -0
- package/lib/anthropic/index.d.ts.map +1 -0
- package/lib/anthropic/index.js +68 -0
- 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 +17 -5
- package/lib/openai/index.d.ts.map +1 -0
- package/lib/{esm/openai → openai}/index.js +254 -148
- 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/shared/claude-messages.d.ts +99 -0
- package/lib/shared/claude-messages.d.ts.map +1 -0
- package/lib/shared/claude-messages.js +869 -0
- 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/vertexai/models/claude.d.ts +16 -0
- package/lib/vertexai/models/claude.d.ts.map +1 -0
- package/lib/vertexai/models/claude.js +65 -0
- package/lib/vertexai/models/claude.js.map +1 -0
- package/lib/{types/vertexai → vertexai}/models/gemini.d.ts +29 -5
- package/lib/vertexai/models/gemini.d.ts.map +1 -0
- package/lib/{esm/vertexai → vertexai}/models/gemini.js +255 -127
- 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 +88 -36
- package/src/adobe/firefly.ts +60 -43
- package/src/anthropic/index.ts +121 -0
- 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 -15
- 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 +389 -254
- 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 +1085 -0
- 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 +339 -253
- package/src/vertexai/models/claude-error-handling.test.ts +86 -39
- package/src/vertexai/models/claude-streaming-spacing.test.ts +82 -75
- package/src/vertexai/models/claude.ts +84 -1041
- 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 +372 -182
- 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/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 -31
- 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 -1129
- 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-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 -917
- package/lib/cjs/vertexai/models/claude.js.map +0 -1
- package/lib/cjs/vertexai/models/gemini.js +0 -858
- 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/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 -15
- 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-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 +0 -906
- 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/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 -15
- 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-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 +0 -119
- 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
package/src/vertexai/index.ts
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { PredictionServiceClient, v1beta1 } from
|
|
4
|
-
import { Content, GoogleGenAI, Model } from "@google/genai";
|
|
1
|
+
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
|
|
2
|
+
import { type Content, GoogleGenAI, type Model } from '@google/genai';
|
|
3
|
+
import { PredictionServiceClient, v1beta1 } from '@google-cloud/aiplatform';
|
|
5
4
|
import {
|
|
6
|
-
AIModel,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ExecutionOptions,
|
|
15
|
-
LlumiverseError,
|
|
16
|
-
LlumiverseErrorContext,
|
|
17
|
-
ModelSearchPayload,
|
|
18
|
-
PromptSegment,
|
|
5
|
+
type AIModel,
|
|
6
|
+
type Completion,
|
|
7
|
+
type CompletionChunkObject,
|
|
8
|
+
type CompletionResult,
|
|
9
|
+
type DriverOptions,
|
|
10
|
+
type EmbeddingsOptions,
|
|
11
|
+
type EmbeddingsResult,
|
|
12
|
+
type ExecutionOptions,
|
|
19
13
|
getConversationMeta,
|
|
20
14
|
getModelCapabilities,
|
|
15
|
+
type HttpTimeoutOptions,
|
|
21
16
|
incrementConversationTurn,
|
|
17
|
+
type LlumiverseError,
|
|
18
|
+
type LlumiverseErrorContext,
|
|
19
|
+
type ModelSearchPayload,
|
|
22
20
|
modelModalitiesToArray,
|
|
21
|
+
type PromptSegment,
|
|
23
22
|
stripBase64ImagesFromConversation,
|
|
24
23
|
stripHeartbeatsFromConversation,
|
|
24
|
+
type ToolUse,
|
|
25
25
|
truncateLargeTextInConversation,
|
|
26
|
-
} from
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
26
|
+
} from '@llumiverse/core';
|
|
27
|
+
import { AbstractDriver } from '@llumiverse/core/driver';
|
|
28
|
+
import { mergeDriverHttpTimeoutOptions, resolveDriverHttpTimeouts } from '@llumiverse/core/http-agent';
|
|
29
|
+
import { type FETCH_FN, FetchClient } from '@vertesia/api-fetch-client';
|
|
30
|
+
import { type AuthClient, GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';
|
|
31
|
+
import { type ClaudePrompt, formatClaudeDebugPrompt } from '../shared/claude-messages.js';
|
|
32
|
+
import { generateVertexAiEmbeddings } from './embeddings/embed.js';
|
|
33
|
+
import { ANTHROPIC_REGIONS, NON_GLOBAL_ANTHROPIC_MODELS } from './models/claude.js';
|
|
34
|
+
import { formatGeminiDebugPrompt } from './models/gemini.js';
|
|
35
|
+
import { formatImagenDebugPrompt, ImagenModelDefinition, type ImagenPrompt } from './models/imagen.js';
|
|
36
|
+
import type { LLamaPrompt } from './models/llama.js';
|
|
37
|
+
import { getModelDefinition, trimModelName } from './models.js';
|
|
34
38
|
|
|
35
39
|
export interface VertexAIDriverOptions extends DriverOptions {
|
|
36
40
|
project: string;
|
|
@@ -42,17 +46,32 @@ export interface GenerateContentPrompt {
|
|
|
42
46
|
contents: Content[];
|
|
43
47
|
system?: Content;
|
|
44
48
|
}
|
|
49
|
+
type ClaudeStreamingPrompt = { messages: unknown[]; system?: unknown[] };
|
|
50
|
+
type ConversationWrapper = { messages?: unknown[]; system?: unknown[] };
|
|
51
|
+
|
|
52
|
+
function isClaudePrompt(prompt: VertexAIPrompt): prompt is ClaudePrompt {
|
|
53
|
+
return (
|
|
54
|
+
'messages' in prompt &&
|
|
55
|
+
('system' in prompt || prompt.messages.some((message) => Array.isArray(message.content)))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isClaudeStreamingPrompt(prompt: unknown): prompt is ClaudeStreamingPrompt {
|
|
60
|
+
return (
|
|
61
|
+
prompt !== null &&
|
|
62
|
+
typeof prompt === 'object' &&
|
|
63
|
+
'messages' in prompt &&
|
|
64
|
+
Array.isArray((prompt as ConversationWrapper).messages)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
45
67
|
|
|
46
68
|
//General Prompt type for VertexAI
|
|
47
|
-
export type VertexAIPrompt = ImagenPrompt | GenerateContentPrompt;
|
|
69
|
+
export type VertexAIPrompt = ImagenPrompt | GenerateContentPrompt | ClaudePrompt | LLamaPrompt;
|
|
48
70
|
|
|
49
|
-
export
|
|
50
|
-
const i = model.lastIndexOf("@");
|
|
51
|
-
return i > -1 ? model.substring(0, i) : model;
|
|
52
|
-
}
|
|
71
|
+
export { trimModelName };
|
|
53
72
|
|
|
54
73
|
export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, VertexAIPrompt> {
|
|
55
|
-
static PROVIDER =
|
|
74
|
+
static PROVIDER = 'vertexai';
|
|
56
75
|
provider = VertexAIDriver.PROVIDER;
|
|
57
76
|
|
|
58
77
|
aiplatform: v1beta1.ModelServiceClient | undefined;
|
|
@@ -61,11 +80,12 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
61
80
|
googleGenAI: GoogleGenAI | undefined;
|
|
62
81
|
googleGenAIRegion: string | undefined;
|
|
63
82
|
googleGenAIFlex: boolean | undefined;
|
|
64
|
-
llamaClient: FetchClient & { region?: string } | undefined;
|
|
83
|
+
llamaClient: (FetchClient & { region?: string }) | undefined;
|
|
65
84
|
modelGarden: v1beta1.ModelGardenServiceClient | undefined;
|
|
66
85
|
imagenClient: PredictionServiceClient | undefined;
|
|
86
|
+
predictionClient: PredictionServiceClient | undefined;
|
|
67
87
|
|
|
68
|
-
googleAuth: GoogleAuth<
|
|
88
|
+
googleAuth: GoogleAuth<AuthClient>;
|
|
69
89
|
private authClientPromise: Promise<AuthClient> | undefined;
|
|
70
90
|
|
|
71
91
|
constructor(options: VertexAIDriverOptions) {
|
|
@@ -73,18 +93,32 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
73
93
|
|
|
74
94
|
this.aiplatform = undefined;
|
|
75
95
|
this.anthropicClient = undefined;
|
|
76
|
-
this.fetchClient = undefined
|
|
96
|
+
this.fetchClient = undefined;
|
|
77
97
|
this.googleGenAI = undefined;
|
|
78
98
|
this.googleGenAIRegion = undefined;
|
|
79
99
|
this.googleGenAIFlex = undefined;
|
|
80
100
|
this.modelGarden = undefined;
|
|
81
101
|
this.llamaClient = undefined;
|
|
82
102
|
this.imagenClient = undefined;
|
|
103
|
+
this.predictionClient = undefined;
|
|
83
104
|
|
|
84
|
-
this.googleAuth = new GoogleAuth(options.googleAuthOptions)
|
|
105
|
+
this.googleAuth = new GoogleAuth(options.googleAuthOptions);
|
|
85
106
|
this.authClientPromise = undefined;
|
|
86
107
|
}
|
|
87
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Cleanup Google Cloud clients when the driver is evicted from the cache.
|
|
111
|
+
* `super.destroy()` releases the HTTP agent socket pool created by
|
|
112
|
+
* {@link AbstractDriver.getHttpAgent} / {@link AbstractDriver.getDriverFetch}.
|
|
113
|
+
*/
|
|
114
|
+
destroy(): void {
|
|
115
|
+
this.aiplatform?.close();
|
|
116
|
+
this.modelGarden?.close();
|
|
117
|
+
this.imagenClient?.close();
|
|
118
|
+
this.predictionClient?.close();
|
|
119
|
+
super.destroy();
|
|
120
|
+
}
|
|
121
|
+
|
|
88
122
|
private async getAuthClient(): Promise<AuthClient> {
|
|
89
123
|
if (!this.authClientPromise) {
|
|
90
124
|
this.authClientPromise = this.googleAuth.getClient();
|
|
@@ -92,10 +126,46 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
92
126
|
return this.authClientPromise;
|
|
93
127
|
}
|
|
94
128
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.
|
|
98
|
-
|
|
129
|
+
private getSdkRequestTimeoutMs(httpTimeout?: HttpTimeoutOptions): number {
|
|
130
|
+
const timeouts = resolveDriverHttpTimeouts(
|
|
131
|
+
mergeDriverHttpTimeoutOptions(this.options.httpTimeout, httpTimeout),
|
|
132
|
+
);
|
|
133
|
+
return Math.max(timeouts.headersTimeout, timeouts.bodyTimeout);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private getGoogleGenAIHttpOptions(flex: boolean, httpTimeout?: HttpTimeoutOptions) {
|
|
137
|
+
return {
|
|
138
|
+
timeout: this.getSdkRequestTimeoutMs(httpTimeout),
|
|
139
|
+
...(flex
|
|
140
|
+
? {
|
|
141
|
+
headers: {
|
|
142
|
+
'X-Vertex-AI-LLM-Request-Type': 'shared',
|
|
143
|
+
'X-Vertex-AI-LLM-Shared-Request-Type': 'flex',
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
: {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private getAnthropicVertexClientOptions(region: string, authClient: AuthClient, httpTimeout?: HttpTimeoutOptions) {
|
|
151
|
+
return {
|
|
152
|
+
timeout: this.getSdkRequestTimeoutMs(httpTimeout),
|
|
153
|
+
region,
|
|
154
|
+
projectId: this.options.project,
|
|
155
|
+
authClient: authClient,
|
|
156
|
+
fetch: this.getDriverFetch(),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public getGoogleGenAIClient(
|
|
161
|
+
region: string = this.options.region,
|
|
162
|
+
flex: boolean = false,
|
|
163
|
+
httpTimeout?: HttpTimeoutOptions,
|
|
164
|
+
): GoogleGenAI {
|
|
165
|
+
if (httpTimeout) {
|
|
166
|
+
return this.buildGoogleGenAIClient(region, flex, httpTimeout);
|
|
167
|
+
}
|
|
168
|
+
if (this.googleGenAI && this.googleGenAIRegion === region && this.googleGenAIFlex === flex) {
|
|
99
169
|
// Return existing client if region and flex settings match
|
|
100
170
|
return this.googleGenAI;
|
|
101
171
|
}
|
|
@@ -105,31 +175,25 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
105
175
|
return this.googleGenAI;
|
|
106
176
|
}
|
|
107
177
|
|
|
108
|
-
private buildGoogleGenAIClient(region: string, flex: boolean): GoogleGenAI {
|
|
178
|
+
private buildGoogleGenAIClient(region: string, flex: boolean, httpTimeout?: HttpTimeoutOptions): GoogleGenAI {
|
|
109
179
|
return new GoogleGenAI({
|
|
110
180
|
project: this.options.project,
|
|
111
181
|
location: region,
|
|
112
182
|
vertexai: true,
|
|
113
183
|
googleAuthOptions: this.options.googleAuthOptions || {
|
|
114
|
-
scopes: [
|
|
184
|
+
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
|
|
115
185
|
},
|
|
116
|
-
|
|
117
|
-
httpOptions: {
|
|
118
|
-
headers: {
|
|
119
|
-
"X-Vertex-AI-LLM-Request-Type": "shared",
|
|
120
|
-
"X-Vertex-AI-LLM-Shared-Request-Type": "flex",
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
} : {}),
|
|
186
|
+
httpOptions: this.getGoogleGenAIHttpOptions(flex, httpTimeout),
|
|
124
187
|
});
|
|
125
188
|
}
|
|
126
189
|
|
|
127
|
-
public getFetchClient(): FetchClient {
|
|
190
|
+
public getFetchClient(region: string = this.options.region): FetchClient {
|
|
128
191
|
//Lazy initialization
|
|
129
192
|
if (!this.fetchClient) {
|
|
130
193
|
this.fetchClient = createFetchClient({
|
|
131
|
-
region:
|
|
194
|
+
region: region,
|
|
132
195
|
project: this.options.project,
|
|
196
|
+
fetchImpl: this.getDriverFetch(),
|
|
133
197
|
}).withAuthCallback(async () => {
|
|
134
198
|
const token = await this.googleAuth.getAccessToken();
|
|
135
199
|
return `Bearer ${token}`;
|
|
@@ -138,24 +202,28 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
138
202
|
return this.fetchClient;
|
|
139
203
|
}
|
|
140
204
|
|
|
141
|
-
public getLLamaClient(region: string =
|
|
205
|
+
public getLLamaClient(region: string = 'us-central1'): FetchClient {
|
|
142
206
|
//Lazy initialization
|
|
143
|
-
if (!this.llamaClient || this.llamaClient
|
|
207
|
+
if (!this.llamaClient || this.llamaClient.region !== region) {
|
|
144
208
|
this.llamaClient = createFetchClient({
|
|
145
209
|
region: region,
|
|
146
210
|
project: this.options.project,
|
|
147
|
-
apiVersion:
|
|
211
|
+
apiVersion: 'v1beta1',
|
|
212
|
+
fetchImpl: this.getDriverFetch(),
|
|
148
213
|
}).withAuthCallback(async () => {
|
|
149
214
|
const token = await this.googleAuth.getAccessToken();
|
|
150
215
|
return `Bearer ${token}`;
|
|
151
216
|
});
|
|
152
217
|
// Store the region for potential client reuse
|
|
153
|
-
this.llamaClient
|
|
218
|
+
this.llamaClient.region = region;
|
|
154
219
|
}
|
|
155
220
|
return this.llamaClient;
|
|
156
221
|
}
|
|
157
222
|
|
|
158
|
-
public async getAnthropicClient(
|
|
223
|
+
public async getAnthropicClient(
|
|
224
|
+
region: string = this.options.region,
|
|
225
|
+
httpTimeout?: HttpTimeoutOptions,
|
|
226
|
+
): Promise<AnthropicVertex> {
|
|
159
227
|
// Extract region prefix and map if it exists in ANTHROPIC_REGIONS, otherwise use as-is
|
|
160
228
|
const getRegionPrefix = (r: string) => r.split('-')[0];
|
|
161
229
|
const regionPrefix = getRegionPrefix(region);
|
|
@@ -168,23 +236,13 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
168
236
|
const authClient = await this.getAuthClient();
|
|
169
237
|
|
|
170
238
|
// If mapped region is different from default mapped region, create one-off client
|
|
171
|
-
if (mappedRegion !== defaultMappedRegion) {
|
|
172
|
-
return new AnthropicVertex(
|
|
173
|
-
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
|
|
174
|
-
region: mappedRegion,
|
|
175
|
-
projectId: this.options.project,
|
|
176
|
-
authClient: authClient as unknown as AnthropicVertexClientOptions["authClient"],
|
|
177
|
-
});
|
|
239
|
+
if (httpTimeout || mappedRegion !== defaultMappedRegion) {
|
|
240
|
+
return new AnthropicVertex(this.getAnthropicVertexClientOptions(mappedRegion, authClient, httpTimeout));
|
|
178
241
|
}
|
|
179
242
|
|
|
180
243
|
//Lazy initialization for default region
|
|
181
244
|
if (!this.anthropicClient) {
|
|
182
|
-
this.anthropicClient = new AnthropicVertex(
|
|
183
|
-
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
|
|
184
|
-
region: mappedRegion,
|
|
185
|
-
projectId: this.options.project,
|
|
186
|
-
authClient: authClient as unknown as AnthropicVertexClientOptions["authClient"],
|
|
187
|
-
});
|
|
245
|
+
this.anthropicClient = new AnthropicVertex(this.getAnthropicVertexClientOptions(mappedRegion, authClient));
|
|
188
246
|
}
|
|
189
247
|
return this.anthropicClient;
|
|
190
248
|
}
|
|
@@ -229,10 +287,23 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
229
287
|
return this.imagenClient;
|
|
230
288
|
}
|
|
231
289
|
|
|
290
|
+
public async getPredictionServiceClient(): Promise<PredictionServiceClient> {
|
|
291
|
+
//Lazy initialization using the driver's configured region
|
|
292
|
+
if (!this.predictionClient) {
|
|
293
|
+
const authClient = await this.getAuthClient();
|
|
294
|
+
this.predictionClient = new PredictionServiceClient({
|
|
295
|
+
projectId: this.options.project,
|
|
296
|
+
apiEndpoint: `${this.options.region}-${API_BASE_PATH}`,
|
|
297
|
+
authClient,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return this.predictionClient;
|
|
301
|
+
}
|
|
302
|
+
|
|
232
303
|
validateResult(result: Completion, options: ExecutionOptions) {
|
|
233
304
|
// Optionally preprocess the result before validation
|
|
234
305
|
const modelDef = getModelDefinition(options.model);
|
|
235
|
-
if (typeof modelDef.preValidationProcessing ===
|
|
306
|
+
if (typeof modelDef.preValidationProcessing === 'function') {
|
|
236
307
|
const processed = modelDef.preValidationProcessing(result, options);
|
|
237
308
|
result = processed.result;
|
|
238
309
|
options = processed.options;
|
|
@@ -249,7 +320,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
249
320
|
}
|
|
250
321
|
|
|
251
322
|
protected isImageModel(model: string): boolean {
|
|
252
|
-
return model.includes(
|
|
323
|
+
return model.includes('imagen');
|
|
253
324
|
}
|
|
254
325
|
|
|
255
326
|
public createPrompt(segments: PromptSegment[], options: ExecutionOptions): Promise<VertexAIPrompt> {
|
|
@@ -259,6 +330,19 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
259
330
|
return getModelDefinition(options.model).createPrompt(this, segments, options);
|
|
260
331
|
}
|
|
261
332
|
|
|
333
|
+
public formatDebugPrompt(prompt: VertexAIPrompt): VertexAIPrompt {
|
|
334
|
+
if (isClaudePrompt(prompt)) {
|
|
335
|
+
return formatClaudeDebugPrompt(prompt);
|
|
336
|
+
}
|
|
337
|
+
if ('contents' in prompt) {
|
|
338
|
+
return formatGeminiDebugPrompt(prompt);
|
|
339
|
+
}
|
|
340
|
+
if ('messages' in prompt) {
|
|
341
|
+
return prompt;
|
|
342
|
+
}
|
|
343
|
+
return formatImagenDebugPrompt(prompt);
|
|
344
|
+
}
|
|
345
|
+
|
|
262
346
|
async requestTextCompletion(prompt: VertexAIPrompt, options: ExecutionOptions): Promise<Completion> {
|
|
263
347
|
return getModelDefinition(options.model).requestTextCompletion(this, prompt, options);
|
|
264
348
|
}
|
|
@@ -278,11 +362,11 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
278
362
|
prompt: VertexAIPrompt,
|
|
279
363
|
result: unknown[],
|
|
280
364
|
toolUse: unknown[] | undefined,
|
|
281
|
-
options: ExecutionOptions
|
|
365
|
+
options: ExecutionOptions,
|
|
282
366
|
): Content[] | unknown | undefined {
|
|
283
367
|
// Handle Claude-style prompts (has 'messages' array)
|
|
284
|
-
if (
|
|
285
|
-
return this.buildClaudeStreamingConversation(prompt
|
|
368
|
+
if (isClaudeStreamingPrompt(prompt)) {
|
|
369
|
+
return this.buildClaudeStreamingConversation(prompt, result, toolUse, options);
|
|
286
370
|
}
|
|
287
371
|
|
|
288
372
|
// Only handle Gemini-style prompts with contents array
|
|
@@ -294,7 +378,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
294
378
|
|
|
295
379
|
// Convert accumulated results to text content for assistant message
|
|
296
380
|
const textContent = completionResults
|
|
297
|
-
.map(r => {
|
|
381
|
+
.map((r) => {
|
|
298
382
|
switch (r.type) {
|
|
299
383
|
case 'text':
|
|
300
384
|
return r.value;
|
|
@@ -303,25 +387,27 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
303
387
|
case 'image':
|
|
304
388
|
// Skip images in conversation - they're in the result
|
|
305
389
|
return '';
|
|
306
|
-
default:
|
|
307
|
-
|
|
390
|
+
default: {
|
|
391
|
+
const _exhaustive: never = r;
|
|
392
|
+
return String(_exhaustive);
|
|
393
|
+
}
|
|
308
394
|
}
|
|
309
395
|
})
|
|
310
396
|
.join('');
|
|
311
397
|
|
|
312
398
|
// Build parts array for assistant message
|
|
313
|
-
const parts:
|
|
399
|
+
const parts: unknown[] = [];
|
|
314
400
|
if (textContent) {
|
|
315
401
|
parts.push({ text: textContent });
|
|
316
402
|
}
|
|
317
403
|
// Add function calls if present (Gemini format)
|
|
318
404
|
if (toolUse && toolUse.length > 0) {
|
|
319
|
-
for (const tool of toolUse as
|
|
320
|
-
const functionCallPart:
|
|
405
|
+
for (const tool of toolUse as ToolUse<unknown>[]) {
|
|
406
|
+
const functionCallPart: Record<string, unknown> = {
|
|
321
407
|
functionCall: {
|
|
322
408
|
name: tool.tool_name,
|
|
323
409
|
args: tool.tool_input,
|
|
324
|
-
}
|
|
410
|
+
},
|
|
325
411
|
};
|
|
326
412
|
// Include thought_signature for Gemini thinking models (2.5+/3.0+)
|
|
327
413
|
// This must be preserved in the conversation for subsequent API calls
|
|
@@ -335,16 +421,14 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
335
421
|
// prompt.contents already includes the conversation history
|
|
336
422
|
// (merged in requestTextCompletionStream via updateConversation),
|
|
337
423
|
// so we use it directly — do NOT prepend options.conversation again.
|
|
338
|
-
let conversation: Content[] = [
|
|
339
|
-
...prompt.contents,
|
|
340
|
-
];
|
|
424
|
+
let conversation: Content[] = [...prompt.contents];
|
|
341
425
|
|
|
342
426
|
// Only add assistant message if there's actual content
|
|
343
427
|
// (Empty text parts can cause API errors)
|
|
344
428
|
if (parts.length > 0) {
|
|
345
429
|
conversation.push({
|
|
346
430
|
role: 'model',
|
|
347
|
-
parts: parts
|
|
431
|
+
parts: parts as Content['parts'],
|
|
348
432
|
});
|
|
349
433
|
}
|
|
350
434
|
|
|
@@ -356,7 +440,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
356
440
|
const stripOptions = {
|
|
357
441
|
keepForTurns: options.stripImagesAfterTurns ?? Infinity,
|
|
358
442
|
currentTurn,
|
|
359
|
-
textMaxTokens: options.stripTextMaxTokens
|
|
443
|
+
textMaxTokens: options.stripTextMaxTokens,
|
|
360
444
|
};
|
|
361
445
|
let processedConversation = stripBase64ImagesFromConversation(conversation, stripOptions);
|
|
362
446
|
processedConversation = truncateLargeTextInConversation(processedConversation, stripOptions);
|
|
@@ -371,7 +455,10 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
371
455
|
const geminiPrompt = prompt as GenerateContentPrompt;
|
|
372
456
|
if (geminiPrompt.system) {
|
|
373
457
|
if (typeof processedConversation === 'object' && processedConversation !== null) {
|
|
374
|
-
processedConversation = {
|
|
458
|
+
processedConversation = {
|
|
459
|
+
...(processedConversation as object),
|
|
460
|
+
_llumiverse_system: geminiPrompt.system,
|
|
461
|
+
};
|
|
375
462
|
}
|
|
376
463
|
}
|
|
377
464
|
|
|
@@ -386,13 +473,13 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
386
473
|
prompt: { messages: unknown[]; system?: unknown[] },
|
|
387
474
|
result: unknown[],
|
|
388
475
|
toolUse: unknown[] | undefined,
|
|
389
|
-
options: ExecutionOptions
|
|
476
|
+
options: ExecutionOptions,
|
|
390
477
|
): unknown {
|
|
391
478
|
const completionResults = result as CompletionResult[];
|
|
392
479
|
|
|
393
480
|
// Convert accumulated results to text content
|
|
394
481
|
const textContent = completionResults
|
|
395
|
-
.map(r => {
|
|
482
|
+
.map((r) => {
|
|
396
483
|
switch (r.type) {
|
|
397
484
|
case 'text':
|
|
398
485
|
return r.value;
|
|
@@ -400,8 +487,10 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
400
487
|
return typeof r.value === 'string' ? r.value : JSON.stringify(r.value);
|
|
401
488
|
case 'image':
|
|
402
489
|
return '';
|
|
403
|
-
default:
|
|
404
|
-
|
|
490
|
+
default: {
|
|
491
|
+
const _exhaustive: never = r;
|
|
492
|
+
return String(_exhaustive);
|
|
493
|
+
}
|
|
405
494
|
}
|
|
406
495
|
})
|
|
407
496
|
.join('');
|
|
@@ -413,46 +502,44 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
413
502
|
if (textContent) {
|
|
414
503
|
content.push({
|
|
415
504
|
type: 'text',
|
|
416
|
-
text: textContent
|
|
505
|
+
text: textContent,
|
|
417
506
|
});
|
|
418
507
|
}
|
|
419
508
|
|
|
420
509
|
// Add tool_use blocks in Claude format
|
|
421
510
|
if (toolUse && toolUse.length > 0) {
|
|
422
|
-
for (const tool of toolUse as
|
|
511
|
+
for (const tool of toolUse as ToolUse<unknown>[]) {
|
|
423
512
|
content.push({
|
|
424
513
|
type: 'tool_use',
|
|
425
514
|
id: tool.id,
|
|
426
515
|
name: tool.tool_name,
|
|
427
|
-
input: tool.tool_input ?? {}
|
|
516
|
+
input: tool.tool_input ?? {},
|
|
428
517
|
});
|
|
429
518
|
}
|
|
430
519
|
}
|
|
431
520
|
|
|
432
521
|
// Claude's requestTextCompletionStream does NOT mutate prompt.messages
|
|
433
522
|
// to include history, so we must prepend options.conversation here.
|
|
434
|
-
const
|
|
435
|
-
const
|
|
523
|
+
const existingConversation = options.conversation as ConversationWrapper | undefined;
|
|
524
|
+
const existingMessages = existingConversation?.messages ?? [];
|
|
525
|
+
const existingSystem = existingConversation?.system ?? prompt.system;
|
|
436
526
|
|
|
437
527
|
// Build the new messages array
|
|
438
|
-
const newMessages = [
|
|
439
|
-
...existingMessages,
|
|
440
|
-
...prompt.messages,
|
|
441
|
-
];
|
|
528
|
+
const newMessages = [...existingMessages, ...prompt.messages];
|
|
442
529
|
|
|
443
530
|
// Only add assistant message if there's actual content
|
|
444
531
|
// (Claude API rejects empty text content blocks)
|
|
445
532
|
if (content.length > 0) {
|
|
446
533
|
newMessages.push({
|
|
447
534
|
role: 'assistant',
|
|
448
|
-
content: content
|
|
535
|
+
content: content,
|
|
449
536
|
});
|
|
450
537
|
}
|
|
451
538
|
|
|
452
539
|
// Build the new conversation in ClaudePrompt format
|
|
453
540
|
const conversation = {
|
|
454
541
|
messages: newMessages,
|
|
455
|
-
system: existingSystem
|
|
542
|
+
system: existingSystem,
|
|
456
543
|
};
|
|
457
544
|
|
|
458
545
|
// Increment turn counter
|
|
@@ -463,7 +550,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
463
550
|
const stripOptions = {
|
|
464
551
|
keepForTurns: options.stripImagesAfterTurns ?? Infinity,
|
|
465
552
|
currentTurn,
|
|
466
|
-
textMaxTokens: options.stripTextMaxTokens
|
|
553
|
+
textMaxTokens: options.stripTextMaxTokens,
|
|
467
554
|
};
|
|
468
555
|
let processedConversation = stripBase64ImagesFromConversation(withTurn, stripOptions);
|
|
469
556
|
processedConversation = truncateLargeTextInConversation(processedConversation, stripOptions);
|
|
@@ -475,11 +562,8 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
475
562
|
return processedConversation;
|
|
476
563
|
}
|
|
477
564
|
|
|
478
|
-
async requestImageGeneration(
|
|
479
|
-
|
|
480
|
-
_options: ExecutionOptions,
|
|
481
|
-
): Promise<Completion> {
|
|
482
|
-
const splits = _options.model.split("/");
|
|
565
|
+
async requestImageGeneration(_prompt: ImagenPrompt, _options: ExecutionOptions): Promise<Completion> {
|
|
566
|
+
const splits = _options.model.split('/');
|
|
483
567
|
const modelName = trimModelName(splits[splits.length - 1]);
|
|
484
568
|
return new ImagenModelDefinition(modelName).requestImageGeneration(this, _prompt, _options);
|
|
485
569
|
}
|
|
@@ -497,36 +581,42 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
497
581
|
// Get clients
|
|
498
582
|
const modelGarden = await this.getModelGardenClient();
|
|
499
583
|
const aiplatform = await this.getAIPlatformClient();
|
|
500
|
-
const globalGenAiClient = this.getGoogleGenAIClient(
|
|
584
|
+
const globalGenAiClient = this.getGoogleGenAIClient('global');
|
|
501
585
|
|
|
502
586
|
let models: AIModel<string>[] = [];
|
|
503
587
|
|
|
504
588
|
//Model Garden Publisher models - Pretrained models
|
|
505
|
-
const publishers = [
|
|
589
|
+
const publishers = ['google', 'anthropic', 'meta'];
|
|
506
590
|
// Meta "maas" models are LLama Models-As-A-Service. Non-maas models are not pre-deployed.
|
|
507
|
-
const supportedModels = { google: [
|
|
591
|
+
const supportedModels = { google: ['gemini', 'imagen'], anthropic: ['claude'], meta: ['maas'] };
|
|
508
592
|
// Additional models not in the listings, but we want to include
|
|
509
593
|
// TODO: Remove once the models are available in the listing API, or no longer needed
|
|
510
594
|
const additionalModels = {
|
|
511
|
-
google: [
|
|
512
|
-
"imagen-3.0-fast-generate-001",
|
|
513
|
-
],
|
|
595
|
+
google: ['imagen-3.0-fast-generate-001'],
|
|
514
596
|
anthropic: [],
|
|
515
597
|
meta: [
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
598
|
+
'llama-4-maverick-17b-128e-instruct-maas',
|
|
599
|
+
'llama-4-scout-17b-16e-instruct-maas',
|
|
600
|
+
'llama-3.3-70b-instruct-maas',
|
|
601
|
+
'llama-3.2-90b-vision-instruct-maas',
|
|
602
|
+
'llama-3.1-405b-instruct-maas',
|
|
603
|
+
'llama-3.1-70b-instruct-maas',
|
|
604
|
+
'llama-3.1-8b-instruct-maas',
|
|
523
605
|
],
|
|
524
|
-
}
|
|
606
|
+
};
|
|
525
607
|
|
|
526
608
|
//Used to exclude retired models that are still in the listing API but not available for use.
|
|
527
609
|
//Or models we do not support yet
|
|
528
610
|
const unsupportedModelsByPublisher = {
|
|
529
|
-
google: [
|
|
611
|
+
google: [
|
|
612
|
+
'gemini-pro',
|
|
613
|
+
'gemini-ultra',
|
|
614
|
+
'imagen-product-recontext-preview',
|
|
615
|
+
'embedding',
|
|
616
|
+
'embed',
|
|
617
|
+
'gemini-live-2.5-flash-preview-native-audio',
|
|
618
|
+
'computer-use-preview',
|
|
619
|
+
],
|
|
530
620
|
anthropic: [],
|
|
531
621
|
meta: [],
|
|
532
622
|
};
|
|
@@ -538,7 +628,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
538
628
|
const publisherPromises = publishers.map(async (publisher) => {
|
|
539
629
|
const [response] = await modelGarden.listPublisherModels({
|
|
540
630
|
parent: `publishers/${publisher}`,
|
|
541
|
-
orderBy:
|
|
631
|
+
orderBy: 'name',
|
|
542
632
|
listAllVersions: true,
|
|
543
633
|
});
|
|
544
634
|
return { publisher, response };
|
|
@@ -556,124 +646,138 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
556
646
|
const [response] = aiplatformResult;
|
|
557
647
|
models = models.concat(
|
|
558
648
|
response.map((model) => ({
|
|
559
|
-
id: model.name?.split(
|
|
560
|
-
name: model.displayName ??
|
|
561
|
-
provider:
|
|
562
|
-
}))
|
|
649
|
+
id: model.name?.split('/').pop() ?? '',
|
|
650
|
+
name: model.displayName ?? '',
|
|
651
|
+
provider: 'vertexai',
|
|
652
|
+
})),
|
|
563
653
|
);
|
|
564
654
|
|
|
565
655
|
// Process global google models from GenAI
|
|
656
|
+
// Exclude embedding, retired and or unsupported models
|
|
657
|
+
const excludedModels = unsupportedModelsByPublisher.google;
|
|
566
658
|
models = models.concat(
|
|
567
|
-
globalGoogleResult
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
659
|
+
globalGoogleResult
|
|
660
|
+
.filter((model) => !excludedModels.includes(model.name ?? ''))
|
|
661
|
+
.map((model) => {
|
|
662
|
+
const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
|
|
663
|
+
return {
|
|
664
|
+
id: `locations/global/${model.name}`,
|
|
665
|
+
name: `Global ${model.name?.split('/').pop()}`,
|
|
666
|
+
provider: 'vertexai',
|
|
667
|
+
owner: 'google',
|
|
668
|
+
input_modalities: modelModalitiesToArray(modelCapability.input),
|
|
669
|
+
output_modalities: modelModalitiesToArray(modelCapability.output),
|
|
670
|
+
tool_support: modelCapability.tool_support,
|
|
671
|
+
};
|
|
672
|
+
}),
|
|
579
673
|
);
|
|
580
674
|
|
|
581
675
|
// Process publisher models
|
|
582
676
|
for (const result of publisherResults) {
|
|
583
677
|
const { publisher, response } = result;
|
|
584
678
|
const modelFamily = supportedModels[publisher as keyof typeof supportedModels];
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
models = models.concat(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
679
|
+
const excludedModels = unsupportedModelsByPublisher[publisher as keyof typeof unsupportedModelsByPublisher];
|
|
680
|
+
|
|
681
|
+
models = models.concat(
|
|
682
|
+
response
|
|
683
|
+
.filter((model) => {
|
|
684
|
+
const modelName = model.name ?? '';
|
|
685
|
+
// Exclude embedding, retired and or unsupported models
|
|
686
|
+
if (excludedModels.some((retiredModel) => modelName.includes(retiredModel))) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
// Check if the model belongs to the supported model families
|
|
690
|
+
if (modelFamily.some((family) => modelName.includes(family))) {
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
return false;
|
|
694
|
+
})
|
|
695
|
+
.map((model) => {
|
|
696
|
+
const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
|
|
697
|
+
return {
|
|
698
|
+
id: model.name ?? '',
|
|
699
|
+
name: model.name?.split('/').pop() ?? '',
|
|
700
|
+
provider: 'vertexai',
|
|
701
|
+
owner: publisher,
|
|
702
|
+
input_modalities: modelModalitiesToArray(modelCapability.input),
|
|
703
|
+
output_modalities: modelModalitiesToArray(modelCapability.output),
|
|
704
|
+
tool_support: modelCapability.tool_support,
|
|
705
|
+
} satisfies AIModel<string>;
|
|
706
|
+
}),
|
|
707
|
+
);
|
|
610
708
|
|
|
611
709
|
// Create global google gemini models for Gemini 2.5 and later, if missing from GenAI listing
|
|
612
710
|
if (publisher === 'google') {
|
|
613
|
-
const globalGeminiModels = response
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
711
|
+
const globalGeminiModels = response
|
|
712
|
+
.filter((model) => {
|
|
713
|
+
const modelName = model.name ?? '';
|
|
714
|
+
if (excludedModels.some((retiredModel) => modelName.includes(retiredModel))) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
if (modelFamily.some((family) => modelName.includes(family))) {
|
|
718
|
+
const versionMatch = modelName.match(/gemini-(\d+(?:\.\d+)?)/);
|
|
719
|
+
if (versionMatch) {
|
|
720
|
+
const version = parseFloat(versionMatch[1]);
|
|
721
|
+
if (version >= 2.5) {
|
|
722
|
+
// Check if already present
|
|
723
|
+
const shortName = modelName.split('/').pop();
|
|
724
|
+
const globalName = `Global ${shortName}`;
|
|
725
|
+
if (models.some((m) => m.name === globalName)) {
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
return true;
|
|
628
729
|
}
|
|
629
|
-
return true;
|
|
630
730
|
}
|
|
731
|
+
return false;
|
|
631
732
|
}
|
|
632
733
|
return false;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
});
|
|
734
|
+
})
|
|
735
|
+
.map((model) => {
|
|
736
|
+
const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
|
|
737
|
+
return {
|
|
738
|
+
id: `locations/global/${model.name}`,
|
|
739
|
+
name: `Global ${model.name?.split('/').pop()}`,
|
|
740
|
+
provider: 'vertexai',
|
|
741
|
+
owner: publisher,
|
|
742
|
+
input_modalities: modelModalitiesToArray(modelCapability.input),
|
|
743
|
+
output_modalities: modelModalitiesToArray(modelCapability.output),
|
|
744
|
+
tool_support: modelCapability.tool_support,
|
|
745
|
+
} satisfies AIModel<string>;
|
|
746
|
+
});
|
|
647
747
|
|
|
648
748
|
models = models.concat(globalGeminiModels);
|
|
649
749
|
}
|
|
650
750
|
|
|
651
751
|
// Create global anthropic models for those not in NON_GLOBAL_ANTHROPIC_MODELS
|
|
652
752
|
if (publisher === 'anthropic') {
|
|
653
|
-
const globalAnthropicModels = response
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (modelFamily.some(family => modelName.includes(family))) {
|
|
659
|
-
if (modelName.includes("claude-3-7")) {
|
|
660
|
-
return true;
|
|
753
|
+
const globalAnthropicModels = response
|
|
754
|
+
.filter((model) => {
|
|
755
|
+
const modelName = model.name ?? '';
|
|
756
|
+
if (excludedModels.some((retiredModel) => modelName.includes(retiredModel))) {
|
|
757
|
+
return false;
|
|
661
758
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
759
|
+
if (modelFamily.some((family) => modelName.includes(family))) {
|
|
760
|
+
if (modelName.includes('claude-3-7')) {
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
return !NON_GLOBAL_ANTHROPIC_MODELS.some((nonGlobalModel) =>
|
|
764
|
+
modelName.includes(nonGlobalModel),
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
return false;
|
|
768
|
+
})
|
|
769
|
+
.map((model) => {
|
|
770
|
+
const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
|
|
771
|
+
return {
|
|
772
|
+
id: `locations/global/${model.name}`,
|
|
773
|
+
name: `Global ${model.name?.split('/').pop()}`,
|
|
774
|
+
provider: 'vertexai',
|
|
775
|
+
owner: publisher,
|
|
776
|
+
input_modalities: modelModalitiesToArray(modelCapability.input),
|
|
777
|
+
output_modalities: modelModalitiesToArray(modelCapability.output),
|
|
778
|
+
tool_support: modelCapability.tool_support,
|
|
779
|
+
} satisfies AIModel<string>;
|
|
780
|
+
});
|
|
677
781
|
|
|
678
782
|
models = models.concat(globalAnthropicModels);
|
|
679
783
|
}
|
|
@@ -681,7 +785,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
681
785
|
// Add additional models that are not in the listing
|
|
682
786
|
for (const additionalModel of additionalModels[publisher as keyof typeof additionalModels]) {
|
|
683
787
|
const publisherModelName = `publishers/${publisher}/models/${additionalModel}`;
|
|
684
|
-
const modelCapability = getModelCapabilities(additionalModel,
|
|
788
|
+
const modelCapability = getModelCapabilities(additionalModel, 'vertexai');
|
|
685
789
|
models.push({
|
|
686
790
|
id: publisherModelName,
|
|
687
791
|
name: additionalModel,
|
|
@@ -695,54 +799,33 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
695
799
|
}
|
|
696
800
|
|
|
697
801
|
//Remove duplicates
|
|
698
|
-
const uniqueModels = Array.from(new Set(models.map(a => a.id)))
|
|
699
|
-
.map(id => {
|
|
700
|
-
return models.find(a => a.id === id) ?? {} as AIModel<string
|
|
701
|
-
})
|
|
802
|
+
const uniqueModels = Array.from(new Set(models.map((a) => a.id)))
|
|
803
|
+
.map((id) => {
|
|
804
|
+
return models.find((a) => a.id === id) ?? ({} as AIModel<string>);
|
|
805
|
+
})
|
|
806
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
702
807
|
|
|
703
808
|
return uniqueModels;
|
|
704
809
|
}
|
|
705
810
|
|
|
706
811
|
validateConnection(): Promise<boolean> {
|
|
707
|
-
throw new Error(
|
|
812
|
+
throw new Error('Method not implemented.');
|
|
708
813
|
}
|
|
709
814
|
|
|
710
815
|
async generateEmbeddings(options: EmbeddingsOptions): Promise<EmbeddingsResult> {
|
|
711
|
-
|
|
712
|
-
if (options.text && options.image) {
|
|
713
|
-
throw new Error("Text and Image simultaneous embedding not implemented. Submit separately");
|
|
714
|
-
}
|
|
715
|
-
return getEmbeddingsForImages(this, options);
|
|
716
|
-
}
|
|
717
|
-
const text_options: TextEmbeddingsOptions = {
|
|
718
|
-
content: options.text ?? "",
|
|
719
|
-
model: options.model,
|
|
720
|
-
};
|
|
721
|
-
return getEmbeddingsForText(this, text_options);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* Cleanup Google Cloud clients when the driver is evicted from the cache.
|
|
726
|
-
*/
|
|
727
|
-
destroy(): void {
|
|
728
|
-
this.aiplatform?.close();
|
|
729
|
-
this.modelGarden?.close();
|
|
730
|
-
this.imagenClient?.close();
|
|
816
|
+
return generateVertexAiEmbeddings(this, options);
|
|
731
817
|
}
|
|
732
818
|
|
|
733
819
|
/**
|
|
734
820
|
* Format VertexAI errors by routing to model-specific error handlers.
|
|
735
821
|
* Each model definition (Gemini, Claude, Llama) can provide custom error parsing
|
|
736
822
|
* based on their specific SDK error structures.
|
|
737
|
-
*
|
|
823
|
+
*
|
|
738
824
|
* @param error - The error from the VertexAI/model SDK
|
|
739
825
|
* @param context - Context about where the error occurred
|
|
740
826
|
* @returns A standardized LlumiverseError
|
|
741
827
|
*/
|
|
742
|
-
public formatLlumiverseError(
|
|
743
|
-
error: unknown,
|
|
744
|
-
context: LlumiverseErrorContext
|
|
745
|
-
): LlumiverseError {
|
|
828
|
+
public formatLlumiverseError(error: unknown, context: LlumiverseErrorContext): LlumiverseError {
|
|
746
829
|
// Get the model definition for this request
|
|
747
830
|
const modelDef = getModelDefinition(context.model);
|
|
748
831
|
|
|
@@ -750,7 +833,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
750
833
|
if (modelDef.formatLlumiverseError) {
|
|
751
834
|
try {
|
|
752
835
|
return modelDef.formatLlumiverseError(this, error, context);
|
|
753
|
-
} catch
|
|
836
|
+
} catch {
|
|
754
837
|
// If model-specific handler throws, fall through to default handling
|
|
755
838
|
// This allows model handlers to explicitly opt out for certain errors
|
|
756
839
|
}
|
|
@@ -762,22 +845,25 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
762
845
|
}
|
|
763
846
|
|
|
764
847
|
//'us-central1-aiplatform.googleapis.com',
|
|
765
|
-
const API_BASE_PATH =
|
|
848
|
+
const API_BASE_PATH = 'aiplatform.googleapis.com';
|
|
766
849
|
function createFetchClient({
|
|
767
850
|
region,
|
|
768
851
|
project,
|
|
769
852
|
apiEndpoint,
|
|
770
|
-
apiVersion =
|
|
853
|
+
apiVersion = 'v1',
|
|
854
|
+
fetchImpl,
|
|
771
855
|
}: {
|
|
772
856
|
region: string;
|
|
773
857
|
project: string;
|
|
774
858
|
apiEndpoint?: string;
|
|
775
859
|
apiVersion?: string;
|
|
860
|
+
fetchImpl?: FETCH_FN;
|
|
776
861
|
}) {
|
|
777
862
|
const vertexBaseEndpoint = apiEndpoint ?? `${region}-${API_BASE_PATH}`;
|
|
778
863
|
return new FetchClient(
|
|
779
864
|
`https://${vertexBaseEndpoint}/${apiVersion}/projects/${project}/locations/${region}`,
|
|
865
|
+
fetchImpl,
|
|
780
866
|
).withHeaders({
|
|
781
|
-
|
|
867
|
+
'Content-Type': 'application/json',
|
|
782
868
|
});
|
|
783
869
|
}
|