-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
180 lines (131 loc) · 4.79 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package vector
type Upsert struct {
// Unique id of the vector.
Id string `json:"id"`
// Vector values.
Vector []float32 `json:"vector"`
// Optional data of the vector.
Data string `json:"data,omitempty"`
// Optional metadata of the vector.
Metadata map[string]any `json:"metadata,omitempty"`
}
type UpsertData struct {
// Unique id of the vector.
Id string `json:"id"`
// Raw data.
// Data will be converted to the vector embedding on the server.
Data string `json:"data"`
// Optional metadata of the vector.
Metadata map[string]any `json:"metadata,omitempty"`
}
type Query struct {
// The query vector.
Vector []float32 `json:"vector"`
// The maximum number of vectors that will
// be returned for the query response.
TopK int `json:"topK,omitempty"`
// Whether to include vector values in the query response.
IncludeVectors bool `json:"includeVectors,omitempty"`
// Whether to include metadata in the query response, if any.
IncludeMetadata bool `json:"includeMetadata,omitempty"`
// Whether to include data in the query response, if any.
IncludeData bool `json:"includeData,omitempty"`
// Query filter
Filter any `json:"filter,omitempty"`
}
type QueryData struct {
// Raw data.
// Data will be converted to the vector embedding on the server.
Data string `json:"data"`
// The maximum number of vectors that will
// be returned for the query response.
TopK int `json:"topK,omitempty"`
// Whether to include vector values in the query response.
IncludeVectors bool `json:"includeVectors,omitempty"`
// Whether to include metadata in the query response, if any.
IncludeMetadata bool `json:"includeMetadata,omitempty"`
// Whether to include data in the query response, if any.
IncludeData bool `json:"includeData,omitempty"`
// Query filter
Filter any `json:"filter,omitempty"`
}
type Vector struct {
// Unique id of the vector.
Id string `json:"id"`
// Vector values.
Vector []float32 `json:"vector,omitempty"`
// Optional metadata of the vector, if any.
Metadata map[string]any `json:"metadata,omitempty"`
// Optional data of the vector.
Data string `json:"data,omitempty"`
}
type VectorScore struct {
// Unique id of the vector.
Id string `json:"id"`
// Similarity score of the vector to the query vector.
// Vectors more similar to the query vector have higher score.
Score float32 `json:"score"`
// Optional vector values.
Vector []float32 `json:"vector,omitempty"`
// Optional metadata of the vector, if any.
Metadata map[string]any `json:"metadata,omitempty"`
// Optional data of the vector.
Data string `json:"data,omitempty"`
}
type Fetch struct {
// Unique vectors ids to fetch.
Ids []string `json:"ids"`
// Whether to include vector values in the fetch response.
IncludeVectors bool `json:"includeVectors,omitempty"`
// Whether to include metadata in the fetch response, if any.
IncludeMetadata bool `json:"includeMetadata,omitempty"`
// Whether to include data in the query response, if any.
IncludeData bool `json:"includeData,omitempty"`
}
type Range struct {
// The cursor to start returning range from (inclusive).
Cursor string `json:"cursor,omitempty"`
// The maximum number of vectors that will be returned for
// the range response.
Limit int `json:"limit,omitempty"`
// Whether to include vector values in the range response.
IncludeVectors bool `json:"includeVectors,omitempty"`
// Whether to include metadata in the fetch response, if any.
IncludeMetadata bool `json:"includeMetadata,omitempty"`
// Whether to include data in the query response, if any.
IncludeData bool `json:"includeData,omitempty"`
}
type RangeVectors struct {
// The cursor that should be used for the subsequent range requests.
NextCursor string `json:"nextCursor"`
// List of vectors in the range.
Vectors []Vector `json:"vectors,omitempty"`
}
type deleted struct {
Deleted int `json:"deleted"`
}
type IndexInfo struct {
// The number of vectors in the index.
VectorCount int `json:"vectorCount"`
// The number of vectors that are pending to be indexed.
PendingVectorCount int `json:"pendingVectorCount"`
// The size of the index on disk in bytes
IndexSize int `json:"indexSize"`
// The dimension of the vectors.
Dimension int `json:"dimension"`
// Name of the similarity function used in indexing and queries.
SimilarityFunction string `json:"similarityFunction"`
// Per-namespace vector and pending vector counts
Namespaces map[string]NamespaceInfo `json:"namespaces"`
}
type NamespaceInfo struct {
// The number of vectors in the namespace of the index.
VectorCount int `json:"vectorCount"`
// The number of vectors that are pending to be indexed.
PendingVectorCount int `json:"pendingVectorCount"`
}
type response[T any] struct {
Result T `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Status int `json:"status,omitempty"`
}