1f38e71d1a
Verification, as the task asked. Drove что такое фотосинтез through /api/chat with the search reachable, with the container stopped, and with the host blackholed. Kiwix claims the turn in both failure cases, and a stopped container costs nothing: DNS fails and the ZIM answers inside the same second. The blackhole is the case that hurts. The search waited its full 8-second budget before the ZIM was asked and the turn took 15.4s against 3.5, which he sits through with nothing being said. So the connect phase alone is now capped at 1.5s. A reachable instance that is merely slow keeps the whole budget, because it is fanning out to real engines. The RU Wikipedia ZIM is on the box (owner moved it into the kiwix zims dir), and kiwix-serve picked it up. A Cyrillic question now searches book_ru verbatim and skips the RU->EN rewrite: that rewriter is the workaround for an English book, and against a Russian one it is a translation of his own words back at him. Catalog names come from the filename, not the <name> field — books.name=wikipedia_ru_all returns nothing. Measurement in docs/evals/2026-08-05-kiwix-offline-fallback.md. The RU book answering a driven turn needs a rebuild and is not verified yet.
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestHasCyrillic(t *testing.T) {
|
|
for _, s := range []string{"что такое фотосинтез", "кто такой Elon Musk", "фотосинтез"} {
|
|
if !hasCyrillic(s) {
|
|
t.Errorf("hasCyrillic(%q) = false; it is a Russian question", s)
|
|
}
|
|
}
|
|
for _, s := range []string{"what is photosynthesis", "", "3:2"} {
|
|
if hasCyrillic(s) {
|
|
t.Errorf("hasCyrillic(%q) = true; there is no Cyrillic in it", s)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The book choice and the rewrite decision are the same decision: a Russian
|
|
// book reads his question as he asked it, an English one needs it translated
|
|
// into keywords first (V-508).
|
|
func TestKiwixBookChoice(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
wiring kiwixWiring
|
|
utterance string
|
|
wantBook string
|
|
wantVerb bool
|
|
}{
|
|
{"a russian question reads the russian book verbatim",
|
|
kiwixWiring{book: "en", bookRU: "ru"}, "что такое фотосинтез", "ru", true},
|
|
{"an english question reads the english book",
|
|
kiwixWiring{book: "en", bookRU: "ru"}, "what is photosynthesis", "en", false},
|
|
{"no russian book configured leaves every question on the english one",
|
|
kiwixWiring{book: "en"}, "что такое фотосинтез", "en", false},
|
|
} {
|
|
book, verbatim := tc.wiring.book, false
|
|
if tc.wiring.bookRU != "" && hasCyrillic(tc.utterance) {
|
|
book, verbatim = tc.wiring.bookRU, true
|
|
}
|
|
if book != tc.wantBook || verbatim != tc.wantVerb {
|
|
t.Errorf("%s: book=%q verbatim=%v, want %q/%v", tc.name, book, verbatim, tc.wantBook, tc.wantVerb)
|
|
}
|
|
}
|
|
}
|