From 7f404bbecb4feae5a034c8acbdc5d85058572dc7 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sat, 23 Aug 2025 02:05:09 +0800 Subject: [PATCH] Update webui assets and bump api version to 0207 --- lightrag/api/__init__.py | 2 +- .../api/webui/assets/{index-B90LgL3h.js => index-B8PWUG__.js} | 2 +- lightrag/api/webui/index.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename lightrag/api/webui/assets/{index-B90LgL3h.js => index-B8PWUG__.js} (93%) diff --git a/lightrag/api/__init__.py b/lightrag/api/__init__.py index d7154027..ac183b60 100644 --- a/lightrag/api/__init__.py +++ b/lightrag/api/__init__.py @@ -1 +1 @@ -__api_version__ = "0206" +__api_version__ = "0207" diff --git a/lightrag/api/webui/assets/index-B90LgL3h.js b/lightrag/api/webui/assets/index-B8PWUG__.js similarity index 93% rename from lightrag/api/webui/assets/index-B90LgL3h.js rename to lightrag/api/webui/assets/index-B8PWUG__.js index c96c2eed..b2f8612b 100644 --- a/lightrag/api/webui/assets/index-B90LgL3h.js +++ b/lightrag/api/webui/assets/index-B8PWUG__.js @@ -28,7 +28,7 @@ You can add a description to the \`${Na}\` by passing a \`${Dd}\` component as a Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Na}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. -For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return E.useEffect(()=>{var d;document.getElementById((d=m.current)==null?void 0:d.getAttribute("aria-describedby"))||console.warn(y)},[y,m]),null},hp=vd,gp=bd,Cd=Sd,Od=Td,_d=Ed,Rd=zd,jd=Ad,Ud=Nd;const pp=hp,yp=gp,Hd=E.forwardRef(({className:m,...y},x)=>o.jsx(Cd,{className:Ve("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",m),...y,ref:x}));Hd.displayName=Cd.displayName;const Ld=E.forwardRef(({className:m,...y},x)=>o.jsxs(yp,{children:[o.jsx(Hd,{}),o.jsx(Od,{ref:x,className:Ve("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",m),...y})]}));Ld.displayName=Od.displayName;const qd=({className:m,...y})=>o.jsx("div",{className:Ve("flex flex-col space-y-2 text-center sm:text-left",m),...y});qd.displayName="AlertDialogHeader";const Bd=E.forwardRef(({className:m,...y},x)=>o.jsx(jd,{ref:x,className:Ve("text-lg font-semibold",m),...y}));Bd.displayName=jd.displayName;const Gd=E.forwardRef(({className:m,...y},x)=>o.jsx(Ud,{ref:x,className:Ve("text-muted-foreground text-sm",m),...y}));Gd.displayName=Ud.displayName;const vp=E.forwardRef(({className:m,...y},x)=>o.jsx(_d,{ref:x,className:Ve(od(),m),...y}));vp.displayName=_d.displayName;const bp=E.forwardRef(({className:m,...y},x)=>o.jsx(Rd,{ref:x,className:Ve(od({variant:"outline"}),"mt-2 sm:mt-0",m),...y}));bp.displayName=Rd.displayName;const Sp=({open:m,onOpenChange:y})=>{const{t:x}=Bl(),d=we.use.apiKey(),[N,_]=E.useState(""),H=sl.use.message();E.useEffect(()=>{_(d||"")},[d,m]),E.useEffect(()=>{H&&(H.includes(rd)||H.includes(fd))&&y(!0)},[H,y]);const P=E.useCallback(()=>{we.setState({apiKey:N||null}),y(!1)},[N,y]),Y=E.useCallback($=>{_($.target.value)},[_]);return o.jsx(pp,{open:m,onOpenChange:y,children:o.jsxs(Ld,{children:[o.jsxs(qd,{children:[o.jsx(Bd,{children:x("apiKeyAlert.title")}),o.jsx(Gd,{children:x("apiKeyAlert.description")})]}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("form",{className:"flex gap-2",onSubmit:$=>$.preventDefault(),children:[o.jsx(us,{type:"password",value:N,onChange:Y,placeholder:x("apiKeyAlert.placeholder"),className:"max-h-full w-full min-w-0",autoComplete:"off"}),o.jsx(Cn,{onClick:P,variant:"outline",size:"sm",children:x("apiKeyAlert.save")})]}),H&&o.jsx("div",{className:"text-sm text-red-500",children:H})]})]})})},Tp=({status:m})=>{const{t:y}=Bl();return m?o.jsxs("div",{className:"min-w-[300px] space-y-2 text-xs",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.serverInfo")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.workingDirectory"),":"]}),o.jsx("span",{className:"truncate",children:m.working_directory}),o.jsxs("span",{children:[y("graphPanel.statusCard.inputDirectory"),":"]}),o.jsx("span",{className:"truncate",children:m.input_directory}),o.jsxs("span",{children:[y("graphPanel.statusCard.summarySettings"),":"]}),o.jsxs("span",{children:[m.configuration.summary_language," / LLM summary on ",m.configuration.force_llm_summary_on_merge.toString()," fragments"]}),o.jsxs("span",{children:[y("graphPanel.statusCard.threshold"),":"]}),o.jsxs("span",{children:["cosine ",m.configuration.cosine_threshold," / rerank_score ",m.configuration.min_rerank_score," / max_related ",m.configuration.related_chunk_number]}),o.jsxs("span",{children:[y("graphPanel.statusCard.maxParallelInsert"),":"]}),o.jsx("span",{children:m.configuration.max_parallel_insert})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.llmConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.llmBindingHost"),":"]}),o.jsx("span",{children:m.configuration.llm_binding_host}),o.jsxs("span",{children:[y("graphPanel.statusCard.llmModel"),":"]}),o.jsxs("span",{children:[m.configuration.llm_binding,": ",m.configuration.llm_model," (#",m.configuration.max_async," Async)"]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.embeddingConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.embeddingBindingHost"),":"]}),o.jsx("span",{children:m.configuration.embedding_binding_host}),o.jsxs("span",{children:[y("graphPanel.statusCard.embeddingModel"),":"]}),o.jsxs("span",{children:[m.configuration.embedding_binding,": ",m.configuration.embedding_model," (#",m.configuration.embedding_func_max_async," Async * ",m.configuration.embedding_batch_num," batches)"]})]})]}),m.configuration.enable_rerank&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.rerankerConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.rerankerBindingHost"),":"]}),o.jsx("span",{children:m.configuration.rerank_binding_host||"-"}),o.jsxs("span",{children:[y("graphPanel.statusCard.rerankerModel"),":"]}),o.jsx("span",{children:m.configuration.rerank_model||"-"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.storageConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.kvStorage"),":"]}),o.jsx("span",{children:m.configuration.kv_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.docStatusStorage"),":"]}),o.jsx("span",{children:m.configuration.doc_status_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.graphStorage"),":"]}),o.jsx("span",{children:m.configuration.graph_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.vectorStorage"),":"]}),o.jsx("span",{children:m.configuration.vector_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.workspace"),":"]}),o.jsx("span",{children:m.configuration.workspace||"-"}),o.jsxs("span",{children:[y("graphPanel.statusCard.maxGraphNodes"),":"]}),o.jsx("span",{children:m.configuration.max_graph_nodes||"-"}),m.keyed_locks&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{children:[y("graphPanel.statusCard.lockStatus"),":"]}),o.jsxs("span",{children:["mp ",m.keyed_locks.current_status.pending_mp_cleanup,"/",m.keyed_locks.current_status.total_mp_locks," | async ",m.keyed_locks.current_status.pending_async_cleanup,"/",m.keyed_locks.current_status.total_async_locks,"(pid: ",m.keyed_locks.process_id,")"]})]})]})]})]}):o.jsx("div",{className:"text-foreground text-xs",children:y("graphPanel.statusCard.unavailable")})},xp=({open:m,onOpenChange:y,status:x})=>{const{t:d}=Bl();return o.jsx(Mg,{open:m,onOpenChange:y,children:o.jsxs(zg,{className:"sm:max-w-[700px]",children:[o.jsxs(Cg,{children:[o.jsx(Og,{children:d("graphPanel.statusDialog.title")}),o.jsx(_g,{children:d("graphPanel.statusDialog.description")})]}),o.jsx(Tp,{status:x})]})})},Ap=()=>{const{t:m}=Bl(),y=sl.use.health(),x=sl.use.lastCheckTime(),d=sl.use.status(),[N,_]=E.useState(!1),[H,P]=E.useState(!1);return E.useEffect(()=>{_(!0);const Y=setTimeout(()=>_(!1),300);return()=>clearTimeout(Y)},[x]),o.jsxs("div",{className:"fixed right-4 bottom-4 flex items-center gap-2 opacity-80 select-none",children:[o.jsxs("div",{className:"flex cursor-pointer items-center gap-2",onClick:()=>P(!0),children:[o.jsx("div",{className:Ve("h-3 w-3 rounded-full transition-all duration-300","shadow-[0_0_8px_rgba(0,0,0,0.2)]",y?"bg-green-500":"bg-red-500",N&&"scale-125",N&&y&&"shadow-[0_0_12px_rgba(34,197,94,0.4)]",N&&!y&&"shadow-[0_0_12px_rgba(239,68,68,0.4)]")}),o.jsx("span",{className:"text-muted-foreground text-xs",children:m(y?"graphPanel.statusIndicator.connected":"graphPanel.statusIndicator.disconnected")})]}),o.jsx(xp,{open:H,onOpenChange:P,status:d})]})};function Yd({className:m}){const[y,x]=E.useState(!1),{t:d}=Bl(),N=we.use.language(),_=we.use.setLanguage(),H=we.use.theme(),P=we.use.setTheme(),Y=E.useCallback(he=>{_(he)},[_]),$=E.useCallback(he=>{P(he)},[P]);return o.jsxs(Rg,{open:y,onOpenChange:x,children:[o.jsx(jg,{asChild:!0,children:o.jsx(Cn,{variant:"ghost",size:"icon",className:Ve("h-9 w-9",m),children:o.jsx(Ug,{className:"h-5 w-5"})})}),o.jsx(Hg,{side:"bottom",align:"end",className:"w-56",children:o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("settings.language")}),o.jsxs(Jf,{value:N,onValueChange:Y,children:[o.jsx(Ff,{children:o.jsx(Pf,{})}),o.jsxs($f,{children:[o.jsx(rt,{value:"en",children:"English"}),o.jsx(rt,{value:"zh",children:"中文"}),o.jsx(rt,{value:"fr",children:"Français"}),o.jsx(rt,{value:"ar",children:"العربية"}),o.jsx(rt,{value:"zh_TW",children:"繁體中文"})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("settings.theme")}),o.jsxs(Jf,{value:H,onValueChange:$,children:[o.jsx(Ff,{children:o.jsx(Pf,{})}),o.jsxs($f,{children:[o.jsx(rt,{value:"light",children:d("settings.light")}),o.jsx(rt,{value:"dark",children:d("settings.dark")}),o.jsx(rt,{value:"system",children:d("settings.system")})]})]})]})]})})]})}const Dp=xg,Xd=E.forwardRef(({className:m,...y},x)=>o.jsx(ud,{ref:x,className:Ve("bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1",m),...y}));Xd.displayName=ud.displayName;const wd=E.forwardRef(({className:m,...y},x)=>o.jsx(id,{ref:x,className:Ve("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm",m),...y}));wd.displayName=id.displayName;const zn=E.forwardRef(({className:m,...y},x)=>o.jsx(cd,{ref:x,className:Ve("ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","data-[state=inactive]:invisible data-[state=active]:visible","h-full w-full",m),forceMount:!0,...y}));zn.displayName=cd.displayName;function Ku({value:m,currentTab:y,children:x}){return o.jsx(wd,{value:m,className:Ve("cursor-pointer px-2 py-1 transition-all",y===m?"!bg-emerald-400 !text-zinc-50":"hover:bg-background/60"),children:x})}function Np(){const m=we.use.currentTab(),{t:y}=Bl();return o.jsx("div",{className:"flex h-8 self-center",children:o.jsxs(Xd,{className:"h-full gap-2",children:[o.jsx(Ku,{value:"documents",currentTab:m,children:y("header.documents")}),o.jsx(Ku,{value:"knowledge-graph",currentTab:m,children:y("header.knowledgeGraph")}),o.jsx(Ku,{value:"retrieval",currentTab:m,children:y("header.retrieval")}),o.jsx(Ku,{value:"api",currentTab:m,children:y("header.api")})]})})}function Ep(){const{t:m}=Bl(),{isGuestMode:y,coreVersion:x,apiVersion:d,username:N,webuiTitle:_,webuiDescription:H}=ql(),P=x&&d?`${x}/${d}`:null,Y=()=>{md.navigateToLogin()};return o.jsxs("header",{className:"border-border/40 bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 flex h-10 w-full border-b px-4 backdrop-blur",children:[o.jsxs("div",{className:"min-w-[200px] w-auto flex items-center",children:[o.jsxs("a",{href:dd,className:"flex items-center gap-2",children:[o.jsx(ss,{className:"size-4 text-emerald-400","aria-hidden":"true"}),o.jsx("span",{className:"font-bold md:inline-block",children:is.name})]}),_&&o.jsxs("div",{className:"flex items-center",children:[o.jsx("span",{className:"mx-1 text-xs text-gray-500 dark:text-gray-400",children:"|"}),o.jsx(Lg,{children:o.jsxs(qg,{children:[o.jsx(Bg,{asChild:!0,children:o.jsx("span",{className:"font-medium text-sm cursor-default",children:_})}),H&&o.jsx(Gg,{side:"bottom",children:H})]})})]})]}),o.jsxs("div",{className:"flex h-10 flex-1 items-center justify-center",children:[o.jsx(Np,{}),y&&o.jsx("div",{className:"ml-2 self-center px-2 py-1 text-xs bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200 rounded-md",children:m("login.guestMode","Guest Mode")})]}),o.jsx("nav",{className:"w-[200px] flex items-center justify-end",children:o.jsxs("div",{className:"flex items-center gap-2",children:[P&&o.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-1",children:["v",P]}),o.jsx(Cn,{variant:"ghost",size:"icon",side:"bottom",tooltip:m("header.projectRepository"),children:o.jsx("a",{href:is.github,target:"_blank",rel:"noopener noreferrer",children:o.jsx(Yg,{className:"size-4","aria-hidden":"true"})})}),o.jsx(Yd,{}),!y&&o.jsx(Cn,{variant:"ghost",size:"icon",side:"bottom",tooltip:`${m("header.logout")} (${N})`,onClick:Y,children:o.jsx(Xg,{className:"size-4","aria-hidden":"true"})})]})})]})}const Mp=()=>{const m=E.useContext(pd);if(!m)throw new Error("useTabVisibility must be used within a TabVisibilityProvider");return m};function zp(){const{t:m}=Bl(),{isTabVisible:y}=Mp(),x=y("api"),[d,N]=E.useState(!1);return E.useEffect(()=>{d||N(!0)},[d]),o.jsx("div",{className:`size-full ${x?"":"hidden"}`,children:d?o.jsx("iframe",{src:wg+"/docs",className:"size-full w-full h-full",style:{width:"100%",height:"100%",border:"none"}},"api-docs-iframe"):o.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-2 h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),o.jsx("p",{children:m("apiSite.loading")})]})})})}function Cp(){const m=sl.use.message(),y=we.use.enableHealthCheck(),x=we.use.currentTab(),[d,N]=E.useState(!1),[_,H]=E.useState(!0),P=E.useRef(!1),Y=E.useRef(!1),$=E.useCallback(V=>{N(V),V||sl.getState().clear()},[]),he=E.useRef(!0);E.useEffect(()=>{he.current=!0;const V=()=>{he.current=!1};return window.addEventListener("beforeunload",V),()=>{he.current=!1,window.removeEventListener("beforeunload",V)}},[]),E.useEffect(()=>{const V=async()=>{try{he.current&&await sl.getState().check()}catch(pe){console.error("Health check error:",pe)}};if(sl.getState().setHealthCheckFunction(V),!y||d){sl.getState().clearHealthCheckTimer();return}return Y.current||(Y.current=!0),sl.getState().resetHealthCheckTimer(),()=>{sl.getState().clearHealthCheckTimer()}},[y,d]),E.useEffect(()=>{(async()=>{if(P.current)return;if(P.current=!0,sessionStorage.getItem("VERSION_CHECKED_FROM_LOGIN")==="true"){H(!1);return}try{H(!0);const ae=localStorage.getItem("LIGHTRAG-API-TOKEN"),C=await gd();if(!C.auth_configured&&C.access_token)ql.getState().login(C.access_token,!0,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null);else if(ae&&(C.core_version||C.api_version||C.webui_title||C.webui_description)){const yl=C.auth_mode==="disabled"||ql.getState().isGuestMode;ql.getState().login(ae,yl,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null)}sessionStorage.setItem("VERSION_CHECKED_FROM_LOGIN","true")}catch(ae){console.error("Failed to get version info:",ae)}finally{H(!1)}})()},[]);const ge=E.useCallback(V=>we.getState().setCurrentTab(V),[]);return E.useEffect(()=>{m&&(m.includes(rd)||m.includes(fd))&&N(!0)},[m]),o.jsx(hd,{children:o.jsx(np,{children:_?o.jsxs("div",{className:"flex h-screen w-screen flex-col",children:[o.jsxs("header",{className:"border-border/40 bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 flex h-10 w-full border-b px-4 backdrop-blur",children:[o.jsx("div",{className:"min-w-[200px] w-auto flex items-center",children:o.jsxs("a",{href:dd,className:"flex items-center gap-2",children:[o.jsx(ss,{className:"size-4 text-emerald-400","aria-hidden":"true"}),o.jsx("span",{className:"font-bold md:inline-block",children:is.name})]})}),o.jsx("div",{className:"flex h-10 flex-1 items-center justify-center"}),o.jsx("nav",{className:"w-[200px] flex items-center justify-end"})]}),o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-2 h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),o.jsx("p",{children:"Initializing..."})]})})]}):o.jsxs("main",{className:"flex h-screen w-screen overflow-hidden",children:[o.jsxs(Dp,{defaultValue:x,className:"!m-0 flex grow flex-col !p-0 overflow-hidden",onValueChange:ge,children:[o.jsx(Ep,{}),o.jsxs("div",{className:"relative grow",children:[o.jsx(zn,{value:"documents",className:"absolute top-0 right-0 bottom-0 left-0 overflow-auto",children:o.jsx(Pg,{})}),o.jsx(zn,{value:"knowledge-graph",className:"absolute top-0 right-0 bottom-0 left-0 overflow-hidden",children:o.jsx(Vg,{})}),o.jsx(zn,{value:"retrieval",className:"absolute top-0 right-0 bottom-0 left-0 overflow-hidden",children:o.jsx($g,{})}),o.jsx(zn,{value:"api",className:"absolute top-0 right-0 bottom-0 left-0 overflow-hidden",children:o.jsx(zp,{})})]})]}),y&&o.jsx(Ap,{}),o.jsx(Sp,{open:d,onOpenChange:$})]})})})}const Op=()=>{const m=sd(),{login:y,isAuthenticated:x}=ql(),{t:d}=Bl(),[N,_]=E.useState(!1),[H,P]=E.useState(""),[Y,$]=E.useState(""),[he,ge]=E.useState(!0),V=E.useRef(!1);if(E.useEffect(()=>{console.log("LoginPage mounted")},[]),E.useEffect(()=>((async()=>{if(!V.current){V.current=!0;try{if(x){m("/");return}const C=await gd();if((C.core_version||C.api_version)&&sessionStorage.setItem("VERSION_CHECKED_FROM_LOGIN","true"),!C.auth_configured&&C.access_token){y(C.access_token,!0,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null),C.message&&En.info(C.message),m("/");return}ge(!1)}catch(C){console.error("Failed to check auth configuration:",C),ge(!1)}}})(),()=>{}),[x,y,m]),he)return null;const pe=async ae=>{if(ae.preventDefault(),!H||!Y){En.error(d("login.errorEmptyFields"));return}try{_(!0);const C=await kg(H,Y);localStorage.getItem("LIGHTRAG-PREVIOUS-USER")===H?console.log("Same user logging in, preserving chat history"):(console.log("Different user logging in, clearing chat history"),we.getState().setRetrievalHistory([])),localStorage.setItem("LIGHTRAG-PREVIOUS-USER",H);const _e=C.auth_mode==="disabled";y(C.access_token,_e,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null),(C.core_version||C.api_version)&&sessionStorage.setItem("VERSION_CHECKED_FROM_LOGIN","true"),_e?En.info(C.message||d("login.authDisabled","Authentication is disabled. Using guest access.")):En.success(d("login.successMessage")),m("/")}catch(C){console.error("Login failed...",C),En.error(d("login.errorInvalidCredentials")),ql.getState().logout(),localStorage.removeItem("LIGHTRAG-API-TOKEN")}finally{_(!1)}};return o.jsxs("div",{className:"flex h-screen w-screen items-center justify-center bg-gradient-to-br from-emerald-50 to-teal-100 dark:from-gray-900 dark:to-gray-800",children:[o.jsx("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:o.jsx(Yd,{className:"bg-white/30 dark:bg-gray-800/30 backdrop-blur-sm rounded-md"})}),o.jsxs(Qg,{className:"w-full max-w-[480px] shadow-lg mx-4",children:[o.jsx(Kg,{className:"flex items-center justify-center space-y-2 pb-8 pt-6",children:o.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:"logo.svg",alt:"LightRAG Logo",className:"h-12 w-12"}),o.jsx(ss,{className:"size-10 text-emerald-400","aria-hidden":"true"})]}),o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"LightRAG"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:d("login.description")})]})]})}),o.jsx(Zg,{className:"px-8 pb-8",children:o.jsxs("form",{onSubmit:pe,className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("label",{htmlFor:"username-input",className:"text-sm font-medium w-16 shrink-0",children:d("login.username")}),o.jsx(us,{id:"username-input",placeholder:d("login.usernamePlaceholder"),value:H,onChange:ae=>P(ae.target.value),required:!0,className:"h-11 flex-1"})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("label",{htmlFor:"password-input",className:"text-sm font-medium w-16 shrink-0",children:d("login.password")}),o.jsx(us,{id:"password-input",type:"password",placeholder:d("login.passwordPlaceholder"),value:Y,onChange:ae=>$(ae.target.value),required:!0,className:"h-11 flex-1"})]}),o.jsx(Cn,{type:"submit",className:"w-full h-11 text-base font-medium mt-2",disabled:N,children:d(N?"login.loggingIn":"login.loginButton")})]})})]})]})},_p=()=>{const[m,y]=E.useState(!0),{isAuthenticated:x}=ql(),d=sd();return E.useEffect(()=>{md.setNavigate(d)},[d]),E.useEffect(()=>((async()=>{try{const _=localStorage.getItem("LIGHTRAG-API-TOKEN");if(_&&x){y(!1);return}_||ql.getState().logout()}catch(_){console.error("Auth initialization error:",_),x||ql.getState().logout()}finally{y(!1)}})(),()=>{}),[x]),E.useEffect(()=>{!m&&!x&&window.location.hash.slice(1)!=="/login"&&(console.log("Not authenticated, redirecting to login"),d("/login"))},[m,x,d]),m?null:o.jsxs(Eg,{children:[o.jsx(kf,{path:"/login",element:o.jsx(Op,{})}),o.jsx(kf,{path:"/*",element:x?o.jsx(Cp,{}):null})]})},Rp=()=>o.jsx(hd,{children:o.jsxs(Ng,{children:[o.jsx(_p,{}),o.jsx(Jg,{position:"bottom-center",theme:"system",closeButton:!0,richColors:!0})]})}),jp={language:"Language",theme:"Theme",light:"Light",dark:"Dark",system:"System"},Up={documents:"Documents",knowledgeGraph:"Knowledge Graph",retrieval:"Retrieval",api:"API",projectRepository:"Project Repository",logout:"Logout",themeToggle:{switchToLight:"Switch to light theme",switchToDark:"Switch to dark theme"}},Hp={description:"Please enter your account and password to log in to the system",username:"Username",usernamePlaceholder:"Please input a username",password:"Password",passwordPlaceholder:"Please input a password",loginButton:"Login",loggingIn:"Logging in...",successMessage:"Login succeeded",errorEmptyFields:"Please enter your username and password",errorInvalidCredentials:"Login failed, please check username and password",authDisabled:"Authentication is disabled. Using login free mode.",guestMode:"Login Free"},Lp={cancel:"Cancel",save:"Save",saving:"Saving...",saveFailed:"Save failed"},qp={clearDocuments:{button:"Clear",tooltip:"Clear documents",title:"Clear Documents",description:"This will remove all documents from the system",warning:"WARNING: This action will permanently delete all documents and cannot be undone!",confirm:"Do you really want to clear all documents?",confirmPrompt:"Type 'yes' to confirm this action",confirmPlaceholder:"Type yes to confirm",clearCache:"Clear LLM cache",confirmButton:"YES",clearing:"Clearing...",timeout:"Clear operation timed out, please try again",success:"Documents cleared successfully",cacheCleared:"Cache cleared successfully",cacheClearFailed:`Failed to clear cache: +For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return E.useEffect(()=>{var d;document.getElementById((d=m.current)==null?void 0:d.getAttribute("aria-describedby"))||console.warn(y)},[y,m]),null},hp=vd,gp=bd,Cd=Sd,Od=Td,_d=Ed,Rd=zd,jd=Ad,Ud=Nd;const pp=hp,yp=gp,Hd=E.forwardRef(({className:m,...y},x)=>o.jsx(Cd,{className:Ve("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",m),...y,ref:x}));Hd.displayName=Cd.displayName;const Ld=E.forwardRef(({className:m,...y},x)=>o.jsxs(yp,{children:[o.jsx(Hd,{}),o.jsx(Od,{ref:x,className:Ve("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",m),...y})]}));Ld.displayName=Od.displayName;const qd=({className:m,...y})=>o.jsx("div",{className:Ve("flex flex-col space-y-2 text-center sm:text-left",m),...y});qd.displayName="AlertDialogHeader";const Bd=E.forwardRef(({className:m,...y},x)=>o.jsx(jd,{ref:x,className:Ve("text-lg font-semibold",m),...y}));Bd.displayName=jd.displayName;const Gd=E.forwardRef(({className:m,...y},x)=>o.jsx(Ud,{ref:x,className:Ve("text-muted-foreground text-sm",m),...y}));Gd.displayName=Ud.displayName;const vp=E.forwardRef(({className:m,...y},x)=>o.jsx(_d,{ref:x,className:Ve(od(),m),...y}));vp.displayName=_d.displayName;const bp=E.forwardRef(({className:m,...y},x)=>o.jsx(Rd,{ref:x,className:Ve(od({variant:"outline"}),"mt-2 sm:mt-0",m),...y}));bp.displayName=Rd.displayName;const Sp=({open:m,onOpenChange:y})=>{const{t:x}=Bl(),d=we.use.apiKey(),[N,_]=E.useState(""),H=sl.use.message();E.useEffect(()=>{_(d||"")},[d,m]),E.useEffect(()=>{H&&(H.includes(rd)||H.includes(fd))&&y(!0)},[H,y]);const P=E.useCallback(()=>{we.setState({apiKey:N||null}),y(!1)},[N,y]),Y=E.useCallback($=>{_($.target.value)},[_]);return o.jsx(pp,{open:m,onOpenChange:y,children:o.jsxs(Ld,{children:[o.jsxs(qd,{children:[o.jsx(Bd,{children:x("apiKeyAlert.title")}),o.jsx(Gd,{children:x("apiKeyAlert.description")})]}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("form",{className:"flex gap-2",onSubmit:$=>$.preventDefault(),children:[o.jsx(us,{type:"password",value:N,onChange:Y,placeholder:x("apiKeyAlert.placeholder"),className:"max-h-full w-full min-w-0",autoComplete:"off"}),o.jsx(Cn,{onClick:P,variant:"outline",size:"sm",children:x("apiKeyAlert.save")})]}),H&&o.jsx("div",{className:"text-sm text-red-500",children:H})]})]})})},Tp=({status:m})=>{const{t:y}=Bl();return m?o.jsxs("div",{className:"min-w-[300px] space-y-2 text-xs",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.serverInfo")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.workingDirectory"),":"]}),o.jsx("span",{className:"truncate",children:m.working_directory}),o.jsxs("span",{children:[y("graphPanel.statusCard.inputDirectory"),":"]}),o.jsx("span",{className:"truncate",children:m.input_directory}),o.jsxs("span",{children:[y("graphPanel.statusCard.summarySettings"),":"]}),o.jsxs("span",{children:[m.configuration.summary_language," / LLM summary on ",m.configuration.force_llm_summary_on_merge.toString()," fragments"]}),o.jsxs("span",{children:[y("graphPanel.statusCard.threshold"),":"]}),o.jsxs("span",{children:["cosine ",m.configuration.cosine_threshold," / rerank_score ",m.configuration.min_rerank_score," / max_related ",m.configuration.related_chunk_number]}),o.jsxs("span",{children:[y("graphPanel.statusCard.maxParallelInsert"),":"]}),o.jsx("span",{children:m.configuration.max_parallel_insert})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.llmConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.llmBindingHost"),":"]}),o.jsx("span",{children:m.configuration.llm_binding_host}),o.jsxs("span",{children:[y("graphPanel.statusCard.llmModel"),":"]}),o.jsxs("span",{children:[m.configuration.llm_binding,": ",m.configuration.llm_model," (#",m.configuration.max_async," Async)"]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.embeddingConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.embeddingBindingHost"),":"]}),o.jsx("span",{children:m.configuration.embedding_binding_host}),o.jsxs("span",{children:[y("graphPanel.statusCard.embeddingModel"),":"]}),o.jsxs("span",{children:[m.configuration.embedding_binding,": ",m.configuration.embedding_model," (#",m.configuration.embedding_func_max_async," Async * ",m.configuration.embedding_batch_num," batches)"]})]})]}),m.configuration.enable_rerank&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.rerankerConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.rerankerBindingHost"),":"]}),o.jsx("span",{children:m.configuration.rerank_binding_host||"-"}),o.jsxs("span",{children:[y("graphPanel.statusCard.rerankerModel"),":"]}),o.jsxs("span",{children:[m.configuration.rerank_binding||"-"," : ",m.configuration.rerank_model||"-"]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"font-medium",children:y("graphPanel.statusCard.storageConfig")}),o.jsxs("div",{className:"text-foreground grid grid-cols-[160px_1fr] gap-1",children:[o.jsxs("span",{children:[y("graphPanel.statusCard.kvStorage"),":"]}),o.jsx("span",{children:m.configuration.kv_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.docStatusStorage"),":"]}),o.jsx("span",{children:m.configuration.doc_status_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.graphStorage"),":"]}),o.jsx("span",{children:m.configuration.graph_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.vectorStorage"),":"]}),o.jsx("span",{children:m.configuration.vector_storage}),o.jsxs("span",{children:[y("graphPanel.statusCard.workspace"),":"]}),o.jsx("span",{children:m.configuration.workspace||"-"}),o.jsxs("span",{children:[y("graphPanel.statusCard.maxGraphNodes"),":"]}),o.jsx("span",{children:m.configuration.max_graph_nodes||"-"}),m.keyed_locks&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{children:[y("graphPanel.statusCard.lockStatus"),":"]}),o.jsxs("span",{children:["mp ",m.keyed_locks.current_status.pending_mp_cleanup,"/",m.keyed_locks.current_status.total_mp_locks," | async ",m.keyed_locks.current_status.pending_async_cleanup,"/",m.keyed_locks.current_status.total_async_locks,"(pid: ",m.keyed_locks.process_id,")"]})]})]})]})]}):o.jsx("div",{className:"text-foreground text-xs",children:y("graphPanel.statusCard.unavailable")})},xp=({open:m,onOpenChange:y,status:x})=>{const{t:d}=Bl();return o.jsx(Mg,{open:m,onOpenChange:y,children:o.jsxs(zg,{className:"sm:max-w-[700px]",children:[o.jsxs(Cg,{children:[o.jsx(Og,{children:d("graphPanel.statusDialog.title")}),o.jsx(_g,{children:d("graphPanel.statusDialog.description")})]}),o.jsx(Tp,{status:x})]})})},Ap=()=>{const{t:m}=Bl(),y=sl.use.health(),x=sl.use.lastCheckTime(),d=sl.use.status(),[N,_]=E.useState(!1),[H,P]=E.useState(!1);return E.useEffect(()=>{_(!0);const Y=setTimeout(()=>_(!1),300);return()=>clearTimeout(Y)},[x]),o.jsxs("div",{className:"fixed right-4 bottom-4 flex items-center gap-2 opacity-80 select-none",children:[o.jsxs("div",{className:"flex cursor-pointer items-center gap-2",onClick:()=>P(!0),children:[o.jsx("div",{className:Ve("h-3 w-3 rounded-full transition-all duration-300","shadow-[0_0_8px_rgba(0,0,0,0.2)]",y?"bg-green-500":"bg-red-500",N&&"scale-125",N&&y&&"shadow-[0_0_12px_rgba(34,197,94,0.4)]",N&&!y&&"shadow-[0_0_12px_rgba(239,68,68,0.4)]")}),o.jsx("span",{className:"text-muted-foreground text-xs",children:m(y?"graphPanel.statusIndicator.connected":"graphPanel.statusIndicator.disconnected")})]}),o.jsx(xp,{open:H,onOpenChange:P,status:d})]})};function Yd({className:m}){const[y,x]=E.useState(!1),{t:d}=Bl(),N=we.use.language(),_=we.use.setLanguage(),H=we.use.theme(),P=we.use.setTheme(),Y=E.useCallback(he=>{_(he)},[_]),$=E.useCallback(he=>{P(he)},[P]);return o.jsxs(Rg,{open:y,onOpenChange:x,children:[o.jsx(jg,{asChild:!0,children:o.jsx(Cn,{variant:"ghost",size:"icon",className:Ve("h-9 w-9",m),children:o.jsx(Ug,{className:"h-5 w-5"})})}),o.jsx(Hg,{side:"bottom",align:"end",className:"w-56",children:o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("settings.language")}),o.jsxs(Jf,{value:N,onValueChange:Y,children:[o.jsx(Ff,{children:o.jsx(Pf,{})}),o.jsxs($f,{children:[o.jsx(rt,{value:"en",children:"English"}),o.jsx(rt,{value:"zh",children:"中文"}),o.jsx(rt,{value:"fr",children:"Français"}),o.jsx(rt,{value:"ar",children:"العربية"}),o.jsx(rt,{value:"zh_TW",children:"繁體中文"})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("settings.theme")}),o.jsxs(Jf,{value:H,onValueChange:$,children:[o.jsx(Ff,{children:o.jsx(Pf,{})}),o.jsxs($f,{children:[o.jsx(rt,{value:"light",children:d("settings.light")}),o.jsx(rt,{value:"dark",children:d("settings.dark")}),o.jsx(rt,{value:"system",children:d("settings.system")})]})]})]})]})})]})}const Dp=xg,Xd=E.forwardRef(({className:m,...y},x)=>o.jsx(ud,{ref:x,className:Ve("bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1",m),...y}));Xd.displayName=ud.displayName;const wd=E.forwardRef(({className:m,...y},x)=>o.jsx(id,{ref:x,className:Ve("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm",m),...y}));wd.displayName=id.displayName;const zn=E.forwardRef(({className:m,...y},x)=>o.jsx(cd,{ref:x,className:Ve("ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","data-[state=inactive]:invisible data-[state=active]:visible","h-full w-full",m),forceMount:!0,...y}));zn.displayName=cd.displayName;function Ku({value:m,currentTab:y,children:x}){return o.jsx(wd,{value:m,className:Ve("cursor-pointer px-2 py-1 transition-all",y===m?"!bg-emerald-400 !text-zinc-50":"hover:bg-background/60"),children:x})}function Np(){const m=we.use.currentTab(),{t:y}=Bl();return o.jsx("div",{className:"flex h-8 self-center",children:o.jsxs(Xd,{className:"h-full gap-2",children:[o.jsx(Ku,{value:"documents",currentTab:m,children:y("header.documents")}),o.jsx(Ku,{value:"knowledge-graph",currentTab:m,children:y("header.knowledgeGraph")}),o.jsx(Ku,{value:"retrieval",currentTab:m,children:y("header.retrieval")}),o.jsx(Ku,{value:"api",currentTab:m,children:y("header.api")})]})})}function Ep(){const{t:m}=Bl(),{isGuestMode:y,coreVersion:x,apiVersion:d,username:N,webuiTitle:_,webuiDescription:H}=ql(),P=x&&d?`${x}/${d}`:null,Y=()=>{md.navigateToLogin()};return o.jsxs("header",{className:"border-border/40 bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 flex h-10 w-full border-b px-4 backdrop-blur",children:[o.jsxs("div",{className:"min-w-[200px] w-auto flex items-center",children:[o.jsxs("a",{href:dd,className:"flex items-center gap-2",children:[o.jsx(ss,{className:"size-4 text-emerald-400","aria-hidden":"true"}),o.jsx("span",{className:"font-bold md:inline-block",children:is.name})]}),_&&o.jsxs("div",{className:"flex items-center",children:[o.jsx("span",{className:"mx-1 text-xs text-gray-500 dark:text-gray-400",children:"|"}),o.jsx(Lg,{children:o.jsxs(qg,{children:[o.jsx(Bg,{asChild:!0,children:o.jsx("span",{className:"font-medium text-sm cursor-default",children:_})}),H&&o.jsx(Gg,{side:"bottom",children:H})]})})]})]}),o.jsxs("div",{className:"flex h-10 flex-1 items-center justify-center",children:[o.jsx(Np,{}),y&&o.jsx("div",{className:"ml-2 self-center px-2 py-1 text-xs bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200 rounded-md",children:m("login.guestMode","Guest Mode")})]}),o.jsx("nav",{className:"w-[200px] flex items-center justify-end",children:o.jsxs("div",{className:"flex items-center gap-2",children:[P&&o.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-1",children:["v",P]}),o.jsx(Cn,{variant:"ghost",size:"icon",side:"bottom",tooltip:m("header.projectRepository"),children:o.jsx("a",{href:is.github,target:"_blank",rel:"noopener noreferrer",children:o.jsx(Yg,{className:"size-4","aria-hidden":"true"})})}),o.jsx(Yd,{}),!y&&o.jsx(Cn,{variant:"ghost",size:"icon",side:"bottom",tooltip:`${m("header.logout")} (${N})`,onClick:Y,children:o.jsx(Xg,{className:"size-4","aria-hidden":"true"})})]})})]})}const Mp=()=>{const m=E.useContext(pd);if(!m)throw new Error("useTabVisibility must be used within a TabVisibilityProvider");return m};function zp(){const{t:m}=Bl(),{isTabVisible:y}=Mp(),x=y("api"),[d,N]=E.useState(!1);return E.useEffect(()=>{d||N(!0)},[d]),o.jsx("div",{className:`size-full ${x?"":"hidden"}`,children:d?o.jsx("iframe",{src:wg+"/docs",className:"size-full w-full h-full",style:{width:"100%",height:"100%",border:"none"}},"api-docs-iframe"):o.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-2 h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),o.jsx("p",{children:m("apiSite.loading")})]})})})}function Cp(){const m=sl.use.message(),y=we.use.enableHealthCheck(),x=we.use.currentTab(),[d,N]=E.useState(!1),[_,H]=E.useState(!0),P=E.useRef(!1),Y=E.useRef(!1),$=E.useCallback(V=>{N(V),V||sl.getState().clear()},[]),he=E.useRef(!0);E.useEffect(()=>{he.current=!0;const V=()=>{he.current=!1};return window.addEventListener("beforeunload",V),()=>{he.current=!1,window.removeEventListener("beforeunload",V)}},[]),E.useEffect(()=>{const V=async()=>{try{he.current&&await sl.getState().check()}catch(pe){console.error("Health check error:",pe)}};if(sl.getState().setHealthCheckFunction(V),!y||d){sl.getState().clearHealthCheckTimer();return}return Y.current||(Y.current=!0),sl.getState().resetHealthCheckTimer(),()=>{sl.getState().clearHealthCheckTimer()}},[y,d]),E.useEffect(()=>{(async()=>{if(P.current)return;if(P.current=!0,sessionStorage.getItem("VERSION_CHECKED_FROM_LOGIN")==="true"){H(!1);return}try{H(!0);const ae=localStorage.getItem("LIGHTRAG-API-TOKEN"),C=await gd();if(!C.auth_configured&&C.access_token)ql.getState().login(C.access_token,!0,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null);else if(ae&&(C.core_version||C.api_version||C.webui_title||C.webui_description)){const yl=C.auth_mode==="disabled"||ql.getState().isGuestMode;ql.getState().login(ae,yl,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null)}sessionStorage.setItem("VERSION_CHECKED_FROM_LOGIN","true")}catch(ae){console.error("Failed to get version info:",ae)}finally{H(!1)}})()},[]);const ge=E.useCallback(V=>we.getState().setCurrentTab(V),[]);return E.useEffect(()=>{m&&(m.includes(rd)||m.includes(fd))&&N(!0)},[m]),o.jsx(hd,{children:o.jsx(np,{children:_?o.jsxs("div",{className:"flex h-screen w-screen flex-col",children:[o.jsxs("header",{className:"border-border/40 bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 flex h-10 w-full border-b px-4 backdrop-blur",children:[o.jsx("div",{className:"min-w-[200px] w-auto flex items-center",children:o.jsxs("a",{href:dd,className:"flex items-center gap-2",children:[o.jsx(ss,{className:"size-4 text-emerald-400","aria-hidden":"true"}),o.jsx("span",{className:"font-bold md:inline-block",children:is.name})]})}),o.jsx("div",{className:"flex h-10 flex-1 items-center justify-center"}),o.jsx("nav",{className:"w-[200px] flex items-center justify-end"})]}),o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-2 h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),o.jsx("p",{children:"Initializing..."})]})})]}):o.jsxs("main",{className:"flex h-screen w-screen overflow-hidden",children:[o.jsxs(Dp,{defaultValue:x,className:"!m-0 flex grow flex-col !p-0 overflow-hidden",onValueChange:ge,children:[o.jsx(Ep,{}),o.jsxs("div",{className:"relative grow",children:[o.jsx(zn,{value:"documents",className:"absolute top-0 right-0 bottom-0 left-0 overflow-auto",children:o.jsx(Pg,{})}),o.jsx(zn,{value:"knowledge-graph",className:"absolute top-0 right-0 bottom-0 left-0 overflow-hidden",children:o.jsx(Vg,{})}),o.jsx(zn,{value:"retrieval",className:"absolute top-0 right-0 bottom-0 left-0 overflow-hidden",children:o.jsx($g,{})}),o.jsx(zn,{value:"api",className:"absolute top-0 right-0 bottom-0 left-0 overflow-hidden",children:o.jsx(zp,{})})]})]}),y&&o.jsx(Ap,{}),o.jsx(Sp,{open:d,onOpenChange:$})]})})})}const Op=()=>{const m=sd(),{login:y,isAuthenticated:x}=ql(),{t:d}=Bl(),[N,_]=E.useState(!1),[H,P]=E.useState(""),[Y,$]=E.useState(""),[he,ge]=E.useState(!0),V=E.useRef(!1);if(E.useEffect(()=>{console.log("LoginPage mounted")},[]),E.useEffect(()=>((async()=>{if(!V.current){V.current=!0;try{if(x){m("/");return}const C=await gd();if((C.core_version||C.api_version)&&sessionStorage.setItem("VERSION_CHECKED_FROM_LOGIN","true"),!C.auth_configured&&C.access_token){y(C.access_token,!0,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null),C.message&&En.info(C.message),m("/");return}ge(!1)}catch(C){console.error("Failed to check auth configuration:",C),ge(!1)}}})(),()=>{}),[x,y,m]),he)return null;const pe=async ae=>{if(ae.preventDefault(),!H||!Y){En.error(d("login.errorEmptyFields"));return}try{_(!0);const C=await kg(H,Y);localStorage.getItem("LIGHTRAG-PREVIOUS-USER")===H?console.log("Same user logging in, preserving chat history"):(console.log("Different user logging in, clearing chat history"),we.getState().setRetrievalHistory([])),localStorage.setItem("LIGHTRAG-PREVIOUS-USER",H);const _e=C.auth_mode==="disabled";y(C.access_token,_e,C.core_version,C.api_version,C.webui_title||null,C.webui_description||null),(C.core_version||C.api_version)&&sessionStorage.setItem("VERSION_CHECKED_FROM_LOGIN","true"),_e?En.info(C.message||d("login.authDisabled","Authentication is disabled. Using guest access.")):En.success(d("login.successMessage")),m("/")}catch(C){console.error("Login failed...",C),En.error(d("login.errorInvalidCredentials")),ql.getState().logout(),localStorage.removeItem("LIGHTRAG-API-TOKEN")}finally{_(!1)}};return o.jsxs("div",{className:"flex h-screen w-screen items-center justify-center bg-gradient-to-br from-emerald-50 to-teal-100 dark:from-gray-900 dark:to-gray-800",children:[o.jsx("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:o.jsx(Yd,{className:"bg-white/30 dark:bg-gray-800/30 backdrop-blur-sm rounded-md"})}),o.jsxs(Qg,{className:"w-full max-w-[480px] shadow-lg mx-4",children:[o.jsx(Kg,{className:"flex items-center justify-center space-y-2 pb-8 pt-6",children:o.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:"logo.svg",alt:"LightRAG Logo",className:"h-12 w-12"}),o.jsx(ss,{className:"size-10 text-emerald-400","aria-hidden":"true"})]}),o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"LightRAG"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:d("login.description")})]})]})}),o.jsx(Zg,{className:"px-8 pb-8",children:o.jsxs("form",{onSubmit:pe,className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("label",{htmlFor:"username-input",className:"text-sm font-medium w-16 shrink-0",children:d("login.username")}),o.jsx(us,{id:"username-input",placeholder:d("login.usernamePlaceholder"),value:H,onChange:ae=>P(ae.target.value),required:!0,className:"h-11 flex-1"})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("label",{htmlFor:"password-input",className:"text-sm font-medium w-16 shrink-0",children:d("login.password")}),o.jsx(us,{id:"password-input",type:"password",placeholder:d("login.passwordPlaceholder"),value:Y,onChange:ae=>$(ae.target.value),required:!0,className:"h-11 flex-1"})]}),o.jsx(Cn,{type:"submit",className:"w-full h-11 text-base font-medium mt-2",disabled:N,children:d(N?"login.loggingIn":"login.loginButton")})]})})]})]})},_p=()=>{const[m,y]=E.useState(!0),{isAuthenticated:x}=ql(),d=sd();return E.useEffect(()=>{md.setNavigate(d)},[d]),E.useEffect(()=>((async()=>{try{const _=localStorage.getItem("LIGHTRAG-API-TOKEN");if(_&&x){y(!1);return}_||ql.getState().logout()}catch(_){console.error("Auth initialization error:",_),x||ql.getState().logout()}finally{y(!1)}})(),()=>{}),[x]),E.useEffect(()=>{!m&&!x&&window.location.hash.slice(1)!=="/login"&&(console.log("Not authenticated, redirecting to login"),d("/login"))},[m,x,d]),m?null:o.jsxs(Eg,{children:[o.jsx(kf,{path:"/login",element:o.jsx(Op,{})}),o.jsx(kf,{path:"/*",element:x?o.jsx(Cp,{}):null})]})},Rp=()=>o.jsx(hd,{children:o.jsxs(Ng,{children:[o.jsx(_p,{}),o.jsx(Jg,{position:"bottom-center",theme:"system",closeButton:!0,richColors:!0})]})}),jp={language:"Language",theme:"Theme",light:"Light",dark:"Dark",system:"System"},Up={documents:"Documents",knowledgeGraph:"Knowledge Graph",retrieval:"Retrieval",api:"API",projectRepository:"Project Repository",logout:"Logout",themeToggle:{switchToLight:"Switch to light theme",switchToDark:"Switch to dark theme"}},Hp={description:"Please enter your account and password to log in to the system",username:"Username",usernamePlaceholder:"Please input a username",password:"Password",passwordPlaceholder:"Please input a password",loginButton:"Login",loggingIn:"Logging in...",successMessage:"Login succeeded",errorEmptyFields:"Please enter your username and password",errorInvalidCredentials:"Login failed, please check username and password",authDisabled:"Authentication is disabled. Using login free mode.",guestMode:"Login Free"},Lp={cancel:"Cancel",save:"Save",saving:"Saving...",saveFailed:"Save failed"},qp={clearDocuments:{button:"Clear",tooltip:"Clear documents",title:"Clear Documents",description:"This will remove all documents from the system",warning:"WARNING: This action will permanently delete all documents and cannot be undone!",confirm:"Do you really want to clear all documents?",confirmPrompt:"Type 'yes' to confirm this action",confirmPlaceholder:"Type yes to confirm",clearCache:"Clear LLM cache",confirmButton:"YES",clearing:"Clearing...",timeout:"Clear operation timed out, please try again",success:"Documents cleared successfully",cacheCleared:"Cache cleared successfully",cacheClearFailed:`Failed to clear cache: {{error}}`,failed:`Clear Documents Failed: {{message}}`,error:`Clear Documents Failed: {{error}}`},deleteDocuments:{button:"Delete",tooltip:"Delete selected documents",title:"Delete Documents",description:"This will permanently delete the selected documents from the system",warning:"WARNING: This action will permanently delete the selected documents and cannot be undone!",confirm:"Do you really want to delete {{count}} selected document(s)?",confirmPrompt:"Type 'yes' to confirm this action",confirmPlaceholder:"Type yes to confirm",confirmButton:"YES",deleteFileOption:"Also delete uploaded files",deleteFileTooltip:"Check this option to also delete the corresponding uploaded files on the server",success:"Document deletion pipeline started successfully",failed:`Delete Documents Failed: diff --git a/lightrag/api/webui/index.html b/lightrag/api/webui/index.html index 7499ac50..8a30cd59 100644 --- a/lightrag/api/webui/index.html +++ b/lightrag/api/webui/index.html @@ -8,7 +8,7 @@ Lightrag - +