EmbaasEmbeddings#

class langchain_community.embeddings.embaas.EmbaasEmbeddings[source]#

Bases: BaseModel, Embeddings

Embaas’s embedding service.

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

Example

# initialize with default model and instruction
from langchain_community.embeddings import EmbaasEmbeddings
emb = EmbaasEmbeddings()

# initialize with custom model and instruction
from langchain_community.embeddings import EmbaasEmbeddings
emb_model = "instructor-large"
emb_inst = "Represent the Wikipedia document for retrieval"
emb = EmbaasEmbeddings(
    model=emb_model,
    instruction=emb_inst
)

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_url: str = 'https://api.embaas.io/v1/embeddings/'#

The URL for the embaas embeddings API.

param embaas_api_key: SecretStr | None = None#

max number of retries for requests

param instruction: str | None = None#

Instruction used for domain-specific embeddings.

param max_retries: int | None = 3#

request timeout in seconds

param model: str = 'e5-large-v2'#

The model used for embeddings.

param timeout: int | None = 30#
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]#

Get embeddings for a list of texts.

Parameters:

texts (List[str]) – The list of texts to get embeddings for.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

embed_query(text: str) → List[float][source]#

Get embeddings for a single text.

Parameters:

text (str) – The text to get embeddings for.

Returns:

List of embeddings.

Return type:

List[float]

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

Validate that api key and python package exists in environment.

Parameters:

values (Dict)

Return type:

Dict

Examples using EmbaasEmbeddings