ClarifaiEmbeddings#

class langchain_community.embeddings.clarifai.ClarifaiEmbeddings[source]#

Bases: BaseModel, Embeddings

Clarifai embedding models.

To use, you should have the clarifai python package installed, and the environment variable CLARIFAI_PAT set with your personal access token or pass it as a named parameter to the constructor.

Example

from langchain_community.embeddings import ClarifaiEmbeddings
clarifai = ClarifaiEmbeddings(user_id=USER_ID,
                              app_id=APP_ID,
                              model_id=MODEL_ID)
                 (or)
Example_URL = "https://clarifai.com/clarifai/main/models/BAAI-bge-base-en-v15"
clarifai = ClarifaiEmbeddings(model_url=EXAMPLE_URL)

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 api_base: str = 'https://api.clarifai.com'#
param app_id: str | None = None#

Clarifai application id to use.

param model_id: str | None = None#

Model id to use.

param model_url: str | None = None#

Model url to use.

param model_version_id: str | None = None#

Model version id to use.

param pat: str | None = None#

Clarifai personal access token to use.

param token: str | None = None#

Clarifai session token to use.

param user_id: str | None = None#

Clarifai user id to use.

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 Clarifai’s embedding models.

Parameters:

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

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

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

Call out to Clarifai’s embedding models.

Parameters:

text (str) – The text to embed.

Returns:

Embeddings for the text.

Return type:

List[float]

Examples using ClarifaiEmbeddings