♻️ (Qdrant.py): refactor QdrantComponent class to improve code readability and maintainability by reordering and organizing the initialization parameters.

This commit is contained in:
ogabrielluiz 2024-05-29 10:09:45 -03:00
commit 642acf8172

View file

@ -67,22 +67,19 @@ class QdrantComponent(CustomComponent):
documents.append(_input.to_lc_document()) documents.append(_input.to_lc_document())
else: else:
documents.append(_input) documents.append(_input)
if documents is None: if not documents:
from qdrant_client import QdrantClient from qdrant_client import QdrantClient
client = QdrantClient( client = QdrantClient(
location=location, location=location,
url=host, url=url,
port=port, port=port,
grpc_port=grpc_port, grpc_port=grpc_port,
https=https, https=https,
prefix=prefix, prefix=prefix,
timeout=timeout, timeout=timeout,
prefer_grpc=prefer_grpc, prefer_grpc=prefer_grpc,
metadata_payload_key=metadata_payload_key,
content_payload_key=content_payload_key,
api_key=api_key, api_key=api_key,
collection_name=collection_name,
host=host, host=host,
path=path, path=path,
) )
@ -90,6 +87,8 @@ class QdrantComponent(CustomComponent):
client=client, client=client,
collection_name=collection_name, collection_name=collection_name,
embeddings=embedding, embeddings=embedding,
content_payload_key=content_payload_key,
metadata_payload_key=metadata_payload_key,
) )
return vs return vs
else: else: