@@ -2473,7 +2473,7 @@ def __add_to_module_config(
24732473 else :
24742474 return_dict ["moduleConfig" ][addition_key ] = addition_val
24752475
2476- def _to_dict (self ) -> Dict [str , Any ]:
2476+ def _to_dict (self , * , emit_default_vector_index_type : bool = True ) -> Dict [str , Any ]:
24772477 ret_dict : Dict [str , Any ] = {}
24782478
24792479 for cls_field in type (self ).model_fields :
@@ -2494,14 +2494,23 @@ def _to_dict(self) -> Dict[str, Any]:
24942494 ret_dict ["vectorIndexType" ] = val .vector_index_type ().value
24952495 ret_dict [cls_field ] = val ._to_dict ()
24962496 elif isinstance (val , _VectorConfigCreate ):
2497- ret_dict ["vectorConfig" ] = {val .name or "default" : val ._to_dict ()}
2497+ ret_dict ["vectorConfig" ] = {
2498+ val .name or "default" : val ._to_dict (
2499+ emit_default_vector_index_type = emit_default_vector_index_type
2500+ )
2501+ }
24982502 elif (
24992503 isinstance (val , list )
25002504 and len (val ) > 0
25012505 and all (isinstance (item , _NamedVectorConfigCreate ) for item in val )
25022506 ):
25032507 val = cast (List [_NamedVectorConfigCreate ], val )
2504- ret_dict ["vectorConfig" ] = {item .name : item ._to_dict () for item in val }
2508+ ret_dict ["vectorConfig" ] = {
2509+ item .name : item ._to_dict (
2510+ emit_default_vector_index_type = emit_default_vector_index_type
2511+ )
2512+ for item in val
2513+ }
25052514 elif (
25062515 isinstance (val , list )
25072516 and len (val ) > 0
@@ -2514,11 +2523,17 @@ def _to_dict(self) -> Dict[str, Any]:
25142523 raise WeaviateInvalidInputError (
25152524 "Vector config name must be set when specifying multiple vectors"
25162525 )
2517- ret_dict ["vectorConfig" ][item .name ] = item ._to_dict ()
2526+ ret_dict ["vectorConfig" ][item .name ] = item ._to_dict (
2527+ emit_default_vector_index_type = emit_default_vector_index_type
2528+ )
25182529 else :
25192530 assert isinstance (val , _ConfigCreateModel )
25202531 ret_dict [cls_field ] = val ._to_dict ()
2521- if self .vectorIndexConfig is None and "vectorConfig" not in ret_dict :
2532+ if (
2533+ self .vectorIndexConfig is None
2534+ and "vectorConfig" not in ret_dict
2535+ and emit_default_vector_index_type
2536+ ):
25222537 ret_dict ["vectorIndexType" ] = VectorIndexType .HNSW
25232538
25242539 ret_dict ["class" ] = self .name
0 commit comments