The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: YandexGPT API add ability to disable request logging (#20670)
Dmitry Tyumentsevf111efeb6ef7
diff --git a/libs/community/langchain_community/embeddings/yandex.py b/libs/community/langchain_community/embeddings/yandex.pyindex c129c8169e..603ca91943 100644--- a/libs/community/langchain_community/embeddings/yandex.py+++ b/libs/community/langchain_community/embeddings/yandex.py@@ -3,7 +3,7 @@ from __future__ import annotationsimport loggingimport time-from typing import Any, Callable, Dict, List+from typing import Any, Callable, Dict, List, Sequencefrom langchain_core.embeddings import Embeddingsfrom langchain_core.pydantic_v1 import BaseModel, Field, SecretStr, root_validator@@ -65,6 +65,10 @@ class YandexGPTEmbeddings(BaseModel, Embeddings):"""Maximum number of retries to make when generating."""sleep_interval: float = 0.0"""Delay between API requests"""+ disable_request_logging: bool = False+ """YandexGPT API logs all request data by default.+ If you provide personal data, confidential information, disable logging."""+ _grpc_metadata: Sequenceclass Config:"""Configuration for this pydantic object."""@@ -110,6 +114,13 @@ class YandexGPTEmbeddings(BaseModel, Embeddings):values["model_uri"] = f"emb://{values['folder_id']}/{values['model_name']}/{values['model_version']}" # noqa: E501+ if values["disable_request_logging"]:+ values["_grpc_metadata"].append(+ (+ "x-data-logging-enabled",+ "false",+ )+ )return valuesdef embed_documents(self, texts: List[str]) -> List[List[float]]:diff --git a/libs/community/langchain_community/llms/yandex.py b/libs/community/langchain_community/llms/yandex.pyindex da529a204c..8b94463af6 100644--- a/libs/community/langchain_community/llms/yandex.py+++ b/libs/community/langchain_community/llms/yandex.py@@ -54,6 +54,9 @@ class _BaseYandexGPT(Serializable):"""Maximum number of retries to make when generating."""sleep_interval: float = 1.0"""Delay between API requests"""+ disable_request_logging: bool = False+ """YandexGPT API logs all request data by default.+ If you provide personal data, confidential information, disable logging."""_grpc_metadata: Sequence@property@@ -104,6 +107,13 @@ class _BaseYandexGPT(Serializable):values["model_uri"] = f"gpt://{values['folder_id']}/{values['model_name']}/{values['model_version']}"+ if values["disable_request_logging"]:+ values["_grpc_metadata"].append(+ (+ "x-data-logging-enabled",+ "false",+ )+ )return values