fix(QDrant): Resolve bug in document search functionality (#2518)
* Update Qdrant.py fixed embeddings and distance_func for search_documents issue #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 <gabriel@langflow.org>
This commit is contained in:
parent
9e6fe193c9
commit
6257a32523
1 changed files with 13 additions and 12 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from typing import List
|
||||
|
||||
from langchain_community.vectorstores import Qdrant
|
||||
|
||||
from langflow.base.vectorstores.model import LCVectorStoreComponent
|
||||
from langflow.helpers.data import docs_to_data
|
||||
from langflow.io import (
|
||||
|
|
@ -13,15 +12,14 @@ from langflow.io import (
|
|||
DataInput,
|
||||
MultilineInput,
|
||||
)
|
||||
|
||||
from langflow.schema import Data
|
||||
from langchain.embeddings.base import Embeddings # Certifique-se de que esta importação está correta
|
||||
|
||||
|
||||
class QdrantVectorStoreComponent(LCVectorStoreComponent):
|
||||
display_name = "Qdrant"
|
||||
description = "Qdrant Vector Store with search capabilities"
|
||||
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/qdrant"
|
||||
name = "Qdrant"
|
||||
icon = "Qdrant"
|
||||
|
||||
inputs = [
|
||||
|
|
@ -66,19 +64,18 @@ class QdrantVectorStoreComponent(LCVectorStoreComponent):
|
|||
qdrant_kwargs = {
|
||||
"collection_name": self.collection_name,
|
||||
"content_payload_key": self.content_payload_key,
|
||||
"distance_func": self.distance_func,
|
||||
"metadata_payload_key": self.metadata_payload_key,
|
||||
}
|
||||
|
||||
server_kwargs = {
|
||||
"host": self.host,
|
||||
"port": self.port,
|
||||
"grpc_port": self.grpc_port,
|
||||
"host": self.host if self.host else None,
|
||||
"port": int(self.port), # Garantir que port seja um inteiro
|
||||
"grpc_port": int(self.grpc_port), # Garantir que grpc_port seja um inteiro
|
||||
"api_key": self.api_key,
|
||||
"prefix": self.prefix,
|
||||
"timeout": self.timeout,
|
||||
"path": self.path,
|
||||
"url": self.url,
|
||||
"timeout": int(self.timeout) if self.timeout else None, # Garantir que timeout seja um inteiro
|
||||
"path": self.path if self.path else None,
|
||||
"url": self.url if self.url else None,
|
||||
}
|
||||
|
||||
server_kwargs = {k: v for k, v in server_kwargs.items() if v is not None}
|
||||
|
|
@ -90,13 +87,17 @@ class QdrantVectorStoreComponent(LCVectorStoreComponent):
|
|||
else:
|
||||
documents.append(_input)
|
||||
|
||||
embedding = self.embedding
|
||||
if not isinstance(embedding, Embeddings):
|
||||
raise ValueError("Invalid embedding object")
|
||||
|
||||
if documents:
|
||||
qdrant = Qdrant.from_documents(documents, embedding=self.embedding, **qdrant_kwargs)
|
||||
qdrant = Qdrant.from_documents(documents, embeddings=embedding, **qdrant_kwargs)
|
||||
else:
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
client = QdrantClient(**server_kwargs)
|
||||
qdrant = Qdrant(embedding_function=self.embedding.embed_query, client=client, **qdrant_kwargs)
|
||||
qdrant = Qdrant(embeddings=embedding, client=client, **qdrant_kwargs)
|
||||
|
||||
return qdrant
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue