mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-01 00:49:25 +00:00
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:
parent
4457e64e13
commit
d084172b63
@ -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
|
||||
|
@ -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"]
|
||||
|
@ -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:
|
||||
|
@ -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."""
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user