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][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 api_key: SecretStr | None = None#

LLMRails API key.

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]

classmethod validate_environment(values: Dict) Dict[source]#

Validate that api key exists in environment.

Parameters:

values (Dict)

Return type:

Dict

Examples using LLMRailsEmbeddings