-
Notifications
You must be signed in to change notification settings - Fork 1
/
upsert_data.go
35 lines (30 loc) · 1.12 KB
/
upsert_data.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
package vector
const upsertDataPath = "/upsert-data"
// UpsertData updates or inserts a vector to the default namespace of the index
// by converting given raw data to an embedding on the server.
// Additional metadata can also be provided while upserting the vector.
func (ix *Index) UpsertData(u UpsertData) (err error) {
return ix.upsertDataInternal(u, defaultNamespace)
}
// UpsertDataMany updates or inserts some vectors to the default namespace of the index
// by converting given raw data to an embedding on the server.
// Additional metadata can also be provided for each vector.
func (ix *Index) UpsertDataMany(u []UpsertData) (err error) {
return ix.upsertDataManyInternal(u, defaultNamespace)
}
func (ix *Index) upsertDataInternal(u UpsertData, ns string) (err error) {
data, err := ix.sendJson(buildPath(upsertDataPath, ns), u)
if err != nil {
return
}
_, err = parseResponse[string](data)
return
}
func (ix *Index) upsertDataManyInternal(u []UpsertData, ns string) (err error) {
data, err := ix.sendJson(buildPath(upsertDataPath, ns), u)
if err != nil {
return
}
_, err = parseResponse[string](data)
return
}