@@ -272,6 +272,14 @@ def get_relevant_question_answers(self, question: str, k: int = 1) -> List[dict]
272272 """
273273 Returns relevant question answers based on search
274274 """
275+ if not self ._client .collection_exists (self ._qa_collection_name ):
276+ return {
277+ "documents" : [],
278+ "distances" : [],
279+ "metadatas" : [],
280+ "ids" : [],
281+ }
282+
275283 response = self ._client .query (
276284 self ._qa_collection_name ,
277285 query_text = question ,
@@ -285,13 +293,19 @@ def get_relevant_docs(self, question: str, k: int = 1) -> List[dict]:
285293 """
286294 Returns relevant documents based on semantic search
287295 """
296+ if not self ._client .collection_exists (self ._docs_collection_name ):
297+ return {
298+ "documents" : [],
299+ "distances" : [],
300+ "metadatas" : [],
301+ "ids" : [],
302+ }
288303 response = self ._client .query (
289304 self ._docs_collection_name ,
290305 query_text = question ,
291306 limit = k ,
292307 score_threshold = self ._similarity_threshold ,
293308 )
294-
295309 return self ._convert_query_response (response )
296310
297311 def get_relevant_question_answers_by_id (self , ids : Iterable [str ]) -> List [dict ]:
@@ -356,9 +370,11 @@ def _convert_ids(self, ids: Iterable[str]) -> List[str]:
356370 This allows us to overwrite the same point with the original ID.
357371 """
358372 return [
359- id
360- if self ._is_valid_uuid (id )
361- else str (uuid .uuid5 (uuid .UUID (UUID_NAMESPACE ), id ))
373+ (
374+ id
375+ if self ._is_valid_uuid (id )
376+ else str (uuid .uuid5 (uuid .UUID (UUID_NAMESPACE ), id ))
377+ )
362378 for id in ids
363379 ]
364380
0 commit comments