Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

YandexGPT

This notebook goes over how to use Langchain withYandexGPT embeddings models.

To use, you should have theyandexcloud python package installed.

%pip install--upgrade--quiet  yandexcloud

First, you shouldcreate service account with theai.languageModels.user role.

Next, you have two authentication options:

  • IAM token.You can specify the token in a constructor parameteriam_token or in an environment variableYC_IAM_TOKEN.
  • API keyYou can specify the key in a constructor parameterapi_key or in an environment variableYC_API_KEY.

To specify the model you can usemodel_uri parameter, seethe documentation for more details.

By default, the latest version oftext-search-query is used from the folder specified in the parameterfolder_id orYC_FOLDER_ID environment variable.

from langchain_community.embeddings.yandeximport YandexGPTEmbeddings
API Reference:YandexGPTEmbeddings
embeddings= YandexGPTEmbeddings()
text="This is a test document."
query_result= embeddings.embed_query(text)
doc_result= embeddings.embed_documents([text])
query_result[:5]
[-0.021392822265625,
0.096435546875,
-0.046966552734375,
-0.0183258056640625,
-0.00555419921875]
doc_result[0][:5]
[-0.021392822265625,
0.096435546875,
-0.046966552734375,
-0.0183258056640625,
-0.00555419921875]

Related


[8]ページ先頭

©2009-2025 Movatter.jp