1
1
from typing import List
2
2
3
3
from langchain_community .vectorstores import Qdrant
4
-
5
4
from langflow .base .vectorstores .model import LCVectorStoreComponent
6
5
from langflow .helpers .data import docs_to_data
7
6
from langflow .io import (
13
12
DataInput ,
14
13
MultilineInput ,
15
14
)
16
-
17
15
from langflow .schema import Data
16
+ from langchain .embeddings .base import Embeddings # Certifique-se de que esta importação está correta
18
17
19
18
20
19
class QdrantVectorStoreComponent (LCVectorStoreComponent ):
21
20
display_name = "Qdrant"
22
21
description = "Qdrant Vector Store with search capabilities"
23
22
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/qdrant"
24
- name = "Qdrant"
25
23
icon = "Qdrant"
26
24
27
25
inputs = [
@@ -66,19 +64,18 @@ def _build_qdrant(self) -> Qdrant:
66
64
qdrant_kwargs = {
67
65
"collection_name" : self .collection_name ,
68
66
"content_payload_key" : self .content_payload_key ,
69
- "distance_func" : self .distance_func ,
70
67
"metadata_payload_key" : self .metadata_payload_key ,
71
68
}
72
69
73
70
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
77
74
"api_key" : self .api_key ,
78
75
"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 ,
82
79
}
83
80
84
81
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:
90
87
else :
91
88
documents .append (_input )
92
89
90
+ embedding = self .embedding
91
+ if not isinstance (embedding , Embeddings ):
92
+ raise ValueError ("Invalid embedding object" )
93
+
93
94
if documents :
94
- qdrant = Qdrant .from_documents (documents , embedding = self . embedding , ** qdrant_kwargs )
95
+ qdrant = Qdrant .from_documents (documents , embeddings = embedding , ** qdrant_kwargs )
95
96
else :
96
97
from qdrant_client import QdrantClient
97
98
98
99
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 )
100
101
101
102
return qdrant
102
103
0 commit comments