Skip to content

Commit

Permalink
models.Distance.COSINE
Browse files Browse the repository at this point in the history
  • Loading branch information
choccccy committed Jul 17, 2023
1 parent b641dac commit 7c9b707
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pylib/embedding_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 []

Expand Down

0 comments on commit 7c9b707

Please sign in to comment.