yangdx commited on
Commit
201c775
·
1 Parent(s): 4fa6126

Fix linting

Browse files
lightrag/api/lightrag_server.py CHANGED
@@ -427,10 +427,12 @@ def create_app(args):
427
  class NoCacheStaticFiles(StaticFiles):
428
  async def get_response(self, path: str, scope):
429
  response = await super().get_response(path, scope)
430
- if path.endswith('.html'):
431
- response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
432
- response.headers['Pragma'] = 'no-cache'
433
- response.headers['Expires'] = '0'
 
 
434
  return response
435
 
436
  # Webui mount webui/index.html
 
427
  class NoCacheStaticFiles(StaticFiles):
428
  async def get_response(self, path: str, scope):
429
  response = await super().get_response(path, scope)
430
+ if path.endswith(".html"):
431
+ response.headers["Cache-Control"] = (
432
+ "no-cache, no-store, must-revalidate"
433
+ )
434
+ response.headers["Pragma"] = "no-cache"
435
+ response.headers["Expires"] = "0"
436
  return response
437
 
438
  # Webui mount webui/index.html
lightrag_webui/src/components/AppSettings.tsx CHANGED
@@ -9,10 +9,10 @@ import { useTranslation } from 'react-i18next'
9
  export default function AppSettings() {
10
  const [opened, setOpened] = useState<boolean>(false)
11
  const { t } = useTranslation()
12
-
13
  const language = useSettingsStore.use.language()
14
  const setLanguage = useSettingsStore.use.setLanguage()
15
-
16
  const theme = useSettingsStore.use.theme()
17
  const setTheme = useSettingsStore.use.setTheme()
18
 
 
9
  export default function AppSettings() {
10
  const [opened, setOpened] = useState<boolean>(false)
11
  const { t } = useTranslation()
12
+
13
  const language = useSettingsStore.use.language()
14
  const setLanguage = useSettingsStore.use.setLanguage()
15
+
16
  const theme = useSettingsStore.use.theme()
17
  const setTheme = useSettingsStore.use.setTheme()
18
 
lightrag_webui/src/components/ThemeProvider.tsx CHANGED
@@ -34,10 +34,10 @@ export default function ThemeProvider({ children, ...props }: ThemeProviderProps
34
  root.classList.remove('light', 'dark')
35
  root.classList.add(e.matches ? 'dark' : 'light')
36
  }
37
-
38
  root.classList.add(mediaQuery.matches ? 'dark' : 'light')
39
  mediaQuery.addEventListener('change', handleChange)
40
-
41
  return () => mediaQuery.removeEventListener('change', handleChange)
42
  } else {
43
  root.classList.add(theme)
 
34
  root.classList.remove('light', 'dark')
35
  root.classList.add(e.matches ? 'dark' : 'light')
36
  }
37
+
38
  root.classList.add(mediaQuery.matches ? 'dark' : 'light')
39
  mediaQuery.addEventListener('change', handleChange)
40
+
41
  return () => mediaQuery.removeEventListener('change', handleChange)
42
  } else {
43
  root.classList.add(theme)
lightrag_webui/src/components/graph/GraphLabels.tsx CHANGED
@@ -54,9 +54,9 @@ const GraphLabels = () => {
54
 
55
  const setQueryLabel = useCallback((newLabel: string) => {
56
  if (newLabel.startsWith('And ') && newLabel.endsWith(' others')) return
57
-
58
  const currentLabel = useSettingsStore.getState().queryLabel
59
-
60
  if (newLabel === '*' && currentLabel === '*') {
61
  // When reselecting '*', just set it again to trigger a new fetch
62
  useSettingsStore.getState().setQueryLabel('*')
 
54
 
55
  const setQueryLabel = useCallback((newLabel: string) => {
56
  if (newLabel.startsWith('And ') && newLabel.endsWith(' others')) return
57
+
58
  const currentLabel = useSettingsStore.getState().queryLabel
59
+
60
  if (newLabel === '*' && currentLabel === '*') {
61
  // When reselecting '*', just set it again to trigger a new fetch
62
  useSettingsStore.getState().setQueryLabel('*')
lightrag_webui/src/components/ui/Tooltip.tsx CHANGED
@@ -25,7 +25,7 @@ const TooltipContent = React.forwardRef<
25
  }
26
  >(({ className, side = 'left', align = 'start', children, ...props }, ref) => {
27
  const contentRef = React.useRef<HTMLDivElement>(null);
28
-
29
  React.useEffect(() => {
30
  if (contentRef.current) {
31
  contentRef.current.scrollTop = 0;
 
25
  }
26
  >(({ className, side = 'left', align = 'start', children, ...props }, ref) => {
27
  const contentRef = React.useRef<HTMLDivElement>(null);
28
+
29
  React.useEffect(() => {
30
  if (contentRef.current) {
31
  contentRef.current.scrollTop = 0;
lightrag_webui/src/hooks/useLightragGraph.tsx CHANGED
@@ -178,8 +178,8 @@ const useLightrangeGraph = () => {
178
  // Reset fetch status only when parameters actually change
179
  useEffect(() => {
180
  const prevParams = prevParamsRef.current;
181
- if (prevParams.queryLabel !== queryLabel ||
182
- prevParams.maxQueryDepth !== maxQueryDepth ||
183
  prevParams.minDegree !== minDegree) {
184
  useGraphStore.getState().setIsFetching(false);
185
  // Reset fetch status for new parameters
@@ -206,7 +206,7 @@ const useLightrangeGraph = () => {
206
  useEffect(() => {
207
  if (queryLabel) {
208
  const fetchKey = `${queryLabel}-${maxQueryDepth}-${minDegree}`;
209
-
210
  // Only fetch if we haven't fetched this combination in the current component lifecycle
211
  if (!isFetching && !fetchStatusRef.current[fetchKey]) {
212
  useGraphStore.getState().setIsFetching(true);
@@ -215,13 +215,13 @@ const useLightrangeGraph = () => {
215
  const state = useGraphStore.getState()
216
  const newSigmaGraph = createSigmaGraph(data)
217
  data?.buildDynamicMap()
218
-
219
  // Update all graph data at once to minimize UI flicker
220
  state.clearSelection()
221
  state.setMoveToSelectedNode(false)
222
  state.setSigmaGraph(newSigmaGraph)
223
  state.setRawGraph(data)
224
-
225
  // Extract labels from graph data
226
  if (data) {
227
  const labelSet = new Set<string>();
 
178
  // Reset fetch status only when parameters actually change
179
  useEffect(() => {
180
  const prevParams = prevParamsRef.current;
181
+ if (prevParams.queryLabel !== queryLabel ||
182
+ prevParams.maxQueryDepth !== maxQueryDepth ||
183
  prevParams.minDegree !== minDegree) {
184
  useGraphStore.getState().setIsFetching(false);
185
  // Reset fetch status for new parameters
 
206
  useEffect(() => {
207
  if (queryLabel) {
208
  const fetchKey = `${queryLabel}-${maxQueryDepth}-${minDegree}`;
209
+
210
  // Only fetch if we haven't fetched this combination in the current component lifecycle
211
  if (!isFetching && !fetchStatusRef.current[fetchKey]) {
212
  useGraphStore.getState().setIsFetching(true);
 
215
  const state = useGraphStore.getState()
216
  const newSigmaGraph = createSigmaGraph(data)
217
  data?.buildDynamicMap()
218
+
219
  // Update all graph data at once to minimize UI flicker
220
  state.clearSelection()
221
  state.setMoveToSelectedNode(false)
222
  state.setSigmaGraph(newSigmaGraph)
223
  state.setRawGraph(data)
224
+
225
  // Extract labels from graph data
226
  if (data) {
227
  const labelSet = new Set<string>();
lightrag_webui/src/stores/graph.ts CHANGED
@@ -129,7 +129,7 @@ const useGraphStoreBase = create<GraphState>()((set) => ({
129
  }),
130
 
131
  setSigmaGraph: (sigmaGraph: DirectedGraph | null) => set({ sigmaGraph }),
132
-
133
  setGraphLabels: (labels: string[]) => set({ graphLabels: labels }),
134
 
135
  setMoveToSelectedNode: (moveToSelectedNode?: boolean) => set({ moveToSelectedNode })
 
129
  }),
130
 
131
  setSigmaGraph: (sigmaGraph: DirectedGraph | null) => set({ sigmaGraph }),
132
+
133
  setGraphLabels: (labels: string[]) => set({ graphLabels: labels }),
134
 
135
  setMoveToSelectedNode: (moveToSelectedNode?: boolean) => set({ moveToSelectedNode })