Skip to content

Commit

Permalink
further support for using no SentenceTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
choccccy committed Oct 10, 2023
1 parent 53d670b commit 6e61242
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pylib/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# SPDX-License-Identifier: Apache-2.0
# ogbujipt.about

__version__ = "0.5.0"
__version__ = "0.5.1"
13 changes: 6 additions & 7 deletions pylib/embedding_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,17 @@ def __init__(self, embedding_model, conn):
See the main docstring (or run `help(pgvector_connection)`)
'''
# Check if the provided embedding model is a SentenceTransformer
if embedding_model.__class__.__name__ == 'SentenceTransformer':
if (embedding_model.__class__.__name__ == 'SentenceTransformer') and (not None):
self._embedding_model = embedding_model
self._embed_dimension = len(self._embedding_model.encode(''))
elif embedding_model is None:
self._embedding_model = None
self._embed_dimension = 0
else:
raise ValueError('embedding_model must be a SentenceTransformer object')
raise ValueError('embedding_model must be a SentenceTransformer object or None')

self.conn = conn

if self._embedding_model: # if self.embedding_model is none, don't try to measure dimensionality
self._embed_dimension = len(self._embedding_model.encode(''))
else:
self._embed_dimension = 0

@classmethod
async def create(
cls,
Expand Down

0 comments on commit 6e61242

Please sign in to comment.