community[patch]: root validator set explicit pre=False or pre=True (#23764)

See issue: https://github.com/langchain-ai/langchain/issues/22819
This commit is contained in:
Eugene Yurtsev 2024-07-02 09:42:05 -04:00 committed by GitHub
parent 4457e64e13
commit d084172b63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 7 deletions

View File

@ -19,7 +19,7 @@ class ApifyWrapper(BaseModel):
apify_client_async: Any
apify_api_token: Optional[str] = None
@root_validator()
@root_validator(pre=True)
def validate_environment(cls, values: Dict) -> Dict:
"""Validate environment.
Validate that an Apify API token is set and the apify-client

View File

@ -51,7 +51,7 @@ class DALMFilter(BaseModel):
value: str
_is_metadata: bool = False
@root_validator()
@root_validator(pre=True)
def set_meta(cls, values: Dict) -> Dict:
"""document and name are reserved arcee keys. Anything else is metadata"""
values["_is_meta"] = values.get("field_name") not in ["document", "name"]

View File

@ -72,7 +72,7 @@ class ArxivAPIWrapper(BaseModel):
return False
return True
@root_validator()
@root_validator(pre=True)
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that the python package exists in environment."""
try:

View File

@ -24,7 +24,7 @@ class AskNewsAPIWrapper(BaseModel):
extra = Extra.forbid
@root_validator()
@root_validator(pre=True)
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api credentials and python package exists in environment."""

View File

@ -34,7 +34,7 @@ class LambdaWrapper(BaseModel):
extra = Extra.forbid
@root_validator()
@root_validator(pre=True)
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that python package exists in environment."""
@ -47,8 +47,6 @@ class LambdaWrapper(BaseModel):
)
values["lambda_client"] = boto3.client("lambda")
values["function_name"] = values["function_name"]
return values
def run(self, query: str) -> str: