nandi/gleanpublic Fork 0
01468b3
Commits
Clone
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Inline function in clusterUnverified

Julien Robert committed 2026-05-18T00:10:08+02:00 Browse files
01468b3 parent: 38f3385
modified internal/ml/embed.go +7 -2
@@ -1,10 +1,11 @@
11 package ml
22
33 import (
4+ "bytes"
45 "context"
6+ "encoding/binary"
57 "unsafe"
68
7- vec "github.com/asg017/sqlite-vec-go-bindings/cgo"
89 "github.com/openai/openai-go"
910 "github.com/openai/openai-go/option"
1011 )
@@ -93,7 +94,11 @@ func AvgEmbeddings(blobs [][]byte, dim int) ([]byte, error) {
9394 for j := range sum {
9495 sum[j] /= float32(count)
9596 }
96- return vec.SerializeFloat32(sum)
97+ buf := new(bytes.Buffer)
98+ if err := binary.Write(buf, binary.LittleEndian, sum); err != nil {
99+ return nil, err
100+ }
101+ return buf.Bytes(), nil
97102 }
98103
99104 func BytesToFloat32s(data []byte, expectedDim int) []float32 {
@@ -1,10 +1,11 @@
1 package ml1 package ml
2 2
3 import (3 import (
4+ "bytes"
4 "context"5 "context"
6+ "encoding/binary"
5 "unsafe"7 "unsafe"
6 8
7- vec "github.com/asg017/sqlite-vec-go-bindings/cgo"
8 "github.com/openai/openai-go"9 "github.com/openai/openai-go"
9 "github.com/openai/openai-go/option"10 "github.com/openai/openai-go/option"
10 )11 )
@@ -93,7 +94,11 @@ func AvgEmbeddings(blobs [][]byte, dim int) ([]byte, error) {
93 for j := range sum {94 for j := range sum {
94 sum[j] /= float32(count)95 sum[j] /= float32(count)
95 }96 }
96- return vec.SerializeFloat32(sum)97+ buf := new(bytes.Buffer)
98+ if err := binary.Write(buf, binary.LittleEndian, sum); err != nil {
99+ return nil, err
100+ }
101+ return buf.Bytes(), nil
97 }102 }
98 103
99 func BytesToFloat32s(data []byte, expectedDim int) []float32 {104 func BytesToFloat32s(data []byte, expectedDim int) []float32 {