UpstageEmbeddings#
- class langchain_upstage.embeddings.UpstageEmbeddings[source]#
Bases:
BaseModel
,Embeddings
UpstageEmbeddings embedding model.
To use, set the environment variable UPSTAGE_API_KEY with your API key or pass it as a named parameter to the constructor.
Example
from langchain_upstage import UpstageEmbeddings model = UpstageEmbeddings(model='solar-embedding-1-large')
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 allowed_special: Literal['all'] | Set[str] = {}#
Not yet supported.
- param chunk_size: int = 1000#
Maximum number of texts to embed in each batch.
Not yet supported.
- param default_headers: Mapping[str, str] | None = None#
- param default_query: Mapping[str, object] | None = None#
- param dimensions: int | None = None#
The number of dimensions the resulting output embeddings should have.
Not yet supported.
- param disallowed_special: Literal['all'] | Set[str] | Sequence[str] = 'all'#
Not yet supported.
- param embed_batch_size: int = 10#
- param embedding_ctx_length: int = 4096#
The maximum number of tokens to embed at once.
Not yet supported.
- param http_async_client: Any | None = None#
Optional httpx.AsyncClient. Only used for async invocations. Must specify http_client as well if youβd like a custom client for sync invocations.
- param http_client: Any | None = None#
Optional httpx.Client. Only used for sync invocations. Must specify http_async_client as well if youβd like a custom client for async invocations.
- param max_retries: int = 2#
Maximum number of retries to make when generating.
- param model: str [Required]#
Embeddings model name to use. Do not add suffixes like -query and -passage. Instead, use βsolar-embedding-1-largeβ for example.
- param model_kwargs: Dict[str, Any] [Optional]#
Holds any model parameters valid for create call not explicitly specified.
- param request_timeout: float | Tuple[float, float] | Any | None = None (alias 'timeout')#
Timeout for requests to Upstage embedding API. Can be float, httpx.Timeout or None.
- param show_progress_bar: bool = False#
Whether to show a progress bar when embedding.
Not yet supported.
- param skip_empty: bool = False#
Whether to skip empty strings when embedding or raise an error. Defaults to not skipping.
Not yet supported.
- param upstage_api_base: str | None [Optional] (alias 'base_url')#
Endpoint URL to use.
- param upstage_api_key: SecretStr [Optional] (alias 'api_key')#
Automatically inferred from env are UPSTAGE_API_KEY if not provided.
- async aembed_documents(texts: List[str]) List[List[float]] [source]#
Embed a list of document texts using passage model asynchronously.
- Parameters:
texts (List[str]) β The list of texts to embed.
- Returns:
List of embeddings, one for each text.
- Return type:
List[List[float]]
- async aembed_query(text: str) List[float] [source]#
Asynchronous Embed query text using query model.
- Parameters:
text (str) β The text to embed.
- Returns:
Embedding for the text.
- Return type:
List[float]