-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
130 lines (111 loc) · 3.76 KB
/
models.go
File metadata and controls
130 lines (111 loc) · 3.76 KB
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
package casper
// InsertRequest describes parameters required to insert or upsert a single vector.
type InsertRequest struct {
ID uint32
Vector []float32
}
// DeleteRequest describes parameters required to delete a single vector by ID.
type DeleteRequest struct {
ID uint32
}
// searchVectorBody is used as JSON body for /search requests.
type searchVectorBody struct {
Vector []float32 `json:"vector"`
}
// insertVectorBody is used as JSON body for /insert requests.
type insertVectorBody struct {
Vector []float32 `json:"vector"`
}
// SearchResult is a single nearest–neighbour hit.
type SearchResult struct {
ID uint32 `json:"id"`
Score float32 `json:"score"`
}
// SearchResponse is a convenience alias for a slice of results.
type SearchResponse []SearchResult
// CreateCollectionRequest describes parameters for a new collection.
type CreateCollectionRequest struct {
Dim int
MaxSize uint32
}
// CollectionsListResponse mirrors the JSON returned from /collections.
type CollectionsListResponse struct {
Collections []CollectionInfo `json:"collections"`
}
// CollectionInfo contains metadata about a single collection.
type CollectionInfo struct {
Name string `json:"name"`
Dimension int `json:"dimension"`
Mutable bool `json:"mutable"`
HasIndex bool `json:"has_index"`
MaxSize uint32 `json:"max_size"`
Index *IndexInfo `json:"index,omitempty"`
}
// IndexInfo contains metadata about a collection index.
type IndexInfo struct {
IndexType string `json:"type"`
Metric string `json:"metric"`
Quantization string `json:"quantization"`
Normalization bool `json:"normalization"`
MaxElements *int `json:"max_elements,omitempty"`
M *int `json:"m,omitempty"`
M0 *int `json:"m0,omitempty"`
EfConstruction *int `json:"ef_construction,omitempty"`
Ef *int `json:"ef,omitempty"`
}
// BatchInsertOperation represents a single insert in a batch update.
type BatchInsertOperation struct {
ID uint32 `json:"id"`
Vector []float32 `json:"vector"`
}
// BatchUpdateRequest wraps a batch of insert and delete operations.
type BatchUpdateRequest struct {
Insert []BatchInsertOperation `json:"insert"`
Delete []uint32 `json:"delete"`
}
// HNSWIndex describes an HNSW index creation request.
type HNSWIndex struct {
HNSW HNSW `json:"hnsw"`
Normalization *bool `json:"normalization,omitempty"`
}
// HNSW contains configuration options for HNSW.
type HNSW struct {
Metric string `json:"metric"`
Quantization string `json:"quantization"`
M int `json:"m"`
M0 int `json:"m0"`
EfConstruction int `json:"ef_construction"`
// PQName is optional and only applicable when using PQ quantization (e.g. "pq8").
PQName *string `json:"pq_name,omitempty"`
}
// GetVectorResponse mirrors the JSON returned from /collection/{name}/vector/{id}.
type GetVectorResponse struct {
ID uint32 `json:"id"`
Vector []float32 `json:"vector"`
}
// MatrixInfo describes a matrix entry returned by /matrix APIs.
type MatrixInfo struct {
Name string `json:"name"`
Dim int `json:"dim"`
Len int `json:"len"`
Enabled bool `json:"enabled"`
}
// UploadMatrixResult contains a summary of a successful gRPC matrix upload.
type UploadMatrixResult struct {
Success bool
Message string
TotalVectors uint32
TotalChunks uint32
}
// CreatePQRequest describes a PQ configuration.
type CreatePQRequest struct {
Dim int `json:"dim"`
Codebooks []string `json:"codebooks"`
}
// PQInfo describes a PQ configuration as returned from /pq APIs.
type PQInfo struct {
Name string `json:"name"`
Dim int `json:"dim"`
Codebooks []string `json:"codebooks"`
Enabled bool `json:"enabled"`
}