@@ -417,42 +417,24 @@ def to_grpc_target_vector(self, version: _ServerVersion) -> base_search_pb2.Targ
417417 assert combination == _MultiTargetVectorJoinEnum .MINIMUM
418418 combination_grpc = base_search_pb2 .COMBINATION_METHOD_TYPE_MIN
419419
420- if version .is_lower_than (1 , 27 , 0 ):
421- if self .weights is not None and any (isinstance (w , list ) for w in self .weights .values ()):
422- raise ValueError (
423- "Multiple weights per target are not supported in this Weaviate version. Please upgrade to at least Weaviate 1.27.0."
424- )
425- # mypy does not seem to understand the type narrowing right above
426- weights_typed = cast (Optional [Dict [str , float ]], self .weights )
427-
428- return base_search_pb2 .Targets (
429- target_vectors = self .target_vectors ,
430- weights = weights_typed ,
431- combination = combination_grpc ,
432- )
433- else :
434- weights : List [base_search_pb2 .WeightsForTarget ] = []
435- target_vectors : List [str ] = self .target_vectors
436- if self .weights is not None :
437- target_vectors = []
438- for target , weight in self .weights .items ():
439- if isinstance (weight , list ):
440- for w in weight :
441- weights .append (
442- base_search_pb2 .WeightsForTarget (target = target , weight = w )
443- )
444- target_vectors .append (target )
445- else :
446- weights .append (
447- base_search_pb2 .WeightsForTarget (target = target , weight = weight )
448- )
420+ weights : List [base_search_pb2 .WeightsForTarget ] = []
421+ target_vectors : List [str ] = self .target_vectors
422+ if self .weights is not None :
423+ target_vectors = []
424+ for target , weight in self .weights .items ():
425+ if isinstance (weight , list ):
426+ for w in weight :
427+ weights .append (base_search_pb2 .WeightsForTarget (target = target , weight = w ))
449428 target_vectors .append (target )
429+ else :
430+ weights .append (base_search_pb2 .WeightsForTarget (target = target , weight = weight ))
431+ target_vectors .append (target )
450432
451- return base_search_pb2 .Targets (
452- target_vectors = target_vectors ,
453- weights_for_targets = weights ,
454- combination = combination_grpc ,
455- )
433+ return base_search_pb2 .Targets (
434+ target_vectors = target_vectors ,
435+ weights_for_targets = weights ,
436+ combination = combination_grpc ,
437+ )
456438
457439
458440TargetVectorJoinType = Union [str , List [str ], _MultiTargetVectorJoin ]
0 commit comments