VoyageEmbeddings#

class langchain_community.embeddings.voyageai.VoyageEmbeddings[source]#

Bases: BaseModel, Embeddings

Deprecated since version 0.0.29: Use :class:`~langchain_voyageai.VoyageAIEmbeddings` instead.

Voyage embedding models.

To use, you should have the environment variable VOYAGE_API_KEY set with your API key or pass it as a named parameter to the constructor.

Example

from langchain_community.embeddings import VoyageEmbeddings

voyage = VoyageEmbeddings(voyage_api_key="your-api-key", model="voyage-2")
text = "This is a test query."
query_result = voyage.embed_query(text)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param batch_size: int [Required]#

Maximum number of texts to embed in each API request.

param max_retries: int = 6#

Maximum number of retries to make when generating.

param model: str [Required]#
param request_timeout: float | Tuple[float, float] | None = None#

Timeout in seconds for the API request.

param show_progress_bar: bool = False#

Whether to show a progress bar when embedding. Must have tqdm installed if set to True.

param truncation: bool = True#

Whether to truncate the input texts to fit within the context length.

If True, over-length input texts will be truncated to fit within the context length, before vectorized by the embedding model. If False, an error will be raised if any given text exceeds the context length.

param voyage_api_base: str = 'https://api.voyageai.com/v1/embeddings'#
param voyage_api_key: SecretStr | None = None#
async aembed_documents(texts: list[str]) list[list[float]]#

Asynchronous Embed search docs.

Parameters:

texts (list[str]) – List of text to embed.

Returns:

List of embeddings.

Return type:

list[list[float]]

async aembed_query(text: str) list[float]#

Asynchronous Embed query text.

Parameters:

text (str) – Text to embed.

Returns:

Embedding.

Return type:

list[float]

embed_documents(texts: List[str]) List[List[float]][source]#

Call out to Voyage Embedding endpoint for embedding search docs.

Parameters:

texts (List[str]) – The list of texts to embed.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

embed_general_texts(texts: List[str], *, input_type: str | None = None) List[List[float]][source]#

Call out to Voyage Embedding endpoint for embedding general text.

Parameters:
  • texts (List[str]) – The list of texts to embed.

  • input_type (str | None) – Type of the input text. Default to None, meaning the type is unspecified. Other options: query, document.

Returns:

Embedding for the text.

Return type:

List[List[float]]

embed_query(text: str) List[float][source]#

Call out to Voyage Embedding endpoint for embedding query text.

Parameters:

text (str) – The text to embed.

Returns:

Embedding for the text.

Return type:

List[float]