3333
3434@dataclass
3535class QdrantConnectionParameters :
36+ """Configuration parameters for connecting to Qdrant service.
37+
38+ Either `location`, `url`, `host`, or `path` must be provided to establish
39+ a connection.
40+
41+ Args:
42+ location:
43+ If `str` - use it as a `url` parameter.
44+ If `None` - use default values for `host` and `port`.
45+ url: either host or str of "<scheme>//<host>:<port>/<prefix>".
46+ Default: `None`
47+ port: Port of the REST API interface. Default: 6333
48+ grpc_port: Port of the gRPC interface. Default: 6334
49+ prefer_grpc: If `true` - use gPRC interface whenever possible.
50+ https: If `true` - use HTTPS(SSL) protocol. Default: `None`
51+ api_key: API key for authentication in Qdrant Cloud. Default: `None`
52+ prefix:
53+ If not `None` - add `prefix` to the REST URL path.
54+ Example: `service/v1` will result in
55+ `http://localhost:6333/service/v1/{qdrant-endpoint}` for REST API.
56+ Default: `None`
57+ timeout:
58+ Timeout for REST and gRPC API requests.
59+ Default: 5 seconds for REST and unlimited for gRPC
60+ host:
61+ Host name of Qdrant service.
62+ If url and host are None, set to 'localhost'.
63+ Default: `None`
64+ path: Persistence path for QdrantLocal. Default: `None`
65+ **kwargs: Additional arguments passed directly into client initialization
66+ """
67+
3668 location : Optional [str ] = None
3769 url : Optional [str ] = None
3870 port : Optional [int ] = 6333
@@ -54,6 +86,21 @@ def __post_init__(self):
5486
5587@dataclass
5688class QdrantWriteConfig (VectorDatabaseWriteConfig ):
89+ """Configuration for writing to Qdrant vector database.
90+
91+ This class defines the parameters needed to write data to a qdrant collection,
92+ including collection targeting, batching behavior, and operation timeouts.
93+
94+ Args:
95+ connection_params: QdrantConnectionParameters with connection settings.
96+ collection_name: Name of the Qdrant collection to write to.
97+ timeout: Optional timeout for write operations in seconds. Default is None.
98+ batch_size: Number of points to write in each batch. Default is 1000.
99+ kwargs: Additional keyword arguments to pass to the client's upsert method.
100+ dense_embedding_key: name for the dense vector in the qdrant collection.
101+ sparse_embedding_key: name for the sparse vector in the qdrant collection.
102+ """
103+
57104 connection_params : QdrantConnectionParameters
58105 collection_name : str
59106 timeout : Optional [float ] = None
@@ -70,8 +117,9 @@ def create_write_transform(self) -> beam.PTransform[EmbeddableItem, Any]:
70117 return _QdrantWriteTransform (self )
71118
72119 def create_converter (
73- self ) -> Callable [[EmbeddableItem ], 'models.PointStruct' ]:
74- def convert (item : EmbeddableItem ) -> 'models.PointStruct' :
120+ self ,
121+ ) -> Callable [[EmbeddableItem ], "models.PointStruct" ]:
122+ def convert (item : EmbeddableItem ) -> "models.PointStruct" :
75123 if item .dense_embedding is None and item .sparse_embedding is None :
76124 raise ValueError (
77125 "EmbeddableItem must have at least one embedding (dense or sparse)" )
@@ -111,7 +159,7 @@ class _QdrantWriteFn(beam.DoFn):
111159 def __init__ (self , config : QdrantWriteConfig ):
112160 self .config = config
113161 self ._batch = []
114- self ._client : ' Optional[QdrantClient]' = None
162+ self ._client : " Optional[QdrantClient]" = None
115163
116164 def process (self , element , * args , ** kwargs ):
117165 self ._batch .append (element )
0 commit comments