From 6da53a302abd363cfa8398d0f1b90c9e43504d1a Mon Sep 17 00:00:00 2001 From: ArnoChen Date: Mon, 17 Feb 2025 12:32:04 +0800 Subject: [PATCH 1/2] add api tab in webui and handle invalid num_turns --- lightrag/utils.py | 4 ++++ lightrag_webui/src/stores/settings.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lightrag/utils.py b/lightrag/utils.py index c8786e7b..fd8e0adc 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -657,6 +657,10 @@ def get_conversation_turns( Returns: Formatted string of the conversation history """ + # Check if num_turns is valid + if num_turns <= 0: + return "" + # Group messages into turns turns: list[list[dict[str, Any]]] = [] messages: list[dict[str, Any]] = [] diff --git a/lightrag_webui/src/stores/settings.ts b/lightrag_webui/src/stores/settings.ts index 84f5feac..60ae8f90 100644 --- a/lightrag_webui/src/stores/settings.ts +++ b/lightrag_webui/src/stores/settings.ts @@ -5,7 +5,7 @@ import { defaultQueryLabel } from '@/lib/constants' import { Message, QueryRequest } from '@/api/lightrag' type Theme = 'dark' | 'light' | 'system' -type Tab = 'documents' | 'knowledge-graph' | 'retrieval' +type Tab = 'documents' | 'knowledge-graph' | 'retrieval' | 'api' interface SettingsState { theme: Theme From 7c68bf7ab7bb5cdbec174c0e57602042bc76b9a4 Mon Sep 17 00:00:00 2001 From: ArnoChen Date: Mon, 17 Feb 2025 12:35:35 +0800 Subject: [PATCH 2/2] move ThemeProvider and ThemeToggle components --- lightrag_webui/src/App.tsx | 2 +- lightrag_webui/src/components/{graph => }/ThemeProvider.tsx | 0 lightrag_webui/src/components/{graph => }/ThemeToggle.tsx | 0 lightrag_webui/src/features/SiteHeader.tsx | 2 +- lightrag_webui/src/hooks/useTheme.tsx | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename lightrag_webui/src/components/{graph => }/ThemeProvider.tsx (100%) rename lightrag_webui/src/components/{graph => }/ThemeToggle.tsx (100%) diff --git a/lightrag_webui/src/App.tsx b/lightrag_webui/src/App.tsx index 2c7e8001..1cf8c5e3 100644 --- a/lightrag_webui/src/App.tsx +++ b/lightrag_webui/src/App.tsx @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import ThemeProvider from '@/components/graph/ThemeProvider' +import ThemeProvider from '@/components/ThemeProvider' import MessageAlert from '@/components/MessageAlert' import ApiKeyAlert from '@/components/ApiKeyAlert' import StatusIndicator from '@/components/graph/StatusIndicator' diff --git a/lightrag_webui/src/components/graph/ThemeProvider.tsx b/lightrag_webui/src/components/ThemeProvider.tsx similarity index 100% rename from lightrag_webui/src/components/graph/ThemeProvider.tsx rename to lightrag_webui/src/components/ThemeProvider.tsx diff --git a/lightrag_webui/src/components/graph/ThemeToggle.tsx b/lightrag_webui/src/components/ThemeToggle.tsx similarity index 100% rename from lightrag_webui/src/components/graph/ThemeToggle.tsx rename to lightrag_webui/src/components/ThemeToggle.tsx diff --git a/lightrag_webui/src/features/SiteHeader.tsx b/lightrag_webui/src/features/SiteHeader.tsx index 5446e382..6eef0bb9 100644 --- a/lightrag_webui/src/features/SiteHeader.tsx +++ b/lightrag_webui/src/features/SiteHeader.tsx @@ -1,6 +1,6 @@ import Button from '@/components/ui/Button' import { SiteInfo } from '@/lib/constants' -import ThemeToggle from '@/components/graph/ThemeToggle' +import ThemeToggle from '@/components/ThemeToggle' import { TabsList, TabsTrigger } from '@/components/ui/Tabs' import { useSettingsStore } from '@/stores/settings' import { cn } from '@/lib/utils' diff --git a/lightrag_webui/src/hooks/useTheme.tsx b/lightrag_webui/src/hooks/useTheme.tsx index e1975174..5fb161a4 100644 --- a/lightrag_webui/src/hooks/useTheme.tsx +++ b/lightrag_webui/src/hooks/useTheme.tsx @@ -1,5 +1,5 @@ import { useContext } from 'react' -import { ThemeProviderContext } from '@/components/graph/ThemeProvider' +import { ThemeProviderContext } from '@/components/ThemeProvider' const useTheme = () => { const context = useContext(ThemeProviderContext)