You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I store []float32 data using sqlite_vec's SerializeFloat32 function and am wondering how I can retrieve it from SQLite into Go. I've been using vec_to_json and unmarshaling the JSON on the Go side as the following code, but I suspect there might be a better approach. Could you please advise?
var embeddingJson string
row := db.QueryRowContext(
ctx,
`SELECT vec_to_json(embedding) FROM documents WHERE document_id = ?`,
id,
)
err := row.Scan(&embeddingJson)
if err != nil {
return nil, err
}
var embedding []float32
err = json.Unmarshal([]byte(embeddingJson), &embedding)
if err != nil {
return nil, err
}
return embedding, nil
The text was updated successfully, but these errors were encountered:
I store
[]float32
data using sqlite_vec'sSerializeFloat32
function and am wondering how I can retrieve it from SQLite into Go. I've been usingvec_to_json
and unmarshaling the JSON on the Go side as the following code, but I suspect there might be a better approach. Could you please advise?The text was updated successfully, but these errors were encountered: