mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 04:50:37 +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_client_async: Any
|
||||||
apify_api_token: Optional[str] = None
|
apify_api_token: Optional[str] = None
|
||||||
|
|
||||||
@root_validator()
|
@root_validator(pre=True)
|
||||||
def validate_environment(cls, values: Dict) -> Dict:
|
def validate_environment(cls, values: Dict) -> Dict:
|
||||||
"""Validate environment.
|
"""Validate environment.
|
||||||
Validate that an Apify API token is set and the apify-client
|
Validate that an Apify API token is set and the apify-client
|
||||||
|
@ -51,7 +51,7 @@ class DALMFilter(BaseModel):
|
|||||||
value: str
|
value: str
|
||||||
_is_metadata: bool = False
|
_is_metadata: bool = False
|
||||||
|
|
||||||
@root_validator()
|
@root_validator(pre=True)
|
||||||
def set_meta(cls, values: Dict) -> Dict:
|
def set_meta(cls, values: Dict) -> Dict:
|
||||||
"""document and name are reserved arcee keys. Anything else is metadata"""
|
"""document and name are reserved arcee keys. Anything else is metadata"""
|
||||||
values["_is_meta"] = values.get("field_name") not in ["document", "name"]
|
values["_is_meta"] = values.get("field_name") not in ["document", "name"]
|
||||||
|
@ -72,7 +72,7 @@ class ArxivAPIWrapper(BaseModel):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@root_validator()
|
@root_validator(pre=True)
|
||||||
def validate_environment(cls, values: Dict) -> Dict:
|
def validate_environment(cls, values: Dict) -> Dict:
|
||||||
"""Validate that the python package exists in environment."""
|
"""Validate that the python package exists in environment."""
|
||||||
try:
|
try:
|
||||||
|
@ -24,7 +24,7 @@ class AskNewsAPIWrapper(BaseModel):
|
|||||||
|
|
||||||
extra = Extra.forbid
|
extra = Extra.forbid
|
||||||
|
|
||||||
@root_validator()
|
@root_validator(pre=True)
|
||||||
def validate_environment(cls, values: Dict) -> Dict:
|
def validate_environment(cls, values: Dict) -> Dict:
|
||||||
"""Validate that api credentials and python package exists in environment."""
|
"""Validate that api credentials and python package exists in environment."""
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class LambdaWrapper(BaseModel):
|
|||||||
|
|
||||||
extra = Extra.forbid
|
extra = Extra.forbid
|
||||||
|
|
||||||
@root_validator()
|
@root_validator(pre=True)
|
||||||
def validate_environment(cls, values: Dict) -> Dict:
|
def validate_environment(cls, values: Dict) -> Dict:
|
||||||
"""Validate that python package exists in environment."""
|
"""Validate that python package exists in environment."""
|
||||||
|
|
||||||
@ -47,8 +47,6 @@ class LambdaWrapper(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
values["lambda_client"] = boto3.client("lambda")
|
values["lambda_client"] = boto3.client("lambda")
|
||||||
values["function_name"] = values["function_name"]
|
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def run(self, query: str) -> str:
|
def run(self, query: str) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user