@@ -152,7 +152,7 @@ def default_serializer(obj):
152152 """Default function to handle non-serializable objects"""
153153 if isinstance (obj , QueryRatingContext ):
154154 return obj .to_dict ()
155- elif isinstance (obj , Document ): # from pydantic import BaseModel
155+ elif isinstance (obj , Document ): # more generall: from pydantic import BaseModel
156156 return obj .model_dump ()
157157 else :
158158 # Convert to string as fallback
@@ -172,9 +172,6 @@ def load_tmp_file_content(self) -> None:
172172 """
173173 Loads the content from a file on disk deserializing queries-ratings and documents.
174174 """
175- self ._documents .clear ()
176- self ._queries_by_id .clear ()
177- self ._query_text_to_query_id .clear ()
178175
179176 filepath : Path = self .ensure_path_and_folder_exists ()
180177
@@ -185,6 +182,10 @@ def load_tmp_file_content(self) -> None:
185182 with filepath .open ("r" , encoding = "utf-8" ) as f :
186183 file_content = json .load (f )
187184
185+ self ._documents .clear ()
186+ self ._queries_by_id .clear ()
187+ self ._query_text_to_query_id .clear ()
188+
188189 queries_data : Dict [str , Dict [str , Any ]] = file_content .get ("queries" , {})
189190 documents_data : Dict [str , Dict [str , Any ]] = file_content .get ("documents" , {})
190191
0 commit comments