The gateway embeds the documents llmgw-kb sends as text
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
01ad8c9207
commit
cacaa35c3f
11 files changed
+350
-27
No files matched your search
@@ -22,6 +22,10 @@ type fakeGateway struct {
|
||||
puts int
|
||||
embedded int
|
||||
busyFirst bool
|
||||
// serverEmbeds is a gateway that embeds text it is sent; vectors
|
||||
// counts chunks that came with one.
|
||||
serverEmbeds bool
|
||||
vectors int
|
||||
}
|
||||
|
||||
func (g *fakeGateway) serve(t *testing.T) *Client {
|
||||
@@ -37,6 +41,7 @@ func (g *fakeGateway) serve(t *testing.T) *Client {
|
||||
}
|
||||
m := Manifest{Collection: coll}
|
||||
m.Collection.Writable = g.writable
|
||||
m.Collection.ServerEmbeds = g.serverEmbeds
|
||||
for _, d := range g.docs {
|
||||
m.Documents = append(m.Documents, d)
|
||||
}
|
||||
@@ -48,6 +53,11 @@ func (g *fakeGateway) serve(t *testing.T) *Client {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
g.puts++
|
||||
for _, c := range d.Chunks {
|
||||
if len(c.Embedding) > 0 {
|
||||
g.vectors++
|
||||
}
|
||||
}
|
||||
g.docs[d.Name] = RemoteDoc{Name: d.Name, Digest: d.Digest, Chunks: len(d.Chunks)}
|
||||
_, _ = w.Write([]byte(`{"changed":true}`))
|
||||
})
|
||||
@@ -270,3 +280,22 @@ func TestFiltersAndNames(t *testing.T) {
|
||||
t.Errorf("an empty folder gave %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAGatewayThatEmbedsIsSentTextAlone(t *testing.T) {
|
||||
g, c, l, dir := setup(t)
|
||||
g.serverEmbeds = true
|
||||
rep, k := run(t, c, l, Options{Collection: "ik", Roots: []string{dir}})
|
||||
if len(k["sent"]) != 2 || rep.Failed != 0 {
|
||||
t.Fatalf("%+v %v", rep, k)
|
||||
}
|
||||
if g.embedded != 0 || g.vectors != 0 {
|
||||
t.Errorf("embedded here: %d asked, %d vectors sent", g.embedded, g.vectors)
|
||||
}
|
||||
|
||||
// --embed-here sends the vectors all the same.
|
||||
write(t, dir, "politika/yeni.md", "Yeni kural.\n")
|
||||
run(t, c, l, Options{Collection: "ik", Roots: []string{dir}, EmbedHere: true})
|
||||
if g.embedded == 0 || g.vectors == 0 {
|
||||
t.Errorf("--embed-here: %d asked, %d vectors sent", g.embedded, g.vectors)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user