DashScopeEmbeddings#
- class langchain_community.embeddings.dashscope.DashScopeEmbeddings[source]#
Bases:
BaseModel
,Embeddings
DashScope embedding models.
To use, you should have the
dashscope
python package installed, and the environment variableDASHSCOPE_API_KEY
set with your API key or pass it as a named parameter to the constructor.Example
from langchain_community.embeddings import DashScopeEmbeddings embeddings = DashScopeEmbeddings(dashscope_api_key="my-api-key")
Example
import os os.environ["DASHSCOPE_API_KEY"] = "your DashScope API KEY" from langchain_community.embeddings.dashscope import DashScopeEmbeddings embeddings = DashScopeEmbeddings( model="text-embedding-v1", ) text = "This is a test query." query_result = embeddings.embed_query(text)
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 client: Any = None#
The DashScope client.
- param dashscope_api_key: str | None = None#
- param max_retries: int = 5#
Maximum number of retries to make when generating.
- param model: str = 'text-embedding-v1'#
- 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]
Examples using DashScopeEmbeddings