From c984ebd46250bb304e8bc4c05733fc0aff3473e7 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 7 May 2025 03:11:59 +0800 Subject: [PATCH] Improve mix query context format --- lightrag/operate.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lightrag/operate.py b/lightrag/operate.py index 7d81cf7b..81a20400 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -1249,7 +1249,7 @@ async def mix_kg_vector_query( for c in maybe_trun_chunks: chunk_text = "File path: " + c["file_path"] + "\r\n\r\n" + c["content"] if c["created_at"]: - chunk_text = f"[Created at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(c['created_at']))}]\n{chunk_text}" + chunk_text = f"[Created at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(c['created_at']))}]\r\n\r\n{chunk_text}" formatted_chunks.append(chunk_text) logger.debug( @@ -1271,12 +1271,12 @@ async def mix_kg_vector_query( if query_param.only_need_context: context_str = f""" - -----Knowledge Graph Context----- - {kg_context if kg_context else "No relevant knowledge graph information found"} +\r\n\r\n=====Knowledge Graph Context=====\r\n\r\n +{kg_context if kg_context else "No relevant knowledge graph information found"} - -----Vector Context----- - {vector_context if vector_context else "No relevant text information found"} - """.strip() +\r\n\r\n=====Vector Context=====\r\n\r\n +{vector_context if vector_context else "No relevant text information found"} +""".strip() return context_str # 5. Construct hybrid prompt