From d14f159d245b5c31c7511f9412870b77c0c624e5 Mon Sep 17 00:00:00 2001 From: eavanvalkenburg Date: Thu, 2 Jan 2025 10:24:28 +0100 Subject: [PATCH] change parsing order --- .../vector_storage/vector_store_record_collection.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/semantic_kernel/data/vector_storage/vector_store_record_collection.py b/python/semantic_kernel/data/vector_storage/vector_store_record_collection.py index 2774ebfb2fd8..cf2d301bf956 100644 --- a/python/semantic_kernel/data/vector_storage/vector_store_record_collection.py +++ b/python/semantic_kernel/data/vector_storage/vector_store_record_collection.py @@ -518,10 +518,10 @@ def _serialize_data_model_to_dict(self, record: TModel, **kwargs: Any) -> OneOrM """ if self.data_model_definition.to_dict: return self.data_model_definition.to_dict(record, **kwargs) - if isinstance(record, BaseModel): - return self._serialize_vectors(record.model_dump()) if isinstance(record, ToDictMethodProtocol): return self._serialize_vectors(record.to_dict()) + if isinstance(record, BaseModel): + return self._serialize_vectors(record.model_dump()) store_model = {} for field_name in self.data_model_definition.field_names: @@ -611,14 +611,14 @@ def _deserialize_dict_to_data_model(self, record: OneOrMany[dict[str, Any]], **k "Cannot deserialize multiple records to a single record unless you are using a container." ) record = record[0] - if issubclass(self.data_model_type, BaseModel): - if include_vectors: - record = self._deserialize_vector(record) - return self.data_model_type.model_validate(record) # type: ignore if func := getattr(self.data_model_type, "from_dict", None): if include_vectors: record = self._deserialize_vector(record) return func(record) + if issubclass(self.data_model_type, BaseModel): + if include_vectors: + record = self._deserialize_vector(record) + return self.data_model_type.model_validate(record) # type: ignore data_model_dict: dict[str, Any] = {} for field_name in self.data_model_definition.fields: if not include_vectors and field_name in self.data_model_definition.vector_field_names: