Skip to content

Commit 6257a32

Browse files
devalexandreautofix-ci[bot]ogabrielluiz
authored
fix(QDrant): Resolve bug in document search functionality (langflow-ai#2518)
* Update Qdrant.py fixed embeddings and distance_func for search_documents issue langflow-ai#2517 * [autofix.ci] apply automated fixes * fixed documents link * update params Qdrant * Update Qdrant.py * Update Qdrant.py * Update Qdrant.py * [autofix.ci] apply automated fixes * Update args * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
1 parent 9e6fe19 commit 6257a32

File tree

1 file changed

+13
-12
lines changed
  • src/backend/base/langflow/components/vectorstores

1 file changed

+13
-12
lines changed

src/backend/base/langflow/components/vectorstores/Qdrant.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import List
22

33
from langchain_community.vectorstores import Qdrant
4-
54
from langflow.base.vectorstores.model import LCVectorStoreComponent
65
from langflow.helpers.data import docs_to_data
76
from langflow.io import (
@@ -13,15 +12,14 @@
1312
DataInput,
1413
MultilineInput,
1514
)
16-
1715
from langflow.schema import Data
16+
from langchain.embeddings.base import Embeddings # Certifique-se de que esta importação está correta
1817

1918

2019
class QdrantVectorStoreComponent(LCVectorStoreComponent):
2120
display_name = "Qdrant"
2221
description = "Qdrant Vector Store with search capabilities"
2322
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/qdrant"
24-
name = "Qdrant"
2523
icon = "Qdrant"
2624

2725
inputs = [
@@ -66,19 +64,18 @@ def _build_qdrant(self) -> Qdrant:
6664
qdrant_kwargs = {
6765
"collection_name": self.collection_name,
6866
"content_payload_key": self.content_payload_key,
69-
"distance_func": self.distance_func,
7067
"metadata_payload_key": self.metadata_payload_key,
7168
}
7269

7370
server_kwargs = {
74-
"host": self.host,
75-
"port": self.port,
76-
"grpc_port": self.grpc_port,
71+
"host": self.host if self.host else None,
72+
"port": int(self.port), # Garantir que port seja um inteiro
73+
"grpc_port": int(self.grpc_port), # Garantir que grpc_port seja um inteiro
7774
"api_key": self.api_key,
7875
"prefix": self.prefix,
79-
"timeout": self.timeout,
80-
"path": self.path,
81-
"url": self.url,
76+
"timeout": int(self.timeout) if self.timeout else None, # Garantir que timeout seja um inteiro
77+
"path": self.path if self.path else None,
78+
"url": self.url if self.url else None,
8279
}
8380

8481
server_kwargs = {k: v for k, v in server_kwargs.items() if v is not None}
@@ -90,13 +87,17 @@ def _build_qdrant(self) -> Qdrant:
9087
else:
9188
documents.append(_input)
9289

90+
embedding = self.embedding
91+
if not isinstance(embedding, Embeddings):
92+
raise ValueError("Invalid embedding object")
93+
9394
if documents:
94-
qdrant = Qdrant.from_documents(documents, embedding=self.embedding, **qdrant_kwargs)
95+
qdrant = Qdrant.from_documents(documents, embeddings=embedding, **qdrant_kwargs)
9596
else:
9697
from qdrant_client import QdrantClient
9798

9899
client = QdrantClient(**server_kwargs)
99-
qdrant = Qdrant(embedding_function=self.embedding.embed_query, client=client, **qdrant_kwargs)
100+
qdrant = Qdrant(embeddings=embedding, client=client, **qdrant_kwargs)
100101

101102
return qdrant
102103

0 commit comments

Comments
 (0)