Improve mix query context format
Browse files- lightrag/operate.py +6 -6
lightrag/operate.py
CHANGED
@@ -1249,7 +1249,7 @@ async def mix_kg_vector_query(
|
|
1249 |
for c in maybe_trun_chunks:
|
1250 |
chunk_text = "File path: " + c["file_path"] + "\r\n\r\n" + c["content"]
|
1251 |
if c["created_at"]:
|
1252 |
-
chunk_text = f"[Created at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(c['created_at']))}]\n{chunk_text}"
|
1253 |
formatted_chunks.append(chunk_text)
|
1254 |
|
1255 |
logger.debug(
|
@@ -1271,12 +1271,12 @@ async def mix_kg_vector_query(
|
|
1271 |
|
1272 |
if query_param.only_need_context:
|
1273 |
context_str = f"""
|
1274 |
-
|
1275 |
-
|
1276 |
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
return context_str
|
1281 |
|
1282 |
# 5. Construct hybrid prompt
|
|
|
1249 |
for c in maybe_trun_chunks:
|
1250 |
chunk_text = "File path: " + c["file_path"] + "\r\n\r\n" + c["content"]
|
1251 |
if c["created_at"]:
|
1252 |
+
chunk_text = f"[Created at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(c['created_at']))}]\r\n\r\n{chunk_text}"
|
1253 |
formatted_chunks.append(chunk_text)
|
1254 |
|
1255 |
logger.debug(
|
|
|
1271 |
|
1272 |
if query_param.only_need_context:
|
1273 |
context_str = f"""
|
1274 |
+
\r\n\r\n=====Knowledge Graph Context=====\r\n\r\n
|
1275 |
+
{kg_context if kg_context else "No relevant knowledge graph information found"}
|
1276 |
|
1277 |
+
\r\n\r\n=====Vector Context=====\r\n\r\n
|
1278 |
+
{vector_context if vector_context else "No relevant text information found"}
|
1279 |
+
""".strip()
|
1280 |
return context_str
|
1281 |
|
1282 |
# 5. Construct hybrid prompt
|