mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:39:20 +08:00
Ship folder-based workspaces and data migration, daily practice, redesigned provider and model settings, and streaming conversation improvements. Synchronize README translations and document the archive/permanent-delete upgrade behavior in assets/releases/ver1-6-9.md. Reduce initial JavaScript by deduplicating English resources and loading animation features after hydration. Keep the existing route size budgets. Update regression fixtures and browser audits for scoped URLs and the new settings and learning interfaces.
88 lines
2.5 KiB
TypeScript
88 lines
2.5 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { testGraphRagModelCompatibility } from "../features/knowledge/api/engines";
|
|
import { canApplyGraphRagModelCandidate } from "../lib/graphrag-model-compatibility";
|
|
|
|
test("GraphRAG candidate probe sends catalog IDs without activating the model", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
let requestUrl = "";
|
|
let requestInit: RequestInit | undefined;
|
|
globalThis.fetch = async (input, init) => {
|
|
requestUrl = String(input);
|
|
requestInit = init;
|
|
return new Response(
|
|
JSON.stringify({
|
|
status: "compatible",
|
|
compatible: true,
|
|
code: "graphrag_model_compatible",
|
|
message: "The model returned valid GraphRAG structured output.",
|
|
model: "gpt-4o-mini",
|
|
binding: "openai",
|
|
retryable: false,
|
|
}),
|
|
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await testGraphRagModelCompatibility("profile-a", "model-b");
|
|
|
|
assert.equal(
|
|
requestUrl,
|
|
"/api/knowledge-bases/rag-pipelines/graphrag/model-compatibility?dt_workspace=",
|
|
);
|
|
assert.equal(requestInit?.method, "POST");
|
|
assert.deepEqual(JSON.parse(String(requestInit?.body)), {
|
|
profile_id: "profile-a",
|
|
model_id: "model-b",
|
|
});
|
|
assert.equal(result.status, "compatible");
|
|
assert.equal(result.compatible, true);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("only the exact candidate that passed compatibility can be applied", () => {
|
|
const compatible = {
|
|
status: "compatible" as const,
|
|
compatible: true,
|
|
code: "graphrag_model_compatible",
|
|
message: "ok",
|
|
model: "gpt-4o-mini",
|
|
binding: "openai",
|
|
retryable: false,
|
|
};
|
|
|
|
assert.equal(
|
|
canApplyGraphRagModelCandidate({
|
|
activeKey: "profile-a::model-a",
|
|
candidateKey: "profile-a::model-b",
|
|
testedKey: "profile-a::model-b",
|
|
result: compatible,
|
|
}),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
canApplyGraphRagModelCandidate({
|
|
activeKey: "profile-a::model-a",
|
|
candidateKey: "profile-a::model-c",
|
|
testedKey: "profile-a::model-b",
|
|
result: compatible,
|
|
}),
|
|
false,
|
|
"changing the dropdown must invalidate the previous probe",
|
|
);
|
|
assert.equal(
|
|
canApplyGraphRagModelCandidate({
|
|
activeKey: "profile-a::model-b",
|
|
candidateKey: "profile-a::model-b",
|
|
testedKey: "profile-a::model-b",
|
|
result: compatible,
|
|
}),
|
|
false,
|
|
"the already-active model does not need to be applied again",
|
|
);
|
|
});
|