VoyageEmbeddings#
- class langchain_community.embeddings.voyageai.VoyageEmbeddings[source]#
Bases:
BaseModel
,Embeddings
Deprecated since version 0.0.29: Use
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 if the input data cannot be parsed to form a valid model.
- 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#
- Constraints:
type = string
writeOnly = True
format = password
- 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]]