From 6da53a302abd363cfa8398d0f1b90c9e43504d1a Mon Sep 17 00:00:00 2001 From: ArnoChen Date: Mon, 17 Feb 2025 12:32:04 +0800 Subject: [PATCH] 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