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:
Eugene Yurtsev
2024-09-10 17:32:10 -04:00
committed by GitHub
parent fc08f240ee
commit 287911adbc
7 changed files with 7 additions and 13 deletions

View File

@@ -45,9 +45,7 @@ class HuggingFaceCrossEncoder(BaseModel, BaseCrossEncoder):
self.model_name, **self.model_kwargs
)
model_config = ConfigDict(
extra="forbid",
)
model_config = ConfigDict(extra="forbid", protected_namespaces=())
def score(self, text_pairs: List[Tuple[str, str]]) -> List[float]:
"""Compute similarity scores using a HuggingFace transformer model.

View File

@@ -90,8 +90,7 @@ class SagemakerEndpointCrossEncoder(BaseModel, BaseCrossEncoder):
"""
model_config = ConfigDict(
arbitrary_types_allowed=True,
extra="forbid",
arbitrary_types_allowed=True, extra="forbid", protected_namespaces=()
)
@model_validator(mode="before")

View File

@@ -76,6 +76,7 @@ class LLMLinguaCompressor(BaseDocumentCompressor):
arbitrary_types_allowed=True,
extra="forbid",
populate_by_name=True,
protected_namespaces=(),
)
@staticmethod

View File

@@ -50,9 +50,7 @@ class MoonshotCommon(BaseModel):
temperature: float = 0.3
"""Temperature parameter (higher values make the model more creative)."""
model_config = ConfigDict(
populate_by_name=True,
)
model_config = ConfigDict(populate_by_name=True, protected_namespaces=())
@property
def lc_secrets(self) -> dict:

View File

@@ -101,8 +101,7 @@ class OCIGenAIBase(BaseModel, ABC):
"""Whether to stream back partial progress"""
model_config = ConfigDict(
extra="forbid",
arbitrary_types_allowed=True,
extra="forbid", arbitrary_types_allowed=True, protected_namespaces=()
)
@pre_init

View File

@@ -53,6 +53,7 @@ class SolarCommon(BaseModel):
populate_by_name=True,
arbitrary_types_allowed=True,
extra="ignore",
protected_namespaces=(),
)
@property

View File

@@ -73,9 +73,7 @@ class DallEAPIWrapper(BaseModel):
http_client: Union[Any, None] = None
"""Optional httpx.Client."""
model_config = ConfigDict(
extra="forbid",
)
model_config = ConfigDict(extra="forbid", protected_namespaces=())
@model_validator(mode="before")
@classmethod