fix(singbox): экспорт COMMUNITY_SERVICES для загрузки ruleset и исправление RAG эмбеддингов AI Doctor

This commit is contained in:
Dushnilin
2026-09-06 17:06:41 +03:00
parent 260e64714b
commit 2fd8c2dca3
4 changed files with 40 additions and 6 deletions
+22
View File
@@ -56,4 +56,26 @@ print((length(out) == 2 && length(out[0]) == 2 && out[1][1] == 4) ? "OK" : "BAD"
[ "$push_check" = "OK" ] ||
fail "ucode push(array, value) did not behave as expected (saw '$push_check')"
# 6. Runtime verification of rag.uc functions (as_string, get_embedding_model, search, sqrt_val, slice)
runtime_check="$(ucode -L "$TACHYON_LIB" -e '
let rag = require("diagnostics.rag");
assert(rag.get_embedding_model("OpenAI") == "text-embedding-3-small", "OpenAI");
assert(rag.get_embedding_model("DEEPSEEK") == "deepseek-embedding", "DeepSeek");
assert(rag.get_embedding_model(null, null) == "text-embedding-3-small", "null");
let idx = {
chunks: [
{ file: "f1.md", heading: "H1", text: "T1", embedding: [1.0, 0.0] },
{ file: "f2.md", heading: "H2", text: "T2", embedding: [0.9, 0.1] },
{ file: "f3.md", heading: "H3", text: "T3", embedding: [0.8, 0.2] }
]
};
let res = rag.search([1.0, 0.0], idx, 2);
assert(length(res) == 2, "limit 2");
assert(res[0].chunk.file == "f1.md", "best match");
print("OK");
' 2>&1 || echo "FAIL")"
[ "$runtime_check" = "OK" ] ||
fail "rag.uc runtime execution failed (saw '$runtime_check')"
printf 'rag embeddings checks passed\n'
+2
View File
@@ -46,5 +46,7 @@ assert_eq binary \
"unknown remote ruleset format"
ucode -L "$TACHYON_LIB" -e 'let rulesets = require("singbox.rulesets"); if (rulesets.kind_from_reference_hint("geoip") != "subnets") exit(1);'
ucode -L "$TACHYON_LIB" -e 'let rulesets = require("singbox.rulesets"); if (type(rulesets.COMMUNITY_SERVICES) != "object" || !rulesets.COMMUNITY_SERVICES.discord) exit(1);'
printf 'singbox rulesets checks passed\n'