gzdaniel commited on
Commit
0a7a39d
·
1 Parent(s): ae607b6

Improve mix query context format

Browse files
Files changed (1) hide show
  1. 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
- -----Knowledge Graph Context-----
1275
- {kg_context if kg_context else "No relevant knowledge graph information found"}
1276
 
1277
- -----Vector Context-----
1278
- {vector_context if vector_context else "No relevant text information found"}
1279
- """.strip()
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