From b92f9b945318b3be6d37c3de2104a20a3b3ecde7 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 8 May 2025 12:53:28 +0800 Subject: [PATCH] Optimizing query prompt --- lightrag/operate.py | 6 +++--- lightrag/prompt.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lightrag/operate.py b/lightrag/operate.py index 3ffca35a..5f57a90c 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -1302,19 +1302,19 @@ async def _build_query_context( relations_str = json.dumps(relations_context, ensure_ascii=False) text_units_str = json.dumps(text_units_context, ensure_ascii=False) - result = f"""-----Entities----- + result = f"""-----Entities(KG)----- ```json {entities_str} ``` ------Relationships----- +-----Relationships(KG)----- ```json {relations_str} ``` ------Sources----- +-----Document Chunks(DC)----- ```json {text_units_str} diff --git a/lightrag/prompt.py b/lightrag/prompt.py index a0f5a672..5ed630f9 100644 --- a/lightrag/prompt.py +++ b/lightrag/prompt.py @@ -199,7 +199,7 @@ PROMPTS["fail_response"] = ( PROMPTS["rag_response"] = """---Role--- -You are a helpful assistant responding to user query about Knowledge Base provided below. +You are a helpful assistant responding to user query about Knowledge Graph and Document Chunks provided in JSON format below. ---Goal--- @@ -215,7 +215,7 @@ When handling relationships with timestamps: ---Conversation History--- {history} ----Knowledge Base--- +---Knowledge Graph and Document Chunks--- {context_data} ---Response Rules--- @@ -224,7 +224,7 @@ When handling relationships with timestamps: - Use markdown formatting with appropriate section headings - Please respond in the same language as the user's question. - Ensure the response maintains continuity with the conversation history. -- List up to 5 most important reference sources at the end under "References" section. Clearly indicating whether each source is from Knowledge Graph (KG) or Vector Data (DC), and include the file path if available, in the following format: [KG/DC] file_path +- List up to 5 most important reference sources at the end under "References" section. Clearly indicating whether each source is from Knowledge Graph (KG) or Document Chunks (DC), and include the file path if available, in the following format: [KG/DC] file_path - If you don't know the answer, just say so. - Do not make anything up. Do not include information not provided by the Knowledge Base. - Addtional user prompt: {user_prompt} @@ -300,7 +300,7 @@ Output: PROMPTS["naive_rag_response"] = """---Role--- -You are a helpful assistant responding to user query about Document Chunks provided below. +You are a helpful assistant responding to user query about Document Chunks provided provided in JSON format below. ---Goal---