Skip to content

Em Invoker

Modules concerning the embedding model invokers used in Gen AI applications.

AzureOpenAIEMInvoker(azure_endpoint, azure_deployment, api_key=None, api_version=DEFAULT_AZURE_OPENAI_API_VERSION, model_kwargs=None, default_hyperparameters=None, retry_config=None)

Bases: OpenAIEMInvoker

An embedding model invoker to interact with Azure OpenAI embedding models.

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 AsyncAzureOpenAI

The client for the Azure OpenAI API.

default_hyperparameters dict[str, Any]

Default hyperparameters for invoking the embedding model.

retry_config RetryConfig

The retry configuration for the embedding model.

Input types

The AzureOpenAIEMInvoker only supports text inputs.

Output format

The AzureOpenAIEMInvoker can embed either: 1. A single content. 1. A single content is a single text. 2. The output will be a Vector, representing the embedding of the content.

# Example 1: Embedding a text content. python text = "This is a text" result = await em_invoker.invoke(text)

The above examples will return a Vector with a size of (embedding_size,).

  1. A list of contents.
  2. A list of contents is a list of texts.
  3. The output will be a list[Vector], where each element is a Vector representing the embedding of each single content.

# Example: Embedding a list of contents. python text1 = "This is a text" text2 = "This is another text" text3 = "This is yet another text" result = await em_invoker.invoke([text1, text2, text3])

The above examples will return a list[Vector] with a size of (3, embedding_size).

Retry and timeout

The AzureOpenAIEMInvoker supports retry and timeout configuration. By default, the max retries is set to 0 and the timeout is set to 30.0 seconds. They can be customized by providing a custom RetryConfig object to the retry_config parameter.

Retry config examples:

retry_config = RetryConfig(max_retries=0, timeout=0.0)  # No retry, no timeout
retry_config = RetryConfig(max_retries=0, timeout=10.0)  # No retry, 10.0 seconds timeout
retry_config = RetryConfig(max_retries=5, timeout=0.0)  # 5 max retries, no timeout
retry_config = RetryConfig(max_retries=5, timeout=10.0)  # 5 max retries, 10.0 seconds timeout

Usage example:

em_invoker = AzureOpenAIEMInvoker(..., retry_config=retry_config)

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 AZURE_OPENAI_API_KEY environment variable will be used.

None
api_version str

The API version of the Azure OpenAI service. Defaults to DEFAULT_AZURE_OPENAI_API_VERSION.

DEFAULT_AZURE_OPENAI_API_VERSION
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 is used.

None

GoogleEMInvoker(model_name, api_key=None, credentials_path=None, project_id=None, location='us-central1', model_kwargs=None, default_hyperparameters=None, retry_config=None)

Bases: BaseEMInvoker

An embedding model invoker to interact with Google embedding models.

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 | None

The retry configuration for the language model.

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="text-embedding-004",
    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="text-embedding-004",
    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.

Input types

The GoogleEMInvoker only supports text inputs.

Output format

The GoogleEMInvoker can embed either: 1. A single content. 1. A single content is a single text. 2. The output will be a Vector, representing the embedding of the content.

# Example 1: Embedding a text content. python text = "This is a text" result = await em_invoker.invoke(text)

The above examples will return a Vector with a size of (embedding_size,).

  1. A list of contents.
  2. A list of contents is a list of texts.
  3. The output will be a list[Vector], where each element is a Vector representing the embedding of each single content.

# Example: Embedding a list of contents. python text1 = "This is a text" text2 = "This is another text" text3 = "This is yet another text" result = await em_invoker.invoke([text1, text2, text3])

The above examples will return a list[Vector] with a size of (3, embedding_size).

Retry and timeout

The GoogleEMInvoker supports retry and timeout configuration. By default, the max retries is set to 0 and the timeout is set to 30.0 seconds. They can be customized by providing a custom RetryConfig object to the retry_config parameter.

Retry config examples:

retry_config = RetryConfig(max_retries=0, timeout=0.0)  # No retry, no timeout
retry_config = RetryConfig(max_retries=0, timeout=10.0)  # No retry, 10.0 seconds timeout
retry_config = RetryConfig(max_retries=5, timeout=0.0)  # 5 max retries, no timeout
retry_config = RetryConfig(max_retries=5, timeout=10.0)  # 5 max retries, 10.0 seconds timeout

Usage example:

em_invoker = GoogleEMInvoker(..., retry_config=retry_config)

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 credentials_path. Defaults to None.

None
credentials_path str | None

Required for Google Vertex AI authentication. Path to the service account credentials JSON file. Cannot be used together with api_key. Defaults to None.

None
project_id str | None

The Google Cloud project ID for Vertex AI. Only used when authenticating with credentials_path. Defaults to None, in which case it will be loaded from the credentials file.

None
location str

The location of the Google Cloud project for Vertex AI. Only used when authenticating with credentials_path. Defaults to "us-central1".

'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 is used.

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.

GoogleGenerativeAIEMInvoker(model_name, api_key, task_type=None, model_kwargs=None, retry_config=None)

Bases: GoogleEMInvoker

An embedding model invoker to interact with Google Generative AI embedding models.

This class has been deprecated as Google Generative AI is now supported through GoogleEMInvoker. This class is maintained for backward compatibility and will be removed in version 0.5.0.

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 | None

The retry configuration for the language model.

Initializes a new instance of the GoogleGenerativeAIEMInvoker class.

Parameters:

Name Type Description Default
model_name str

The name of the Google Generative AI model to be used.

required
api_key str

The API key for accessing the Google Generative AI model.

required
task_type str | None

The type of task to be performed by the embedding model. Defaults to None.

None
model_kwargs Any

Additional keyword arguments to initiate the embedding 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 is used.

None

GoogleVertexAIEMInvoker(model_name, credentials_path, project_id=None, location='us-central1', model_kwargs=None, retry_config=None)

Bases: GoogleEMInvoker

An embedding model invoker to interact with Google Vertex AI embedding models.

This class has been deprecated as Google Vertex AI is now supported through GoogleEMInvoker. This class is maintained for backward compatibility and will be removed in version 0.5.0.

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 | None

The retry configuration for the language model.

Initializes a new instance of the GoogleVertexAIEMInvoker class.

Parameters:

Name Type Description Default
model_name str

The name of the multimodal embedding model to be used.

required
credentials_path str

The path to the Google Cloud service account credentials JSON file.

required
project_id str | None

The Google Cloud project ID. Defaults to None, in which case the project ID will be loaded from the credentials file.

None
location str

The location of the Google Cloud project. Defaults to "us-central1".

'us-central1'
model_kwargs Any

Additional keyword arguments to initiate the Google Vertex AI 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 is used.

None

LangChainEMInvoker(model=None, model_class_path=None, model_name=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, em=None)

Bases: BaseEMInvoker

A language model invoker to interact with LangChain's Embeddings.

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.

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 model_class_path parameter. Defaults to None.

None
model_class_path str | None

The LangChain's Embeddings class path. Must be formatted as "." (e.g. "langchain_openai.OpenAIEmbeddings"). Ignored if model is provided. Defaults to None.

None
model_name str | None

The model name. Only used if model_class_path is provided. Defaults to None.

None
model_kwargs dict[str, Any] | None

The additional keyword arguments. Only used if model_class_path is provided. 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 is used.

None
em Embeddings | None

Deprecated parameter to pass the LangChain's Embeddings instance. Equivalent to the model parameter. Retained for backward compatibility. Defaults to None.

None

to_langchain()

Converts the current embedding model invoker to an instance of LangChain Embeddings object.

This method converts the EM invoker to an instance of LangChain's Embeddings object.

Returns:

Name Type Description
Embeddings Embeddings

An instance of LangChain Embeddings object.

OpenAICompatibleEMInvoker(model_name, base_url, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None)

Bases: OpenAIEMInvoker

An embedding model invoker to interact with endpoints compatible with OpenAI's embedding API contract.

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 AsyncOpenAI

The OpenAI client instance.

default_hyperparameters dict[str, Any]

Default hyperparameters for invoking the embedding model.

retry_config RetryConfig

The retry configuration for the embedding model.

When to use

The OpenAICompatibleEMInvoker is designed to interact with endpoints that are compatible with OpenAI's embedding API contract. This includes but are not limited to: 1. Text Embeddings Inference (https://github.com/huggingface/text-embeddings-inference) 2. vLLM (https://vllm.ai/) When using this invoker, please note that the supported features and capabilities may vary between different endpoints and language models. Using features that are not supported by the endpoint will result in an error.

Input types

The OpenAICompatibleEMInvoker only supports text inputs.

Output format

The OpenAICompatibleEMInvoker can embed either: 1. A single content. 1. A single content is a single text. 2. The output will be a Vector, representing the embedding of the content.

# Example 1: Embedding a text content. python text = "This is a text" result = await em_invoker.invoke(text)

The above examples will return a Vector with a size of (embedding_size,).

  1. A list of contents.
  2. A list of contents is a list of texts.
  3. The output will be a list[Vector], where each element is a Vector representing the embedding of each single content.

# Example: Embedding a list of contents. python text1 = "This is a text" text2 = "This is another text" text3 = "This is yet another text" result = await em_invoker.invoke([text1, text2, text3])

The above examples will return a list[Vector] with a size of (3, embedding_size).

Retry and timeout

The OpenAICompatibleEMInvoker supports retry and timeout configuration. By default, the max retries is set to 0 and the timeout is set to 30.0 seconds. They can be customized by providing a custom RetryConfig object to the retry_config parameter.

Retry config examples:

retry_config = RetryConfig(max_retries=0, timeout=0.0)  # No retry, no timeout
retry_config = RetryConfig(max_retries=0, timeout=10.0)  # No retry, 10.0 seconds timeout
retry_config = RetryConfig(max_retries=5, timeout=0.0)  # 5 max retries, no timeout
retry_config = RetryConfig(max_retries=5, timeout=10.0)  # 5 max retries, 10.0 seconds timeout

Usage example:

em_invoker = OpenAICompatibleEMInvoker(..., retry_config=retry_config)

Initializes a new instance of the OpenAICompatibleEMInvoker class.

Parameters:

Name Type Description Default
model_name str

The name of the embedding model hosted on the OpenAI compatible endpoint.

required
base_url str

The base URL for the OpenAI compatible endpoint.

required
api_key str | None

The API key for authenticating with the OpenAI compatible endpoint. Defaults to None, in which case the OPENAI_API_KEY environment variable will be used.

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 is used.

None

OpenAIEMInvoker(model_name, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None)

Bases: BaseEMInvoker

An embedding model invoker to interact with OpenAI embedding models.

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 AsyncOpenAI

The client for the OpenAI API.

default_hyperparameters dict[str, Any]

Default hyperparameters for invoking the embedding model.

retry_config RetryConfig

The retry configuration for the embedding model.

Input types

The OpenAIEMInvoker only supports text inputs.

Output format

The OpenAIEMInvoker can embed either: 1. A single content. 1. A single content is a single text. 2. The output will be a Vector, representing the embedding of the content.

# Example 1: Embedding a text content. python text = "This is a text" result = await em_invoker.invoke(text)

The above examples will return a Vector with a size of (embedding_size,).

  1. A list of contents.
  2. A list of contents is a list of texts.
  3. The output will be a list[Vector], where each element is a Vector representing the embedding of each single content.

# Example: Embedding a list of contents. python text1 = "This is a text" text2 = "This is another text" text3 = "This is yet another text" result = await em_invoker.invoke([text1, text2, text3])

The above examples will return a list[Vector] with a size of (3, embedding_size).

Retry and timeout

The OpenAIEMInvoker supports retry and timeout configuration. By default, the max retries is set to 0 and the timeout is set to 30.0 seconds. They can be customized by providing a custom RetryConfig object to the retry_config parameter.

Retry config examples:

retry_config = RetryConfig(max_retries=0, timeout=0.0)  # No retry, no timeout
retry_config = RetryConfig(max_retries=0, timeout=10.0)  # No retry, 10.0 seconds timeout
retry_config = RetryConfig(max_retries=5, timeout=0.0)  # 5 max retries, no timeout
retry_config = RetryConfig(max_retries=5, timeout=10.0)  # 5 max retries, 10.0 seconds timeout

Usage example:

em_invoker = OpenAIEMInvoker(..., retry_config=retry_config)

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 the OpenAI API. Defaults to None, in which case the OPENAI_API_KEY environment variable will be used.

None
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 is used.

None

TEIEMInvoker(url, username='', password='', api_key=None, query_prefix='', document_prefix='', retry_config=None)

Bases: BaseEMInvoker

An embedding model invoker to interact with embedding models hosted in Text Embeddings Inference (TEI).

The TEIEMInvoker class is responsible for invoking an embedding model in Text Embeddings Inference (TEI). It uses the embedding model to transform a text or a list of input text into their vector representations.

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 AsyncInferenceClient

The client instance to interact with the TEI service.

query_prefix str

The additional prefix to be added when embedding a query.

document_prefix str

The additional prefix to be added when embedding documents.

retry_config RetryConfig

The retry configuration for the embedding model.

Initializes a new instance of the TEIEMInvoker class.

Parameters:

Name Type Description Default
url str

The URL of the TEI service.

required
username str

The username for Basic Authentication. Defaults to an empty string.

''
password str

The password for Basic Authentication. Defaults to an empty string.

''
api_key str | None

The API key for the TEI service. Defaults to None.

None
query_prefix str

The additional prefix to be added when embedding a query. Defaults to an empty string.

''
document_prefix str

The additional prefix to be added when embedding documents. Defaults to an empty string.

''
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 is used.

None

to_langchain()

Converts the current embedding model invoker to an instance of LangChain TEIEmbeddings object.

Returns:

Name Type Description
TEIEmbeddings TEIEmbeddings

An instance of LangChain TEIEmbeddings object.

TwelveLabsEMInvoker(model_name, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None)

Bases: BaseEMInvoker

An embedding model invoker to interact with TwelveLabs embedding models.

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.

Input types

The TwelveLabsEMInvoker supports the following input types: 1. Text. 2. Audio: ".mp3", ".wav", and ".flac". 3. Image: ".png", ".jpeg", and ".jpg". Non-text inputs must be passed as a Attachment object.

Output format

The TwelveLabsEMInvoker can embed either: 1. A single content. 1. A single content is either a text, an audio, or an image. 2. The output will be a Vector, representing the embedding of the content.

# Example 1: Embedding a text content. python text = "What animal is in this image?" result = await em_invoker.invoke(text)

# Example 2: Embedding an audio content. python audio = Attachment.from_path("path/to/local/audio.mp3") result = await em_invoker.invoke(audio)

# Example 3: Embedding an image content. python image = Attachment.from_path("path/to/local/image.png") result = await em_invoker.invoke(image)

The above examples will return a Vector with a size of (embedding_size,).

  1. A list of contents.
  2. A list of contents is a list that consists of any of the above single contents.
  3. The output will be a list[Vector], where each element is a Vector representing the embedding of each single content.

# Example: Embedding a list of contents. python text = "What animal is in this image?" audio = Attachment.from_path("path/to/local/audio.mp3") image = Attachment.from_path("path/to/local/image.png") result = await em_invoker.invoke([text, audio, image])

The above examples will return a list[Vector] with a size of (3, embedding_size).

Retry and timeout

The TwelveLabsEMInvoker supports retry and timeout configuration. By default, the max retries is set to 0 and the timeout is set to 30.0 seconds. They can be customized by providing a custom RetryConfig object to the retry_config parameter.

Retry config examples:

retry_config = RetryConfig(max_retries=0, timeout=0.0)  # No retry, no timeout
retry_config = RetryConfig(max_retries=0, timeout=10.0)  # No retry, 10.0 seconds timeout
retry_config = RetryConfig(max_retries=5, timeout=0.0)  # 5 max retries, no timeout
retry_config = RetryConfig(max_retries=5, timeout=10.0)  # 5 max retries, 10.0 seconds timeout

Usage example:

em_invoker = TwelveLabsEMInvoker(..., retry_config=retry_config)

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 TWELVELABS_API_KEY environment variable will be used.

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 is used.

None

to_langchain()

Converts the current embedding model invoker to an instance of LangChain Embeddings object.

This method converts the EM invoker to an instance of LangChain's Embeddings object. However, the TwelveLabsEMInvoker is not supported by LangChain.

Returns:

Name Type Description
Embeddings Embeddings

An instance of LangChain Embeddings object.

Raises:

Type Description
NotImplementedError

The TwelveLabsEMInvoker is not supported by LangChain.

VoyageEMInvoker(model_name, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None)

Bases: BaseEMInvoker

An embedding model invoker to interact with Voyage embedding models.

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.

Input types

The VoyageEMInvoker supports the following input types: 1. Text. 2. Image: ".png", ".jpeg", and ".jpg". 3. A tuple containing text and image. Non-text inputs must be passed as a Attachment object.

Output format

The VoyageEMInvoker can embed either: 1. A single content. 1. A single content is either a text, an image, or a tuple containing a text and an image. 2. The output will be a Vector, representing the embedding of the content.

# Example 1: Embedding a text content. python text = "What animal is in this image?" result = await em_invoker.invoke(text)

# Example 2: Embedding an image content. python image = Attachment.from_path("path/to/local/image.png") result = await em_invoker.invoke(image)

# Example 3: Embedding a tuple containing a text and an image. python text = "What animal is in this image?" image = Attachment.from_path("path/to/local/image.png") result = await em_invoker.invoke((text, image))

The above examples will return a Vector with a size of (embedding_size,).

  1. A list of contents.
  2. A list of contents is a list that consists of any of the above single contents.
  3. The output will be a list[Vector], where each element is a Vector representing the embedding of each single content.

# Example: Embedding a list of contents. python text = "What animal is in this image?" image = Attachment.from_path("path/to/local/image.png") mix_content = (text, image) result = await em_invoker.invoke([text, image, mix_content])

The above examples will return a list[Vector] with a size of (3, embedding_size).

Retry and timeout

The VoyageEMInvoker supports retry and timeout configuration. By default, the max retries is set to 0 and the timeout is set to 30.0 seconds. They can be customized by providing a custom RetryConfig object to the retry_config parameter.

Retry config examples:

retry_config = RetryConfig(max_retries=0, timeout=0.0)  # No retry, no timeout
retry_config = RetryConfig(max_retries=0, timeout=10.0)  # No retry, 10.0 seconds timeout
retry_config = RetryConfig(max_retries=5, timeout=0.0)  # 5 max retries, no timeout
retry_config = RetryConfig(max_retries=5, timeout=10.0)  # 5 max retries, 10.0 seconds timeout

Usage example:

em_invoker = VoyageEMInvoker(..., retry_config=retry_config)

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 VOYAGE_API_KEY environment variable will be used.

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 is used.

None