mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 07:09:31 +00:00
docs: Standardize ZhipuAIEmbeddings docstrings (#24933)
- **Description:** Standardize ZhipuAIEmbeddings rich docstrings. - **Issue:** the issue #24856
This commit is contained in:
parent
02db66d764
commit
ea505985c4
@ -6,25 +6,64 @@ from langchain_core.utils import get_from_dict_or_env
|
|||||||
|
|
||||||
|
|
||||||
class ZhipuAIEmbeddings(BaseModel, Embeddings):
|
class ZhipuAIEmbeddings(BaseModel, Embeddings):
|
||||||
"""ZhipuAI embedding models.
|
"""ZhipuAI embedding model integration.
|
||||||
|
|
||||||
To use, you should have the ``zhipuai`` python package installed, and the
|
Setup:
|
||||||
environment variable ``ZHIPU_API_KEY`` set with your API key or pass it
|
|
||||||
as a named parameter to the constructor.
|
|
||||||
|
|
||||||
More instructions about ZhipuAi Embeddings, you can get it
|
To use, you should have the ``zhipuai`` python package installed, and the
|
||||||
from https://open.bigmodel.cn/dev/api#vector
|
environment variable ``ZHIPU_API_KEY`` set with your API KEY.
|
||||||
|
|
||||||
|
More instructions about ZhipuAi Embeddings, you can get it
|
||||||
|
from https://open.bigmodel.cn/dev/api#vector
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip install -U zhipuai
|
||||||
|
export ZHIPU_API_KEY="your-api-key"
|
||||||
|
|
||||||
|
Key init args — completion params:
|
||||||
|
model: Optional[str]
|
||||||
|
Name of ZhipuAI model to use.
|
||||||
|
api_key: str
|
||||||
|
Automatically inferred from env var `ZHIPU_API_KEY` if not provided.
|
||||||
|
|
||||||
|
See full list of supported init args and their descriptions in the params section.
|
||||||
|
|
||||||
|
Instantiate:
|
||||||
|
|
||||||
Example:
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain_community.embeddings import ZhipuAIEmbeddings
|
from langchain_community.embeddings import ZhipuAIEmbeddings
|
||||||
embeddings = ZhipuAIEmbeddings(api_key="your-api-key")
|
|
||||||
text = "This is a test query."
|
embed = ZhipuAIEmbeddings(
|
||||||
query_result = embeddings.embed_query(text)
|
model="embedding-2",
|
||||||
# texts = ["This is a test query1.", "This is a test query2."]
|
# api_key="...",
|
||||||
# query_result = embeddings.embed_query(texts)
|
)
|
||||||
"""
|
|
||||||
|
Embed single text:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
input_text = "The meaning of life is 42"
|
||||||
|
embed.embed_query(input_text)
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
[-0.003832892, 0.049372625, -0.035413884, -0.019301128, 0.0068899863, 0.01248398, -0.022153955, 0.006623926, 0.00778216, 0.009558191, ...]
|
||||||
|
|
||||||
|
|
||||||
|
Embed multiple text:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
input_texts = ["This is a test query1.", "This is a test query2."]
|
||||||
|
embed.embed_documents(input_texts)
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
[
|
||||||
|
[0.0083934665, 0.037985895, -0.06684559, -0.039616987, 0.015481004, -0.023952313, ...],
|
||||||
|
[-0.02713102, -0.005470169, 0.032321047, 0.042484466, 0.023290444, 0.02170547, ...]
|
||||||
|
]
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
client: Any = Field(default=None, exclude=True) #: :meta private:
|
client: Any = Field(default=None, exclude=True) #: :meta private:
|
||||||
model: str = Field(default="embedding-2")
|
model: str = Field(default="embedding-2")
|
||||||
|
Loading…
Reference in New Issue
Block a user