Added core and API version to health check

- Bumped API version to 1.2.2
This commit is contained in:
yangdx
2025-03-23 00:28:50 +08:00
parent ea51ff05c1
commit 31c7923067
4 changed files with 31 additions and 1 deletions

View File

@@ -1 +1 @@
__api_version__ = "1.2.1" __api_version__ = "1.2.2"

View File

@@ -438,6 +438,8 @@ def create_app(args):
"enable_llm_cache_for_extract": args.enable_llm_cache_for_extract, "enable_llm_cache_for_extract": args.enable_llm_cache_for_extract,
}, },
"update_status": update_status, "update_status": update_status,
"core_version": core_version,
"api_version": __api_version__
} }
# Custom StaticFiles class to prevent caching of HTML files # Custom StaticFiles class to prevent caching of HTML files

View File

@@ -41,6 +41,9 @@ export type LightragStatus = {
graph_storage: string graph_storage: string
vector_storage: string vector_storage: string
} }
update_status?: Record<string, any>
core_version?: string
api_version?: string
} }
export type LightragDocumentsScanProgress = { export type LightragDocumentsScanProgress = {

View File

@@ -23,6 +23,7 @@ interface AuthState {
apiVersion: string | null; apiVersion: string | null;
login: (token: string, isGuest?: boolean, coreVersion?: string | null, apiVersion?: string | null) => void; login: (token: string, isGuest?: boolean, coreVersion?: string | null, apiVersion?: string | null) => void;
logout: () => void; logout: () => void;
setVersion: (coreVersion: string | null, apiVersion: string | null) => void;
} }
const useBackendStateStoreBase = create<BackendState>()((set) => ({ const useBackendStateStoreBase = create<BackendState>()((set) => ({
@@ -35,6 +36,14 @@ const useBackendStateStoreBase = create<BackendState>()((set) => ({
check: async () => { check: async () => {
const health = await checkHealth() const health = await checkHealth()
if (health.status === 'healthy') { if (health.status === 'healthy') {
// Update version information if health check returns it
if (health.core_version || health.api_version) {
useAuthStore.getState().setVersion(
health.core_version || null,
health.api_version || null
);
}
set({ set({
health: true, health: true,
message: null, message: null,
@@ -148,6 +157,22 @@ export const useAuthStore = create<AuthState>(set => {
coreVersion: coreVersion, coreVersion: coreVersion,
apiVersion: apiVersion apiVersion: apiVersion
}); });
},
setVersion: (coreVersion, apiVersion) => {
// Update localStorage
if (coreVersion) {
localStorage.setItem('LIGHTRAG-CORE-VERSION', coreVersion);
}
if (apiVersion) {
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
}
// Update state
set({
coreVersion: coreVersion,
apiVersion: apiVersion
});
} }
}; };
}); });