@@ -33,6 +33,7 @@ class Field:
33
33
description: A human-readable description.
34
34
tags: User-defined metadata in dictionary form.
35
35
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.
36
37
vector_search_metric: The metric used for vector similarity search.
37
38
"""
38
39
@@ -41,6 +42,7 @@ class Field:
41
42
description : str
42
43
tags : Dict [str , str ]
43
44
vector_index : bool
45
+ vector_length : int
44
46
vector_search_metric : Optional [str ]
45
47
46
48
def __init__ (
@@ -51,6 +53,7 @@ def __init__(
51
53
description : str = "" ,
52
54
tags : Optional [Dict [str , str ]] = None ,
53
55
vector_index : bool = False ,
56
+ vector_length : int = 0 ,
54
57
vector_search_metric : Optional [str ] = None ,
55
58
):
56
59
"""
@@ -69,6 +72,7 @@ def __init__(
69
72
self .description = description
70
73
self .tags = tags or {}
71
74
self .vector_index = vector_index
75
+ self .vector_length = vector_length
72
76
self .vector_search_metric = vector_search_metric
73
77
74
78
def __eq__ (self , other ):
@@ -80,6 +84,7 @@ def __eq__(self, other):
80
84
or self .dtype != other .dtype
81
85
or self .description != other .description
82
86
or self .tags != other .tags
87
+ or self .vector_length != other .vector_length
83
88
# or self.vector_index != other.vector_index
84
89
# or self.vector_search_metric != other.vector_search_metric
85
90
):
@@ -100,6 +105,7 @@ def __repr__(self):
100
105
f" description={ self .description !r} ,\n "
101
106
f" tags={ self .tags !r} \n "
102
107
f" vector_index={ self .vector_index !r} \n "
108
+ f" vector_length={ self .vector_length !r} \n "
103
109
f" vector_search_metric={ self .vector_search_metric !r} \n "
104
110
f")"
105
111
)
@@ -117,6 +123,7 @@ def to_proto(self) -> FieldProto:
117
123
description = self .description ,
118
124
tags = self .tags ,
119
125
vector_index = self .vector_index ,
126
+ vector_length = self .vector_length ,
120
127
vector_search_metric = vector_search_metric ,
121
128
)
122
129
@@ -131,12 +138,14 @@ def from_proto(cls, field_proto: FieldProto):
131
138
value_type = ValueType (field_proto .value_type )
132
139
vector_search_metric = getattr (field_proto , "vector_search_metric" , "" )
133
140
vector_index = getattr (field_proto , "vector_index" , False )
141
+ vector_length = getattr (field_proto , "vector_length" , 0 )
134
142
return cls (
135
143
name = field_proto .name ,
136
144
dtype = from_value_type (value_type = value_type ),
137
145
tags = dict (field_proto .tags ),
138
146
description = field_proto .description ,
139
147
vector_index = vector_index ,
148
+ vector_length = vector_length ,
140
149
vector_search_metric = vector_search_metric ,
141
150
)
142
151
0 commit comments