langchain.embeddings.cohere.CohereEmbeddings¶
class langchain.embeddings.cohere.CohereEmbeddings[source]¶
Bases: BaseModel, Embeddings
Cohere embedding models.
To use, you should have the cohere python package installed, and the
environment variable COHERE_API_KEY set with your API key or pass it
as a named parameter to the constructor.
Example
from langchain.embeddings import CohereEmbeddings
cohere = CohereEmbeddings(
    model="embed-english-light-v2.0", cohere_api_key="my-api-key"
)
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 async_client: Any = None¶
Cohere async client.
param client: Any = None¶
Cohere client.
param cohere_api_key: Optional[str] = None¶
param model: str = 'embed-english-v2.0'¶
Model name to use.
param truncate: Optional[str] = None¶
Truncate embeddings that are too long from start or end (“NONE”|”START”|”END”)
async aembed_documents(texts: List[str]) → List[List[float]][source]¶
Async call out to Cohere’s embedding endpoint.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
async aembed_query(text: str) → List[float][source]¶
Async call out to Cohere’s embedding endpoint.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶