langchain.embeddings.embaas.EmbaasEmbeddings¶
- class langchain.embeddings.embaas.EmbaasEmbeddings(*, model: str = 'e5-large-v2', instruction: Optional[str] = None, api_url: str = 'https://api.embaas.io/v1/embeddings/', embaas_api_key: Optional[str] = None)[source]¶
Bases:
BaseModel,EmbeddingsEmbaas’s embedding service.
To use, you should have the environment variable
EMBAAS_API_KEYset with your API key, or pass it as a named parameter to the constructor.Example
# Initialise with default model and instruction from langchain.embeddings import EmbaasEmbeddings emb = EmbaasEmbeddings() # Initialise with custom model and instruction from langchain.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 if the input data cannot be parsed to form a valid model.
- param api_url: str = 'https://api.embaas.io/v1/embeddings/'¶
The URL for the embaas embeddings API.
- param embaas_api_key: Optional[str] = None¶
- param instruction: Optional[str] = None¶
Instruction used for domain-specific embeddings.
- param model: str = 'e5-large-v2'¶
The model used for embeddings.
- embed_documents(texts: List[str]) List[List[float]][source]¶
Get embeddings for a list of texts.
- Parameters
texts – The list of texts to get embeddings for.
- Returns
List of embeddings, one for each text.
- embed_query(text: str) List[float][source]¶
Get embeddings for a single text.
- Parameters
text – The text to get embeddings for.
- Returns
List of embeddings.