From 47485b130de5a56128517a559cd3a25d197ee456 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sat, 23 Aug 2025 02:04:14 +0800 Subject: [PATCH] refac(ui): Show rerank binding info on status card - Remove separate ENABLE_RERANK flag in favor of rerank_binding="null" - Change default rerank binding from "cohere" to "null" (disabled) - Update UI to display both rerank binding and model information --- env.example | 5 ++--- lightrag/api/config.py | 8 +------- lightrag/api/lightrag_server.py | 12 +++++------- lightrag/constants.py | 2 +- lightrag_webui/src/api/lightrag.ts | 1 + lightrag_webui/src/components/status/StatusCard.tsx | 2 +- 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/env.example b/env.example index c39faa5f..e4521132 100644 --- a/env.example +++ b/env.example @@ -87,11 +87,10 @@ ENABLE_LLM_CACHE=true ######################################################### ### Reranking configuration -### RERANK_BINDING type: cohere, jina, aliyun +### RERANK_BINDING type: null, cohere, jina, aliyun ### For rerank model deployed by vLLM use cohere binding ######################################################### -ENABLE_RERANK=False -RERANK_BINDING=cohere +RERANK_BINDING=null ### rerank score chunk filter(set to 0.0 to keep all chunks, 0.6 or above if LLM is not strong enought) # MIN_RERANK_SCORE=0.0 diff --git a/lightrag/api/config.py b/lightrag/api/config.py index 92952ec4..a5e352dc 100644 --- a/lightrag/api/config.py +++ b/lightrag/api/config.py @@ -228,15 +228,9 @@ def parse_args() -> argparse.Namespace: "--rerank-binding", type=str, default=get_env_value("RERANK_BINDING", DEFAULT_RERANK_BINDING), - choices=["cohere", "jina", "aliyun"], + choices=["null", "cohere", "jina", "aliyun"], help=f"Rerank binding type (default: from env or {DEFAULT_RERANK_BINDING})", ) - parser.add_argument( - "--enable-rerank", - action="store_true", - default=get_env_value("ENABLE_RERANK", False, bool), - help="Enable rerank functionality (default: from env or disalbed)", - ) # Conditionally add binding options defined in binding_options module # This will add command line arguments for all binding options (e.g., --ollama-embedding-num_ctx) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 8214d601..7d94eec4 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -393,7 +393,7 @@ def create_app(args): # Configure rerank function based on enable_rerank parameter rerank_model_func = None - if args.enable_rerank and args.rerank_binding: + if args.rerank_binding != "null": from lightrag.rerank import cohere_rerank, jina_rerank, ali_rerank # Map rerank binding to corresponding function @@ -651,13 +651,11 @@ def create_app(args): "workspace": args.workspace, "max_graph_nodes": args.max_graph_nodes, # Rerank configuration - "enable_rerank": args.enable_rerank, - "rerank_binding": args.rerank_binding - if args.enable_rerank - else None, - "rerank_model": args.rerank_model if args.enable_rerank else None, + "enable_rerank": rerank_model_func is not None, + "rerank_binding": args.rerank_binding, + "rerank_model": args.rerank_model if rerank_model_func else None, "rerank_binding_host": args.rerank_binding_host - if args.enable_rerank + if rerank_model_func else None, # Environment variable status (requested configuration) "summary_language": args.summary_language, diff --git a/lightrag/constants.py b/lightrag/constants.py index 6aa845af..9445872e 100644 --- a/lightrag/constants.py +++ b/lightrag/constants.py @@ -33,7 +33,7 @@ DEFAULT_HISTORY_TURNS = 0 # Rerank configuration defaults DEFAULT_MIN_RERANK_SCORE = 0.0 -DEFAULT_RERANK_BINDING = "cohere" +DEFAULT_RERANK_BINDING = "null" # File path configuration for vector and graph database(Should not be changed, used in Milvus Schema) DEFAULT_MAX_FILE_PATH_LENGTH = 32768 diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index 98fc59ca..d2f23f12 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -43,6 +43,7 @@ export type LightragStatus = { workspace?: string max_graph_nodes?: string enable_rerank?: boolean + rerank_binding?: string | null rerank_model?: string | null rerank_binding_host?: string | null summary_language: string diff --git a/lightrag_webui/src/components/status/StatusCard.tsx b/lightrag_webui/src/components/status/StatusCard.tsx index a084ea13..8eeaaf70 100644 --- a/lightrag_webui/src/components/status/StatusCard.tsx +++ b/lightrag_webui/src/components/status/StatusCard.tsx @@ -52,7 +52,7 @@ const StatusCard = ({ status }: { status: LightragStatus | null }) => { {t('graphPanel.statusCard.rerankerBindingHost')}: {status.configuration.rerank_binding_host || '-'} {t('graphPanel.statusCard.rerankerModel')}: - {status.configuration.rerank_model || '-'} + {(status.configuration.rerank_binding || '-')} : {(status.configuration.rerank_model || '-')} )}