p2.1: honcho-embed, wayback http/204, memento, keys owner
Embed requests send dixie.embed_model (default honcho-embed). Wayback accepts http://web.archive.org, rewrites to https, skips non-200 closest.status. Memento-Datetime is parsed as an HTTP date and future/garbage values become empty snapshot_at. keys add writes via temp+fchown/chmod/rename so root does not clobber keys.toml. Digest fallback is capped at the 6k-token budget.
This commit is contained in:
@@ -250,3 +250,42 @@ func TestChunkOrderAndBudget(t *testing.T) {
|
||||
t.Fatal("document order")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmbedUsesConfiguredModel(t *testing.T) {
|
||||
var got string
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var body struct {
|
||||
Model string `json:"model"`
|
||||
}
|
||||
_ = json.NewDecoder(r.Body).Decode(&body)
|
||||
got = body.Model
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"data": []map[string]any{
|
||||
{"index": 0, "embedding": []float64{1, 0}},
|
||||
{"index": 1, "embedding": []float64{0, 1}},
|
||||
},
|
||||
})
|
||||
}))
|
||||
defer ts.Close()
|
||||
e := &Engine{EmbedURL: ts.URL, EmbedModel: "honcho-embed", Client: ts.Client()}
|
||||
if _, err := e.embedBatch(context.Background(), []string{"q", "chunk"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != "honcho-embed" {
|
||||
t.Fatalf("model %q", got)
|
||||
}
|
||||
e.EmbedModel = "other-embed"
|
||||
if _, err := e.embedBatch(context.Background(), []string{"q", "chunk"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != "other-embed" {
|
||||
t.Fatalf("model %q", got)
|
||||
}
|
||||
e.EmbedModel = ""
|
||||
if _, err := e.embedBatch(context.Background(), []string{"q", "chunk"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != "honcho-embed" {
|
||||
t.Fatalf("default model %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user