From 7c9b70764a61c828f4ec05582a19f5db2dea0320 Mon Sep 17 00:00:00 2001 From: choccccy Date: Mon, 17 Jul 2023 14:39:46 -0600 Subject: [PATCH] models.Distance.COSINE --- pylib/embedding_helper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pylib/embedding_helper.py b/pylib/embedding_helper.py index a4571c1..104e4e3 100644 --- a/pylib/embedding_helper.py +++ b/pylib/embedding_helper.py @@ -107,6 +107,7 @@ def add(self, texts, distance_function='Cosine', # Set the default distance function, giving grace to capitalization distance_function = distance_function.lower().capitalize() + distance_function = models.Distance.COSINE # Create a collection in the Qdrant client, and configure its vectors # Using REcreate_collection ensures overwrite @@ -121,6 +122,9 @@ def add(self, texts, distance_function='Cosine', # Put the items in the collection self.upsert(texts=texts, metas=metas) + current_count = int(str(self.db.count(self.name)).partition('=')[-1]) + print('COLLECTION COUNT:', current_count) + def upsert(self, texts, metas=None): ''' Update/insert a Qdrant client's collection with the some chunks of text @@ -132,6 +136,7 @@ def upsert(self, texts, metas=None): metas (List[dict]): Optional metadata per text, stored with the text and included whenever the text is retrieved via search/query ''' + # This ugly declaration just gets the count as an integer current_count = int(str(self.db.count(self.name)).partition('=')[-1]) metas = metas or []