Skip to main content

GigaChat

本笔记展示了如何使用LangChain与GigaChat嵌入。 要使用它,您需要安装gigachat Python包。

%pip install --upgrade --quiet  gigachat

要获取GigaChat凭证,您需要创建账户获取API访问权限

示例

import os
from getpass import getpass

if "GIGACHAT_CREDENTIALS" not in os.environ:
os.environ["GIGACHAT_CREDENTIALS"] = getpass()
<!--IMPORTS:[{"imported": "GigaChatEmbeddings", "source": "langchain_community.embeddings", "docs": "https://python.langchain.com/api_reference/community/embeddings/langchain_community.embeddings.gigachat.GigaChatEmbeddings.html", "title": "GigaChat"}]-->
from langchain_community.embeddings import GigaChatEmbeddings

embeddings = GigaChatEmbeddings(verify_ssl_certs=False, scope="GIGACHAT_API_PERS")
query_result = embeddings.embed_query("The quick brown fox jumps over the lazy dog")
query_result[:5]
[0.8398333191871643,
-0.14180311560630798,
-0.6161925792694092,
-0.17103666067123413,
1.2884578704833984]

相关


Was this page helpful?


You can also leave detailed feedback on GitHub.

扫我,入群扫我,找书