Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(knowledge): expose LightRAG LLM timeout in engine settings

Bingxi Zhao (Frank)0fa40f1c1395
diff --git a/web/features/knowledge/api/client.ts b/web/features/knowledge/api/client.ts
index 05a9213cb..9f334651d 100644
--- a/web/features/knowledge/api/client.ts
+++ b/web/features/knowledge/api/client.ts
@@ -155,6 +155,8 @@ export interface LightRagConfig {
llm_model_max_async: number;
/** Extra extraction passes per chunk, to recover missed entities. */
entity_extract_max_gleaning: number;
+ /** Per-call timeout for LightRAG's LLM requests, in seconds. */
+ llm_timeout: number;
/** Query model and default indexing selection; empty uses the active chat model. */
llm_profile_id: string;
llm_model_id: string;
diff --git a/web/features/knowledge/components/engines/EngineDetail.tsx b/web/features/knowledge/components/engines/EngineDetail.tsx
index 9977c2e2f..e44329683 100644
--- a/web/features/knowledge/components/engines/EngineDetail.tsx
+++ b/web/features/knowledge/components/engines/EngineDetail.tsx
@@ -1092,6 +1092,7 @@ export function LightRagForm({
response_type: form.response_type,
max_concurrent_files: form.max_concurrent_files,
entity_extract_max_gleaning: form.entity_extract_max_gleaning,
+ llm_timeout: form.llm_timeout,
});
setLoaded(next);
setForm(next);
@@ -1156,6 +1157,14 @@ export function LightRagForm({
max={5}
onChange={(v) => patch({ entity_extract_max_gleaning: v })}
/>
+ <NumberField
+ label={t("LLM timeout (seconds)")}
+ hint={t("Maximum time per LightRAG LLM call")}
+ value={form.llm_timeout}
+ min={60}
+ max={3600}
+ onChange={(v) => patch({ llm_timeout: v })}
+ />
</div>
</div>
diff --git a/web/tests/lightrag-form.spec.tsx b/web/tests/lightrag-form.spec.tsx
index 917f28f8a..75bbee1d7 100644
--- a/web/tests/lightrag-form.spec.tsx
+++ b/web/tests/lightrag-form.spec.tsx
@@ -7,11 +7,15 @@ import {
within,
} from "@testing-library/react";
import { beforeEach, expect, it, vi } from "vitest";
-import { LightRagModelsForm } from "@/features/knowledge/components/engines/EngineDetail";
+import {
+ LightRagForm,
+ LightRagModelsForm,
+} from "@/features/knowledge/components/engines/EngineDetail";
const fixture = vi.hoisted(() => ({
version: 2,
maxAsync: 4,
+ llmTimeout: 240,
profileId: "",
modelId: "",
save: vi.fn(),
@@ -56,6 +60,7 @@ vi.mock("@/features/knowledge/api/engines", async (original) => ({
response_type: "Multiple Paragraphs",
max_concurrent_files: 1,
llm_model_max_async: fixture.maxAsync,
+ llm_timeout: fixture.llmTimeout,
entity_extract_max_gleaning: 1,
}),
updateLightRagConfig: async (value: unknown) => {
@@ -66,11 +71,30 @@ vi.mock("@/features/knowledge/api/engines", async (original) => ({
beforeEach(() => {
fixture.version = 2;
fixture.maxAsync = 4;
+ fixture.llmTimeout = 240;
fixture.profileId = "";
fixture.modelId = "";
fixture.save.mockClear();
});
+it("shows and saves the LightRAG LLM timeout", async () => {
+ render(<LightRagForm onChanged={vi.fn()} onError={vi.fn()} />);
+ const timeout = await screen.findByRole("spinbutton", {
+ name: /^LLM timeout \(seconds\)/,
+ });
+ expect(timeout).toHaveValue(240);
+
+ fireEvent.change(timeout, { target: { value: "480" } });
+ fireEvent.click(screen.getByRole("button", { name: "Save changes" }));
+
+ await waitFor(() => expect(fixture.save).toHaveBeenCalledOnce());
+ expect(fixture.save.mock.calls[0][0]).toMatchObject({
+ llm_timeout: 480,
+ max_concurrent_files: 1,
+ entity_extract_max_gleaning: 1,
+ });
+});
+
it.each([
[2, "disabled"],
[1, "inherit"],