LLMRailsEmbeddings#

class langchain_community.embeddings.llm_rails.LLMRailsEmbeddings[source]#

Bases: BaseModel, Embeddings

LLMRails embedding models.

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

Model can be one of [“embedding-english-v1”,”embedding-multi-v1”]

Example

from langchain_community.embeddings import LLMRailsEmbeddings
cohere = LLMRailsEmbeddings(
    model="embedding-english-v1", 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 api_key: SecretStr | None = None#

LLMRails API key.

Constraints:
  • type = string

  • writeOnly = True

  • format = password

param model: str = 'embedding-english-v1'#

Model name 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 Cohere’s embedding endpoint.

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 Cohere’s embedding endpoint.

Parameters:

text (str) – The text to embed.

Returns:

Embeddings for the text.

Return type:

List[float]

Examples using LLMRailsEmbeddings