From 97c3544a1eaef3fc939fc9c4bedf84f86dcf8873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20=C5=81ukawski?= Date: Tue, 24 Jan 2023 16:01:07 +0100 Subject: [PATCH] Hotfix: Qdrant.from_text embeddings (#713) I'm providing a hotfix for Qdrant integration. Calculating a single embedding to obtain the vector size was great idea. However, that change introduced a bug trying to put only that single embedding into the database. It's fixed. Right now all the embeddings will be pushed to Qdrant. --- langchain/vectorstores/qdrant.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/langchain/vectorstores/qdrant.py b/langchain/vectorstores/qdrant.py index 77f5b0cf08b..bc40dc263f3 100644 --- a/langchain/vectorstores/qdrant.py +++ b/langchain/vectorstores/qdrant.py @@ -177,8 +177,8 @@ class Qdrant(VectorStore): from qdrant_client.http import models as rest # Just do a single quick embedding to get vector size - embeddings = embedding.embed_documents(texts[:1]) - vector_size = len(embeddings[0]) + partial_embeddings = embedding.embed_documents(texts[:1]) + vector_size = len(partial_embeddings[0]) qdrant_host = get_from_dict_or_env(kwargs, "host", "QDRANT_HOST") kwargs.pop("host") @@ -194,6 +194,9 @@ class Qdrant(VectorStore): ), ) + # Now generate the embeddings for all the texts + embeddings = embedding.embed_documents(texts) + client.upsert( collection_name=collection_name, points=rest.Batch(