mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-26 22:05:29 +00:00
community[patch]: Add protected_namespace=() to models that use model namespace (#26284)
Add protected_namespaces=() for existing implementations that use the pydantic reserved model namespace.
This commit is contained in:
@@ -45,9 +45,7 @@ class HuggingFaceCrossEncoder(BaseModel, BaseCrossEncoder):
|
|||||||
self.model_name, **self.model_kwargs
|
self.model_name, **self.model_kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(extra="forbid", protected_namespaces=())
|
||||||
extra="forbid",
|
|
||||||
)
|
|
||||||
|
|
||||||
def score(self, text_pairs: List[Tuple[str, str]]) -> List[float]:
|
def score(self, text_pairs: List[Tuple[str, str]]) -> List[float]:
|
||||||
"""Compute similarity scores using a HuggingFace transformer model.
|
"""Compute similarity scores using a HuggingFace transformer model.
|
||||||
|
@@ -90,8 +90,7 @@ class SagemakerEndpointCrossEncoder(BaseModel, BaseCrossEncoder):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
arbitrary_types_allowed=True,
|
arbitrary_types_allowed=True, extra="forbid", protected_namespaces=()
|
||||||
extra="forbid",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
|
@@ -76,6 +76,7 @@ class LLMLinguaCompressor(BaseDocumentCompressor):
|
|||||||
arbitrary_types_allowed=True,
|
arbitrary_types_allowed=True,
|
||||||
extra="forbid",
|
extra="forbid",
|
||||||
populate_by_name=True,
|
populate_by_name=True,
|
||||||
|
protected_namespaces=(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@@ -50,9 +50,7 @@ class MoonshotCommon(BaseModel):
|
|||||||
temperature: float = 0.3
|
temperature: float = 0.3
|
||||||
"""Temperature parameter (higher values make the model more creative)."""
|
"""Temperature parameter (higher values make the model more creative)."""
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(populate_by_name=True, protected_namespaces=())
|
||||||
populate_by_name=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lc_secrets(self) -> dict:
|
def lc_secrets(self) -> dict:
|
||||||
|
@@ -101,8 +101,7 @@ class OCIGenAIBase(BaseModel, ABC):
|
|||||||
"""Whether to stream back partial progress"""
|
"""Whether to stream back partial progress"""
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
extra="forbid",
|
extra="forbid", arbitrary_types_allowed=True, protected_namespaces=()
|
||||||
arbitrary_types_allowed=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@pre_init
|
@pre_init
|
||||||
|
@@ -53,6 +53,7 @@ class SolarCommon(BaseModel):
|
|||||||
populate_by_name=True,
|
populate_by_name=True,
|
||||||
arbitrary_types_allowed=True,
|
arbitrary_types_allowed=True,
|
||||||
extra="ignore",
|
extra="ignore",
|
||||||
|
protected_namespaces=(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@@ -73,9 +73,7 @@ class DallEAPIWrapper(BaseModel):
|
|||||||
http_client: Union[Any, None] = None
|
http_client: Union[Any, None] = None
|
||||||
"""Optional httpx.Client."""
|
"""Optional httpx.Client."""
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(extra="forbid", protected_namespaces=())
|
||||||
extra="forbid",
|
|
||||||
)
|
|
||||||
|
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Reference in New Issue
Block a user