mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-01 17:13:22 +00:00
community[patch]: Fix missing protected_namespaces(). (#27610)
- [x] **PR message**: - **Description:** Fixes warning messages raised due to missing `protected_namespaces` parameter in `ConfigDict`. - **Issue:** https://github.com/langchain-ai/langchain/issues/27609 - **Dependencies:** No dependencies - **Twitter handle:** @gawbul
This commit is contained in:
parent
7667ee126f
commit
24605bcdb6
@ -2,7 +2,7 @@ import os
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from pydantic import BaseModel, model_validator
|
||||
from pydantic import BaseModel, ConfigDict, model_validator
|
||||
|
||||
|
||||
class AscendEmbeddings(Embeddings, BaseModel):
|
||||
@ -33,6 +33,8 @@ class AscendEmbeddings(Embeddings, BaseModel):
|
||||
model: Any
|
||||
tokenizer: Any
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
try:
|
||||
|
@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env, pre_init
|
||||
from pydantic import BaseModel, Field, SecretStr
|
||||
from pydantic import BaseModel, ConfigDict, Field, SecretStr
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -81,6 +81,8 @@ class QianfanEmbeddingsEndpoint(BaseModel, Embeddings):
|
||||
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
|
||||
"""extra params for model invoke using with `do`."""
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@pre_init
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
"""
|
||||
|
@ -5,7 +5,7 @@ from typing import Any, List
|
||||
|
||||
import requests
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
API_URL = "https://api.bookend.ai/"
|
||||
DEFAULT_TASK = "embeddings"
|
||||
@ -42,6 +42,8 @@ class BookendEmbeddings(BaseModel, Embeddings):
|
||||
"""Embeddings model ID to use."""
|
||||
auth_header: dict = Field(default_factory=dict)
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
def __init__(self, **kwargs: Any):
|
||||
super().__init__(**kwargs)
|
||||
self.auth_header = {"Authorization": "Basic {}".format(self.api_token)}
|
||||
|
@ -8,7 +8,7 @@ from langchain_core._api.deprecation import deprecated
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.runnables.config import run_in_executor
|
||||
from langchain_core.utils import get_from_dict_or_env, pre_init
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -31,6 +31,8 @@ class ErnieEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
_lock = threading.Lock()
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@pre_init
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
values["ernie_api_base"] = get_from_dict_or_env(
|
||||
|
@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.utils import get_from_dict_or_env, pre_init
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from tenacity import (
|
||||
before_sleep_log,
|
||||
retry,
|
||||
@ -62,6 +62,8 @@ class GooglePalmEmbeddings(BaseModel, Embeddings):
|
||||
show_progress_bar: bool = False
|
||||
"""Whether to show a tqdm progress bar. Must have `tqdm` installed."""
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@pre_init
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
"""Validate api key, python package exists."""
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from pydantic import BaseModel, model_validator
|
||||
from pydantic import BaseModel, ConfigDict, model_validator
|
||||
|
||||
|
||||
class GPT4AllEmbeddings(BaseModel, Embeddings):
|
||||
@ -28,6 +28,8 @@ class GPT4AllEmbeddings(BaseModel, Embeddings):
|
||||
gpt4all_kwargs: Optional[dict] = {}
|
||||
client: Any #: :meta private:
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_environment(cls, values: Dict) -> Any:
|
||||
|
@ -60,6 +60,7 @@ class InfinityEmbeddingsLocal(BaseModel, Embeddings):
|
||||
# LLM call kwargs
|
||||
model_config = ConfigDict(
|
||||
extra="forbid",
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
@ -120,6 +120,7 @@ class QuantizedBgeEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
model_config = ConfigDict(
|
||||
extra="allow",
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
def _embed(self, inputs: Any) -> Any:
|
||||
|
@ -6,7 +6,7 @@ from urllib.parse import urlparse
|
||||
import requests
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env
|
||||
from pydantic import BaseModel, SecretStr, model_validator
|
||||
from pydantic import BaseModel, ConfigDict, SecretStr, model_validator
|
||||
|
||||
JINA_API_URL: str = "https://api.jina.ai/v1/embeddings"
|
||||
|
||||
@ -46,6 +46,8 @@ class JinaEmbeddings(BaseModel, Embeddings):
|
||||
model_name: str = "jina-embeddings-v2-base-en"
|
||||
jina_api_key: Optional[SecretStr] = None
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_environment(cls, values: Dict) -> Any:
|
||||
|
@ -63,6 +63,7 @@ class LlamaCppEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
model_config = ConfigDict(
|
||||
extra="forbid",
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
@ -2,7 +2,7 @@ from typing import Any, Dict, List
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.utils import get_from_dict_or_env, pre_init
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class NLPCloudEmbeddings(BaseModel, Embeddings):
|
||||
@ -22,6 +22,8 @@ class NLPCloudEmbeddings(BaseModel, Embeddings):
|
||||
gpu: bool # Define gpu as a class attribute
|
||||
client: Any #: :meta private:
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
model_name: str = "paraphrase-multilingual-mpnet-base-v2",
|
||||
|
@ -102,6 +102,7 @@ For more information, please visit:
|
||||
|
||||
model_config = ConfigDict(
|
||||
extra="allow",
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
def _embed(self, inputs: Any) -> Any:
|
||||
|
@ -4,7 +4,7 @@ from typing import Dict, Generator, List, Optional
|
||||
import requests
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.utils import get_from_dict_or_env, pre_init
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class SambaStudioEmbeddings(BaseModel, Embeddings):
|
||||
@ -64,6 +64,8 @@ class SambaStudioEmbeddings(BaseModel, Embeddings):
|
||||
batch_size: int = 32
|
||||
"""Batch size for the embedding models"""
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@pre_init
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
"""Validate that api key and python package exists in environment."""
|
||||
|
@ -45,6 +45,7 @@ class TensorflowHubEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
model_config = ConfigDict(
|
||||
extra="forbid",
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||
|
@ -3,7 +3,7 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class Text2vecEmbeddings(Embeddings, BaseModel):
|
||||
@ -33,6 +33,8 @@ class Text2vecEmbeddings(Embeddings, BaseModel):
|
||||
device: Optional[str] = None
|
||||
model: Any = None
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
Loading…
Reference in New Issue
Block a user