Em Invoker
Modules concerning the embedding model invokers used in Gen AI applications.
AzureOpenAIEMInvoker(azure_endpoint, azure_deployment, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: OpenAIEMInvoker
An embedding model invoker to interact with Azure OpenAI embedding models.
Examples:
em_invoker = AzureOpenAIEMInvoker(
azure_endpoint="https://<your-azure-openai-endpoint>.openai.azure.com/openai/v1",
azure_deployment="<your-azure-openai-deployment>",
)
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Text input only
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the Azure OpenAI embedding model deployment. |
client_kwargs |
dict[str, Any]
|
The keyword arguments for the Azure OpenAI client. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the AzureOpenAIEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
azure_endpoint
|
str
|
The endpoint of the Azure OpenAI service. |
required |
azure_deployment
|
str
|
The deployment name of the Azure OpenAI service. |
required |
api_key
|
str | None
|
The API key for authenticating with Azure OpenAI. Defaults to None, in
which case the |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional model parameters. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
BedrockEMInvoker(model_name, access_key_id=None, secret_access_key=None, region_name='us-east-1', model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with AWS Bedrock embedding models.
Examples:
em_invoker = BedrockEMInvoker(model_name="cohere.embed-english-v3")
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Multimodal input a. Text b. Image (For Marengo models only)
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
session |
Session
|
The Bedrock client session. |
client_kwargs |
dict[str, Any]
|
The Bedrock client kwargs. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the BedrockEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the Bedrock embedding model to be used. |
required |
access_key_id
|
str | None
|
The AWS access key ID. Defaults to None, in which case
the |
None
|
secret_access_key
|
str | None
|
The AWS secret access key. Defaults to None, in which case
the |
None
|
region_name
|
str
|
The AWS region name. Defaults to "us-east-1". |
'us-east-1'
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the Bedrock client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the model name is not supported. |
ValueError
|
If |
CohereEMInvoker(model_name, api_key=None, base_url=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None, input_type=CohereInputType.SEARCH_DOCUMENT)
Bases: BaseEMInvoker
An embedding model invoker to interact with Cohere embedding models.
Examples:
em_invoker = CohereEMInvoker(model_name="embed-english-v4.0")
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Multimodal input a. Text b. Image
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model (Cohere). |
model_name |
str
|
The name of the Cohere embedding model. |
client |
AsyncClient
|
The asynchronous client for the Cohere API. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
input_type |
CohereInputType
|
The input type for the embedding model. Supported values include:
1. |
Initializes a new instance of the CohereEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the Cohere embedding model to be used. |
required |
api_key
|
str | None
|
The API key for authenticating with Cohere. Defaults to None, in which
case the |
None
|
base_url
|
str | None
|
The base URL for a custom Cohere-compatible endpoint. Defaults to None, in which case Cohere's default URL will be used. |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the Cohere client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
input_type
|
CohereInputType
|
The input type for the embedding model.
Defaults to |
SEARCH_DOCUMENT
|
GoogleEMInvoker(model_name, api_key=None, credentials_path=None, project_id=None, location='us-central1', model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with Google embedding models.
Examples:
em_invoker = GoogleEMInvoker(model_name="gemini-embedding-001")
result = await em_invoker.invoke("Hi there!")
Initialization
The GoogleEMInvoker can use either Google Gen AI or Google Vertex AI.
Google Gen AI is recommended for quick prototyping and development. It requires a Gemini API key for authentication.
Usage example:
em_invoker = GoogleEMInvoker(
model_name="gemini-embedding-001",
api_key="your_api_key"
)
Google Vertex AI is recommended to build production-ready applications. It requires a service account JSON file for authentication.
Usage example:
em_invoker = GoogleEMInvoker(
model_name="gemini-embedding-001",
credentials_path="path/to/service_account.json"
)
If neither api_key nor credentials_path is provided, Google Gen AI will be used by default.
The GOOGLE_API_KEY environment variable will be used for authentication.
Supported features
- Basic invocation
- Batch invocation
- Multimodal input a. Text b. Image c. Audio d. Video e. Document
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
client_params |
dict[str, Any]
|
The Google client instance init parameters. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the GoogleEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the model to use. |
required |
api_key
|
str | None
|
Required for Google Gen AI authentication. Cannot be used together
with |
None
|
credentials_path
|
str | None
|
Required for Google Vertex AI authentication. Path to the service
account credentials JSON file. Cannot be used together with |
None
|
project_id
|
str | None
|
The Google Cloud project ID for Vertex AI. Only used when authenticating
with |
None
|
location
|
str
|
The location of the Google Cloud project for Vertex AI. Only used when
authenticating with |
'us-central1'
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the Google client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
Note
If neither api_key nor credentials_path is provided, Google Gen AI will be used by default.
The GOOGLE_API_KEY environment variable will be used for authentication.
JinaEMInvoker(model_name, api_key=None, base_url=JINA_DEFAULT_URL, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with Jina AI embedding models.
Examples:
em_invoker = JinaEMInvoker(model_name="jina-embeddings-v2-large")
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Multimodal input a. Text b. Image
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
client |
AsyncClient
|
The client for the Jina AI API. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the JinaEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the Jina embedding model to be used. |
required |
api_key
|
str | None
|
The API key for authenticating with Jina AI.
Defaults to None, in which case the |
None
|
base_url
|
str
|
The base URL for the Jina AI API. Defaults to "https://api.jina.ai/v1". |
JINA_DEFAULT_URL
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the HTTP client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
LangChainEMInvoker(model=None, model_class_path=None, model_name=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with LangChain's Embeddings.
Examples:
em_invoker = LangChainEMInvoker(
model_class_path="langchain_openai.OpenAIEmbeddings",
model_name="text-embedding-3-small",
)
result = await em_invoker.invoke("Hi there!")
Initialization
The LangChainEMInvoker can be initialized by either passing:
- A LangChain's Embeddings instance: Usage example:
from langchain_openai import OpenAIEmbeddings
model = OpenAIEmbeddings(model="text-embedding-3-small", api_key="your_api_key")
em_invoker = LangChainEMInvoker(model=model)
- A model path in the format of "
. ": Usage example:
em_invoker = LangChainEMInvoker(
model_class_path="langchain_openai.OpenAIEmbeddings",
model_name="text-embedding-3-small",
model_kwargs={"api_key": "your_api_key"}
)
For the list of supported providers, please refer to the following table: https://docs.langchain.com/oss/python/integrations/providers/overview#featured-providers
Supported features
- Basic invocation
- Batch invocation
- Text input only
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
em |
Embeddings
|
The instance to interact with an embedding model defined using LangChain's Embeddings. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the LangChainEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Embeddings | None
|
The LangChain's Embeddings instance. If provided, will take
precedence over the |
None
|
model_class_path
|
str | None
|
The LangChain's Embeddings class path. Must be formatted as
" |
None
|
model_name
|
str | None
|
The model name. Only used if |
None
|
model_kwargs
|
dict[str, Any] | None
|
The additional keyword arguments. Only used if
|
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
OpenAIEMInvoker(model_name, api_key=None, base_url=OPENAI_DEFAULT_URL, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with OpenAI embedding models.
Examples:
em_invoker = OpenAIEMInvoker(model_name="text-embedding-3-small")
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Text input only
- Text truncation
- Vector fusion
- Retry and timeout
OpenAI compatible endpoints
This class can interact with endpoints that are compatible with OpenAI's Embeddings API schema.
This includes but are not limited to:
1. Text Embeddings Inference (https://github.com/huggingface/text-embeddings-inference)
2. vLLM (https://vllm.ai/)
To do this, simply set base_url to the endpoint URL.
Supported features may vary between endpoints.
Unsupported features will result in an error.
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
client_kwargs |
dict[str, Any]
|
The keyword arguments for the OpenAI client. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the OpenAIEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the OpenAI embedding model to be used. |
required |
api_key
|
str | None
|
The API key for authenticating with OpenAI. Defaults to None, in which
case the |
None
|
base_url
|
str
|
The base URL of a custom endpoint that is compatible with OpenAI's Embeddings API schema. Defaults to OpenAI's default URL. |
OPENAI_DEFAULT_URL
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the OpenAI client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
TwelveLabsEMInvoker(model_name, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with TwelveLabs embedding models.
Examples:
em_invoker = TwelveLabsEMInvoker(model_name="Marengo-retrieval-2.7")
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Multimodal input a. Text b. Audio c. Image d. Video
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
client |
Client
|
The client for the TwelveLabs API. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the TwelveLabsEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the TwelveLabs embedding model to be used. |
required |
api_key
|
str | None
|
The API key for the TwelveLabs API. Defaults to None, in which
case the |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the TwelveLabs client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|
VoyageEMInvoker(model_name, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, truncation_config=None, vector_fuser=None)
Bases: BaseEMInvoker
An embedding model invoker to interact with Voyage embedding models.
Examples:
em_invoker = VoyageEMInvoker(model_name="voyage-3.5-lite")
result = await em_invoker.invoke("Hi there!")
Supported features
- Basic invocation
- Batch invocation
- Multimodal input a. Text b. Image
- Text truncation
- Vector fusion
- Retry and timeout
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
The model ID of the embedding model. |
model_provider |
str
|
The provider of the embedding model. |
model_name |
str
|
The name of the embedding model. |
client |
Client
|
The client for the Voyage API. |
default_hyperparameters |
dict[str, Any]
|
Default hyperparameters for invoking the embedding model. |
retry_config |
RetryConfig
|
The retry configuration for the embedding model. |
truncation_config |
TruncationConfig | None
|
The truncation configuration for the embedding model. |
vector_fuser |
BaseVectorFuser | None
|
The vector fuser to handle mixed content. |
Initializes a new instance of the VoyageEMInvoker class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the Voyage embedding model to be used. |
required |
api_key
|
str | None
|
The API key for the Voyage API. Defaults to None, in which
case the |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional keyword arguments for the Voyage client. Defaults to None. |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default hyperparameters for invoking the model. Defaults to None. |
None
|
retry_config
|
RetryConfig | None
|
The retry configuration for the embedding model. Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used. |
None
|
truncation_config
|
TruncationConfig | None
|
Configuration for text truncation behavior. Defaults to None, in which case no truncation is applied. |
None
|
vector_fuser
|
BaseVectorFuser | VectorFuserType | None
|
The vector fuser to handle mixed content. Defaults to None, in which case handling the mixed modality content depends on the EM's capabilities. |
None
|