mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 17:08:47 +00:00
community[patch]: YandexGPT API add ability to disable request logging (#20670)
Closes (#20622) Added the ability to [disable logging of requests to YandexGPT](https://yandex.cloud/en/docs/foundation-models/operations/yandexgpt/disable-logging).
This commit is contained in:
parent
e5f5d9ff56
commit
f111efeb6e
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import time
|
||||
from typing import Any, Callable, Dict, List
|
||||
from typing import Any, Callable, Dict, List, Sequence
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from 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: Sequence
|
||||
|
||||
class 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 values
|
||||
|
||||
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user