pkavumba / django-vectordb

A fast and scalable app that adds vector search capabilities to your Django applications. It offers low latency, fast search results, native Django integration, and automatic syncing between your models and the vector index. Incremental updates are also supported out of the box.
Apache License 2.0
68 stars 6 forks source link

fix case where text is a list #10

Closed bbytiger closed 1 year ago

bbytiger commented 1 year ago

The embedding function model.objects.embedding_fn is sometimes called with singular text of type str, but other times called with a list of str texts.

On line 80 of queryset.py, we have query_embeddings = self.model.objects.embedding_fn([text]), which will break the get_embedding function of the OpenAIEmbeddings class. You get an error with text = text.replace("\n", " ") because text is not a string but instead a list.

This change fixes this so that get_embedding is only called with type string.