diff --git a/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py b/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py index 20d6b85c6a0..62bf96bad9a 100644 --- a/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py +++ b/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py @@ -95,14 +95,14 @@ class SagemakerEndpointCrossEncoder(BaseModel, BaseCrossEncoder): extra = Extra.forbid arbitrary_types_allowed = True - @root_validator() + @root_validator(pre=True) def validate_environment(cls, values: Dict) -> Dict: """Validate that AWS credentials to and python package exists in environment.""" try: import boto3 try: - if values["credentials_profile_name"] is not None: + if values.get("credentials_profile_name"): session = boto3.Session( profile_name=values["credentials_profile_name"] ) diff --git a/libs/community/langchain_community/document_compressors/dashscope_rerank.py b/libs/community/langchain_community/document_compressors/dashscope_rerank.py index 45010863990..07903d549ec 100644 --- a/libs/community/langchain_community/document_compressors/dashscope_rerank.py +++ b/libs/community/langchain_community/document_compressors/dashscope_rerank.py @@ -32,7 +32,7 @@ class DashScopeRerank(BaseDocumentCompressor): arbitrary_types_allowed = True allow_population_by_field_name = True - @root_validator() + @root_validator(pre=True) def validate_environment(cls, values: Dict) -> Dict: """Validate that api key and python package exists in environment.""" diff --git a/libs/community/langchain_community/document_compressors/volcengine_rerank.py b/libs/community/langchain_community/document_compressors/volcengine_rerank.py index f62ed88514c..a7098584db1 100644 --- a/libs/community/langchain_community/document_compressors/volcengine_rerank.py +++ b/libs/community/langchain_community/document_compressors/volcengine_rerank.py @@ -39,7 +39,7 @@ class VolcengineRerank(BaseDocumentCompressor): arbitrary_types_allowed = True allow_population_by_field_name = True - @root_validator() + @root_validator(pre=True) def validate_environment(cls, values: Dict) -> Dict: """Validate that api key and python package exists in environment.""" diff --git a/libs/community/langchain_community/document_loaders/apify_dataset.py b/libs/community/langchain_community/document_loaders/apify_dataset.py index 2805ff698c2..339a25c1ede 100644 --- a/libs/community/langchain_community/document_loaders/apify_dataset.py +++ b/libs/community/langchain_community/document_loaders/apify_dataset.py @@ -49,7 +49,7 @@ class ApifyDatasetLoader(BaseLoader, BaseModel): dataset_id=dataset_id, dataset_mapping_function=dataset_mapping_function ) - @root_validator() + @root_validator(pre=True) def validate_environment(cls, values: Dict) -> Dict: """Validate environment. diff --git a/libs/community/langchain_community/tools/connery/service.py b/libs/community/langchain_community/tools/connery/service.py index b8606a9317a..11c921c1bc2 100644 --- a/libs/community/langchain_community/tools/connery/service.py +++ b/libs/community/langchain_community/tools/connery/service.py @@ -20,7 +20,7 @@ class ConneryService(BaseModel): runner_url: Optional[str] = None api_key: Optional[str] = None - @root_validator() + @root_validator(pre=True) def validate_attributes(cls, values: Dict) -> Dict: """ Validate the attributes of the ConneryService class. diff --git a/libs/community/langchain_community/tools/connery/tool.py b/libs/community/langchain_community/tools/connery/tool.py index 51138714e26..ac725a3a4b4 100644 --- a/libs/community/langchain_community/tools/connery/tool.py +++ b/libs/community/langchain_community/tools/connery/tool.py @@ -63,7 +63,7 @@ class ConneryAction(BaseTool): return self.args_schema.schema_json(indent=2) - @root_validator() + @root_validator(pre=True) def validate_attributes(cls, values: dict) -> dict: """ Validate the attributes of the ConneryAction class. diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index 109d52f6555..9543120c3c3 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -1559,7 +1559,7 @@ class AzureSearchVectorStoreRetriever(BaseRetriever): arbitrary_types_allowed = True - @root_validator() + @root_validator(pre=True) def validate_search_type(cls, values: Dict) -> Dict: """Validate search type.""" if "search_type" in values: