@@ -33,6 +33,7 @@ class Field:
3333 description: A human-readable description.
3434 tags: User-defined metadata in dictionary form.
3535 vector_index: If set to True the field will be indexed for vector similarity search.
36+ vector_length: The length of the vector if the vector index is set to True.
3637 vector_search_metric: The metric used for vector similarity search.
3738 """
3839
@@ -41,6 +42,7 @@ class Field:
4142 description : str
4243 tags : Dict [str , str ]
4344 vector_index : bool
45+ vector_length : int
4446 vector_search_metric : Optional [str ]
4547
4648 def __init__ (
@@ -51,6 +53,7 @@ def __init__(
5153 description : str = "" ,
5254 tags : Optional [Dict [str , str ]] = None ,
5355 vector_index : bool = False ,
56+ vector_length : int = 0 ,
5457 vector_search_metric : Optional [str ] = None ,
5558 ):
5659 """
@@ -69,6 +72,7 @@ def __init__(
6972 self .description = description
7073 self .tags = tags or {}
7174 self .vector_index = vector_index
75+ self .vector_length = vector_length
7276 self .vector_search_metric = vector_search_metric
7377
7478 def __eq__ (self , other ):
@@ -80,6 +84,7 @@ def __eq__(self, other):
8084 or self .dtype != other .dtype
8185 or self .description != other .description
8286 or self .tags != other .tags
87+ or self .vector_length != other .vector_length
8388 # or self.vector_index != other.vector_index
8489 # or self.vector_search_metric != other.vector_search_metric
8590 ):
@@ -100,6 +105,7 @@ def __repr__(self):
100105 f" description={ self .description !r} ,\n "
101106 f" tags={ self .tags !r} \n "
102107 f" vector_index={ self .vector_index !r} \n "
108+ f" vector_length={ self .vector_length !r} \n "
103109 f" vector_search_metric={ self .vector_search_metric !r} \n "
104110 f")"
105111 )
@@ -117,6 +123,7 @@ def to_proto(self) -> FieldProto:
117123 description = self .description ,
118124 tags = self .tags ,
119125 vector_index = self .vector_index ,
126+ vector_length = self .vector_length ,
120127 vector_search_metric = vector_search_metric ,
121128 )
122129
@@ -131,12 +138,14 @@ def from_proto(cls, field_proto: FieldProto):
131138 value_type = ValueType (field_proto .value_type )
132139 vector_search_metric = getattr (field_proto , "vector_search_metric" , "" )
133140 vector_index = getattr (field_proto , "vector_index" , False )
141+ vector_length = getattr (field_proto , "vector_length" , 0 )
134142 return cls (
135143 name = field_proto .name ,
136144 dtype = from_value_type (value_type = value_type ),
137145 tags = dict (field_proto .tags ),
138146 description = field_proto .description ,
139147 vector_index = vector_index ,
148+ vector_length = vector_length ,
140149 vector_search_metric = vector_search_metric ,
141150 )
142151
0 commit comments