@@ -30,226 +30,251 @@ def __init__(self):
3030
3131 @classmethod
3232 def simple_recommend_image (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
33- return client .recommend (
33+ return client .query_points (
3434 collection_name = COLLECTION_NAME ,
35- positive = [10 ],
36- negative = [],
35+ query = models .RecommendQuery (
36+ recommend = models .RecommendInput (positive = [10 ], negative = [])
37+ ),
3738 with_payload = True ,
3839 limit = 10 ,
3940 using = "sparse-image" ,
40- )
41+ ). points
4142
4243 @classmethod
4344 def many_recommend (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
44- return client .recommend (
45+ return client .query_points (
4546 collection_name = COLLECTION_NAME ,
46- positive = [10 , 19 ],
47+ query = models . RecommendQuery ( recommend = models . RecommendInput ( positive = [10 , 19 ])) ,
4748 with_payload = True ,
4849 limit = 10 ,
4950 using = "sparse-image" ,
50- )
51+ ). points
5152
5253 @classmethod
5354 def simple_recommend_negative (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
54- return client .recommend (
55+ return client .query_points (
5556 collection_name = COLLECTION_NAME ,
56- positive = [10 ],
57- negative = [15 , 7 ],
57+ query = models .RecommendQuery (
58+ recommend = models .RecommendInput (positive = [10 ], negative = [15 , 7 ])
59+ ),
5860 with_payload = True ,
5961 limit = 10 ,
6062 using = "sparse-image" ,
61- )
63+ ). points
6264
6365 @classmethod
6466 def recommend_from_another_collection (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
65- return client .recommend (
67+ return client .query_points (
6668 collection_name = COLLECTION_NAME ,
67- positive = [10 ],
68- negative = [15 , 7 ],
69+ query = models .RecommendQuery (
70+ recommend = models .RecommendInput (positive = [10 ], negative = [15 , 7 ])
71+ ),
6972 with_payload = True ,
7073 limit = 10 ,
7174 using = "sparse-image" ,
7275 lookup_from = models .LookupLocation (
7376 collection = secondary_collection_name ,
7477 vector = "sparse-image" ,
7578 ),
76- )
79+ ). points
7780
7881 @classmethod
7982 def filter_recommend_text (
8083 cls , client : QdrantBase , query_filter : models .Filter
8184 ) -> list [models .ScoredPoint ]:
82- return client .recommend (
85+ return client .query_points (
8386 collection_name = COLLECTION_NAME ,
84- positive = [10 ],
87+ query = models . RecommendQuery ( recommend = models . RecommendInput ( positive = [10 ])) ,
8588 query_filter = query_filter ,
8689 with_payload = True ,
8790 limit = 10 ,
8891 using = "sparse-text" ,
89- )
92+ ). points
9093
9194 @classmethod
9295 def best_score_recommend (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
93- return client .recommend (
96+ return client .query_points (
9497 collection_name = COLLECTION_NAME ,
95- positive = [
96- 10 ,
97- 20 ,
98- ],
99- negative = [] ,
98+ query = models . RecommendQuery (
99+ recommend = models . RecommendInput (
100+ positive = [ 10 , 20 ], negative = [], strategy = models . RecommendStrategy . BEST_SCORE
101+ )
102+ ) ,
100103 with_payload = True ,
101104 limit = 10 ,
102105 using = "sparse-image" ,
103- strategy = models .RecommendStrategy .BEST_SCORE ,
104- )
106+ ).points
105107
106108 @classmethod
107109 def best_score_recommend_euclid (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
108- return client .recommend (
110+ return client .query_points (
109111 collection_name = COLLECTION_NAME ,
110- positive = [
111- 10 ,
112- 20 ,
113- ],
114- negative = [11 , 21 ],
112+ query = models .RecommendQuery (
113+ recommend = models .RecommendInput (
114+ positive = [10 , 20 ],
115+ negative = [11 , 21 ],
116+ strategy = models .RecommendStrategy .BEST_SCORE ,
117+ )
118+ ),
115119 with_payload = True ,
116120 limit = 10 ,
117121 using = "sparse-code" ,
118- strategy = models .RecommendStrategy .BEST_SCORE ,
119- )
122+ ).points
120123
121124 @classmethod
122125 def only_negatives_best_score_recommend (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
123- return client .recommend (
126+ return client .query_points (
124127 collection_name = COLLECTION_NAME ,
125- positive = None ,
126- negative = [10 , 12 ],
128+ query = models .RecommendQuery (
129+ recommend = models .RecommendInput (
130+ positive = None , negative = [10 , 12 ], strategy = models .RecommendStrategy .BEST_SCORE
131+ )
132+ ),
127133 with_payload = True ,
128134 limit = 10 ,
129135 using = "sparse-image" ,
130- strategy = models .RecommendStrategy .BEST_SCORE ,
131- )
136+ ).points
132137
133138 @classmethod
134139 def only_negatives_best_score_recommend_euclid (
135140 cls , client : QdrantBase
136141 ) -> list [models .ScoredPoint ]:
137- return client .recommend (
142+ return client .query_points (
138143 collection_name = COLLECTION_NAME ,
139- positive = None ,
140- negative = [10 , 12 ],
144+ query = models .RecommendQuery (
145+ recommend = models .RecommendInput (
146+ positive = None , negative = [10 , 12 ], strategy = models .RecommendStrategy .BEST_SCORE
147+ )
148+ ),
141149 with_payload = True ,
142150 limit = 10 ,
143151 using = "sparse-code" ,
144- strategy = models .RecommendStrategy .BEST_SCORE ,
145- )
152+ ).points
146153
147154 @classmethod
148155 def sum_scores_recommend (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
149- return client .recommend (
156+ return client .query_points (
150157 collection_name = COLLECTION_NAME ,
151- positive = [
152- 10 ,
153- 20 ,
154- ],
155- negative = [] ,
158+ query = models . RecommendQuery (
159+ recommend = models . RecommendInput (
160+ positive = [ 10 , 20 ], negative = [], strategy = models . RecommendStrategy . SUM_SCORES
161+ )
162+ ) ,
156163 with_payload = True ,
157164 limit = 10 ,
158165 using = "sparse-image" ,
159- strategy = models .RecommendStrategy .SUM_SCORES ,
160- )
166+ ).points
161167
162168 @classmethod
163169 def sum_scores_recommend_euclid (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
164- return client .recommend (
170+ return client .query_points (
165171 collection_name = COLLECTION_NAME ,
166- positive = [
167- 10 ,
168- 20 ,
169- ],
170- negative = [11 , 21 ],
172+ query = models .RecommendQuery (
173+ recommend = models .RecommendInput (
174+ positive = [10 , 20 ],
175+ negative = [11 , 21 ],
176+ strategy = models .RecommendStrategy .SUM_SCORES ,
177+ )
178+ ),
171179 with_payload = True ,
172180 limit = 10 ,
173181 using = "sparse-code" ,
174- strategy = models .RecommendStrategy .SUM_SCORES ,
175- )
182+ ).points
176183
177184 @classmethod
178185 def only_negatives_sum_scores_recommend (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
179- return client .recommend (
186+ return client .query_points (
180187 collection_name = COLLECTION_NAME ,
181- positive = None ,
182- negative = [10 , 12 ],
188+ query = models .RecommendQuery (
189+ recommend = models .RecommendInput (
190+ positive = None , negative = [10 , 12 ], strategy = models .RecommendStrategy .SUM_SCORES
191+ )
192+ ),
183193 with_payload = True ,
184194 limit = 10 ,
185195 using = "sparse-image" ,
186- strategy = models .RecommendStrategy .SUM_SCORES ,
187- )
196+ ).points
188197
189198 @classmethod
190199 def only_negatives_sum_scores_recommend_euclid (
191200 cls , client : QdrantBase
192201 ) -> list [models .ScoredPoint ]:
193- return client .recommend (
202+ return client .query_points (
194203 collection_name = COLLECTION_NAME ,
195- positive = None ,
196- negative = [10 , 12 ],
204+ query = models .RecommendQuery (
205+ recommend = models .RecommendInput (
206+ positive = None , negative = [10 , 12 ], strategy = models .RecommendStrategy .SUM_SCORES
207+ )
208+ ),
197209 with_payload = True ,
198210 limit = 10 ,
199211 using = "sparse-code" ,
200- strategy = models .RecommendStrategy .SUM_SCORES ,
201- )
212+ ).points
202213
203214 @classmethod
204215 def avg_vector_recommend (cls , client : QdrantBase ) -> list [models .ScoredPoint ]:
205- return client .recommend (
216+ return client .query_points (
206217 collection_name = COLLECTION_NAME ,
207- positive = [10 , 13 ],
208- negative = [],
218+ query = models .RecommendQuery (
219+ recommend = models .RecommendInput (
220+ positive = [10 , 13 ],
221+ negative = [],
222+ strategy = models .RecommendStrategy .AVERAGE_VECTOR ,
223+ )
224+ ),
209225 with_payload = True ,
210226 limit = 10 ,
211227 using = "sparse-image" ,
212- strategy = models .RecommendStrategy .AVERAGE_VECTOR ,
213- )
228+ ).points
214229
215230 def recommend_from_raw_vectors (self , client : QdrantBase ) -> list [models .ScoredPoint ]:
216- return client .recommend (
231+ return client .query_points (
217232 collection_name = COLLECTION_NAME ,
218- positive = [self .query_image ],
219- negative = [],
233+ query = models .RecommendQuery (
234+ recommend = models .RecommendInput (positive = [self .query_image ], negative = [])
235+ ),
220236 with_payload = True ,
221237 limit = 10 ,
222238 using = "sparse-image" ,
223- )
239+ ). points
224240
225241 def recommend_from_raw_vectors_and_ids (self , client : QdrantBase ) -> list [models .ScoredPoint ]:
226- return client .recommend (
242+ return client .query_points (
227243 collection_name = COLLECTION_NAME ,
228- positive = [self .query_image , 10 ],
229- negative = [],
244+ query = models .RecommendQuery (
245+ recommend = models .RecommendInput (positive = [self .query_image , 10 ], negative = [])
246+ ),
230247 with_payload = True ,
231248 limit = 10 ,
232249 using = "sparse-image" ,
233- )
250+ ). points
234251
235252 @staticmethod
236- def recommend_batch (client : QdrantBase ) -> list [list [ models .ScoredPoint ] ]:
237- return client .recommend_batch (
253+ def recommend_batch (client : QdrantBase ) -> list [models .QueryResponse ]:
254+ return client .query_batch_points (
238255 collection_name = COLLECTION_NAME ,
239256 requests = [
240- models .RecommendRequest (
241- positive = [3 ],
242- negative = [],
257+ models .QueryRequest (
258+ query = models .RecommendQuery (
259+ recommend = models .RecommendInput (
260+ positive = [3 ],
261+ negative = [],
262+ strategy = models .RecommendStrategy .AVERAGE_VECTOR ,
263+ )
264+ ),
243265 limit = 1 ,
244266 using = "sparse-image" ,
245- strategy = models .RecommendStrategy .AVERAGE_VECTOR ,
246267 ),
247- models .RecommendRequest (
248- positive = [10 ],
249- negative = [],
268+ models .QueryRequest (
269+ query = models .RecommendQuery (
270+ recommend = models .RecommendInput (
271+ positive = [10 ],
272+ negative = [],
273+ strategy = models .RecommendStrategy .BEST_SCORE ,
274+ )
275+ ),
250276 limit = 2 ,
251277 using = "sparse-image" ,
252- strategy = models .RecommendStrategy .BEST_SCORE ,
253278 lookup_from = models .LookupLocation (
254279 collection = secondary_collection_name ,
255280 vector = "sparse-image" ,
@@ -362,33 +387,37 @@ def test_query_with_nan():
362387 )
363388
364389 with pytest .raises (AssertionError ):
365- local_client .recommend (
390+ local_client .query_points (
366391 collection_name = COLLECTION_NAME ,
367- positive = [sparse_vector ],
368- negative = [],
392+ query = models .RecommendQuery (
393+ recommend = models .RecommendInput (positive = [sparse_vector ], negative = [])
394+ ),
369395 using = using ,
370396 )
371397
372398 with pytest .raises (UnexpectedResponse ):
373- remote_client .recommend (
399+ remote_client .query_points (
374400 collection_name = COLLECTION_NAME ,
375- positive = [sparse_vector ],
376- negative = [],
401+ query = models .RecommendQuery (
402+ recommend = models .RecommendInput (positive = [sparse_vector ], negative = [])
403+ ),
377404 using = using ,
378405 )
379406
380407 with pytest .raises (AssertionError ):
381- local_client .recommend (
408+ local_client .query_points (
382409 collection_name = COLLECTION_NAME ,
383- positive = [1 ],
384- negative = [sparse_vector ],
410+ query = models .RecommendQuery (
411+ recommend = models .RecommendInput (positive = [1 ], negative = [sparse_vector ])
412+ ),
385413 using = using ,
386414 )
387415
388416 with pytest .raises (UnexpectedResponse ):
389- remote_client .recommend (
417+ remote_client .query_points (
390418 collection_name = COLLECTION_NAME ,
391- positive = [1 ],
392- negative = [sparse_vector ],
419+ query = models .RecommendQuery (
420+ recommend = models .RecommendInput (positive = [1 ], negative = [sparse_vector ])
421+ ),
393422 using = using ,
394423 )
0 commit comments