yangdx
commited on
Commit
·
a845c0d
1
Parent(s):
f510afe
Fix linting
Browse files
lightrag/api/lightrag_server.py
CHANGED
@@ -439,7 +439,7 @@ def create_app(args):
|
|
439 |
},
|
440 |
"update_status": update_status,
|
441 |
"core_version": core_version,
|
442 |
-
"api_version": __api_version__
|
443 |
}
|
444 |
|
445 |
# Custom StaticFiles class to prevent caching of HTML files
|
|
|
439 |
},
|
440 |
"update_status": update_status,
|
441 |
"core_version": core_version,
|
442 |
+
"api_version": __api_version__,
|
443 |
}
|
444 |
|
445 |
# Custom StaticFiles class to prevent caching of HTML files
|
lightrag_webui/src/App.tsx
CHANGED
@@ -29,15 +29,15 @@ function App() {
|
|
29 |
useEffect(() => {
|
30 |
// Only execute if health check is enabled
|
31 |
if (!enableHealthCheck) return;
|
32 |
-
|
33 |
// Health check function
|
34 |
const performHealthCheck = async () => {
|
35 |
await useBackendState.getState().check();
|
36 |
};
|
37 |
-
|
38 |
// Execute immediately
|
39 |
performHealthCheck();
|
40 |
-
|
41 |
// Set interval for periodic execution
|
42 |
const interval = setInterval(performHealthCheck, healthCheckInterval * 1000);
|
43 |
return () => clearInterval(interval);
|
@@ -49,26 +49,26 @@ function App() {
|
|
49 |
// Prevent duplicate calls in Vite dev mode
|
50 |
if (versionCheckRef.current) return;
|
51 |
versionCheckRef.current = true;
|
52 |
-
|
53 |
// Check if version info was already obtained in login page
|
54 |
const versionCheckedFromLogin = sessionStorage.getItem('VERSION_CHECKED_FROM_LOGIN') === 'true';
|
55 |
if (versionCheckedFromLogin) return;
|
56 |
-
|
57 |
// Get version info
|
58 |
const token = localStorage.getItem('LIGHTRAG-API-TOKEN');
|
59 |
if (!token) return;
|
60 |
-
|
61 |
try {
|
62 |
const status = await getAuthStatus();
|
63 |
if (status.core_version || status.api_version) {
|
64 |
// Update version info while maintaining login state
|
65 |
useAuthStore.getState().login(
|
66 |
-
token,
|
67 |
-
useAuthStore.getState().isGuestMode,
|
68 |
-
status.core_version,
|
69 |
status.api_version
|
70 |
);
|
71 |
-
|
72 |
// Set flag to indicate version info has been checked
|
73 |
sessionStorage.setItem('VERSION_CHECKED_FROM_LOGIN', 'true');
|
74 |
}
|
@@ -76,7 +76,7 @@ function App() {
|
|
76 |
console.error('Failed to get version info:', error);
|
77 |
}
|
78 |
};
|
79 |
-
|
80 |
// Execute version check
|
81 |
checkVersion();
|
82 |
}, []); // Empty dependency array ensures it only runs once on mount
|
|
|
29 |
useEffect(() => {
|
30 |
// Only execute if health check is enabled
|
31 |
if (!enableHealthCheck) return;
|
32 |
+
|
33 |
// Health check function
|
34 |
const performHealthCheck = async () => {
|
35 |
await useBackendState.getState().check();
|
36 |
};
|
37 |
+
|
38 |
// Execute immediately
|
39 |
performHealthCheck();
|
40 |
+
|
41 |
// Set interval for periodic execution
|
42 |
const interval = setInterval(performHealthCheck, healthCheckInterval * 1000);
|
43 |
return () => clearInterval(interval);
|
|
|
49 |
// Prevent duplicate calls in Vite dev mode
|
50 |
if (versionCheckRef.current) return;
|
51 |
versionCheckRef.current = true;
|
52 |
+
|
53 |
// Check if version info was already obtained in login page
|
54 |
const versionCheckedFromLogin = sessionStorage.getItem('VERSION_CHECKED_FROM_LOGIN') === 'true';
|
55 |
if (versionCheckedFromLogin) return;
|
56 |
+
|
57 |
// Get version info
|
58 |
const token = localStorage.getItem('LIGHTRAG-API-TOKEN');
|
59 |
if (!token) return;
|
60 |
+
|
61 |
try {
|
62 |
const status = await getAuthStatus();
|
63 |
if (status.core_version || status.api_version) {
|
64 |
// Update version info while maintaining login state
|
65 |
useAuthStore.getState().login(
|
66 |
+
token,
|
67 |
+
useAuthStore.getState().isGuestMode,
|
68 |
+
status.core_version,
|
69 |
status.api_version
|
70 |
);
|
71 |
+
|
72 |
// Set flag to indicate version info has been checked
|
73 |
sessionStorage.setItem('VERSION_CHECKED_FROM_LOGIN', 'true');
|
74 |
}
|
|
|
76 |
console.error('Failed to get version info:', error);
|
77 |
}
|
78 |
};
|
79 |
+
|
80 |
// Execute version check
|
81 |
checkVersion();
|
82 |
}, []); // Empty dependency array ensures it only runs once on mount
|
lightrag_webui/src/features/LoginPage.tsx
CHANGED
@@ -35,7 +35,7 @@ const LoginPage = () => {
|
|
35 |
return;
|
36 |
}
|
37 |
authCheckRef.current = true;
|
38 |
-
|
39 |
try {
|
40 |
// If already authenticated, redirect to home
|
41 |
if (isAuthenticated) {
|
@@ -45,13 +45,13 @@ const LoginPage = () => {
|
|
45 |
|
46 |
// Check auth status
|
47 |
const status = await getAuthStatus()
|
48 |
-
|
49 |
// Set checkingAuth to false immediately after getAuthStatus
|
50 |
// This allows the login page to render while other processing continues
|
51 |
if (isMounted) {
|
52 |
setCheckingAuth(false);
|
53 |
}
|
54 |
-
|
55 |
// Set session flag for version check to avoid duplicate checks in App component
|
56 |
if (isMounted && (status.core_version || status.api_version)) {
|
57 |
sessionStorage.setItem('VERSION_CHECKED_FROM_LOGIN', 'true');
|
@@ -107,7 +107,7 @@ const LoginPage = () => {
|
|
107 |
// Check authentication mode
|
108 |
const isGuestMode = response.auth_mode === 'disabled'
|
109 |
login(response.access_token, isGuestMode, response.core_version, response.api_version)
|
110 |
-
|
111 |
// Set session flag for version check
|
112 |
if (response.core_version || response.api_version) {
|
113 |
sessionStorage.setItem('VERSION_CHECKED_FROM_LOGIN', 'true');
|
|
|
35 |
return;
|
36 |
}
|
37 |
authCheckRef.current = true;
|
38 |
+
|
39 |
try {
|
40 |
// If already authenticated, redirect to home
|
41 |
if (isAuthenticated) {
|
|
|
45 |
|
46 |
// Check auth status
|
47 |
const status = await getAuthStatus()
|
48 |
+
|
49 |
// Set checkingAuth to false immediately after getAuthStatus
|
50 |
// This allows the login page to render while other processing continues
|
51 |
if (isMounted) {
|
52 |
setCheckingAuth(false);
|
53 |
}
|
54 |
+
|
55 |
// Set session flag for version check to avoid duplicate checks in App component
|
56 |
if (isMounted && (status.core_version || status.api_version)) {
|
57 |
sessionStorage.setItem('VERSION_CHECKED_FROM_LOGIN', 'true');
|
|
|
107 |
// Check authentication mode
|
108 |
const isGuestMode = response.auth_mode === 'disabled'
|
109 |
login(response.access_token, isGuestMode, response.core_version, response.api_version)
|
110 |
+
|
111 |
// Set session flag for version check
|
112 |
if (response.core_version || response.api_version) {
|
113 |
sessionStorage.setItem('VERSION_CHECKED_FROM_LOGIN', 'true');
|
lightrag_webui/src/stores/state.ts
CHANGED
@@ -43,7 +43,7 @@ const useBackendStateStoreBase = create<BackendState>()((set) => ({
|
|
43 |
health.api_version || null
|
44 |
);
|
45 |
}
|
46 |
-
|
47 |
set({
|
48 |
health: true,
|
49 |
message: null,
|
|
|
43 |
health.api_version || null
|
44 |
);
|
45 |
}
|
46 |
+
|
47 |
set({
|
48 |
health: true,
|
49 |
message: null,
|