diff --git a/libs/community/langchain_google_community/bq_storage_vectorstores/bigquery.py b/libs/community/langchain_google_community/bq_storage_vectorstores/bigquery.py index d85a1bf8..af2fa62f 100644 --- a/libs/community/langchain_google_community/bq_storage_vectorstores/bigquery.py +++ b/libs/community/langchain_google_community/bq_storage_vectorstores/bigquery.py @@ -128,7 +128,7 @@ def initialize_bq_vector_index(self) -> Self: self._have_index = self._have_index self._last_index_check = self._last_index_check - if (self._have_index or None) or (self._creating_index or None): + if self._have_index or self._creating_index: return self table = self._bq_client.get_table(self._full_table_id) # type: ignore[union-attr] @@ -567,7 +567,9 @@ def to_vertex_fs_vector_store(self, **kwargs: Any) -> Any: VertexFSVectorStore, ) - base_params = self.dict(include=BaseBigQueryVectorStore.__fields__.keys()) + base_params = self.model_dump( + include=set(BaseBigQueryVectorStore.model_fields.keys()) + ) base_params["embedding"] = self.embedding all_params = {**base_params, **kwargs} fs_obj = VertexFSVectorStore(**all_params) diff --git a/libs/community/langchain_google_community/bq_storage_vectorstores/featurestore.py b/libs/community/langchain_google_community/bq_storage_vectorstores/featurestore.py index bc3e4f54..a0a1ba1f 100644 --- a/libs/community/langchain_google_community/bq_storage_vectorstores/featurestore.py +++ b/libs/community/langchain_google_community/bq_storage_vectorstores/featurestore.py @@ -99,9 +99,9 @@ def _initialize_bq_vector_index(self) -> Self: self.algorithm_config = utils.TreeAhConfig() if self.distance_measure_type is None: self.distance_measure_type = utils.DistanceMeasureType.DOT_PRODUCT_DISTANCE - if (self.online_store_name or None) is None: + if self.online_store_name is None: self.online_store_name = self.dataset_name - if (self.view_name or None) is None: + if self.view_name is None: self.view_name = self.table_name api_endpoint = f"{self.location}-aiplatform.googleapis.com" @@ -513,7 +513,9 @@ def to_bq_vector_store(self, **kwargs: Any) -> Any: BigQueryVectorStore, ) - base_params = self.dict(include=BaseBigQueryVectorStore.__fields__.keys()) + base_params = self.model_dump( + include=set(BaseBigQueryVectorStore.model_fields.keys()) + ) base_params["embedding"] = self.embedding all_params = {**base_params, **kwargs} bq_obj = BigQueryVectorStore(**all_params) diff --git a/libs/community/langchain_google_community/drive.py b/libs/community/langchain_google_community/drive.py index 0fa68e16..7cc3f8a6 100644 --- a/libs/community/langchain_google_community/drive.py +++ b/libs/community/langchain_google_community/drive.py @@ -13,7 +13,7 @@ from langchain_core.document_loaders import BaseLoader from langchain_core.documents import Document -from pydantic import BaseModel, root_validator, validator +from pydantic import BaseModel, model_validator, validator SCOPES = ["https://www.googleapis.com/auth/drive.file"] @@ -194,8 +194,9 @@ def _get_identity_metadata_from_id(self, id: str) -> List[str]: return authorized_identities - @root_validator - def validate_inputs(cls, values: Dict[str, Any]) -> Dict[str, Any]: + @model_validator(mode="before") + @classmethod + def validate_inputs(cls, values: Dict[str, Any]) -> Any: """Validate that either folder_id or document_ids is set, but not both.""" if values.get("folder_id") and ( values.get("document_ids") or values.get("file_ids")