yangdx commited on
Commit
ee42ccf
·
1 Parent(s): 0ec71c5

Fix file_path error in PostgreSQL storage

Browse files
lightrag/kg/postgres_impl.py CHANGED
@@ -1891,9 +1891,9 @@ SQL_TEMPLATES = {
1891
  FROM LIGHTRAG_DOC_CHUNKS
1892
  WHERE {doc_ids} IS NULL OR full_doc_id = ANY(ARRAY[{doc_ids}])
1893
  )
1894
- SELECT id FROM
1895
  (
1896
- SELECT id, 1 - (content_vector <=> '[{embedding_string}]'::vector) as distance
1897
  FROM LIGHTRAG_DOC_CHUNKS
1898
  where workspace=$1
1899
  AND id IN (SELECT chunk_id FROM relevant_chunks)
 
1891
  FROM LIGHTRAG_DOC_CHUNKS
1892
  WHERE {doc_ids} IS NULL OR full_doc_id = ANY(ARRAY[{doc_ids}])
1893
  )
1894
+ SELECT id, content, file_path FROM
1895
  (
1896
+ SELECT id, content, file_path, 1 - (content_vector <=> '[{embedding_string}]'::vector) as distance
1897
  FROM LIGHTRAG_DOC_CHUNKS
1898
  where workspace=$1
1899
  AND id IN (SELECT chunk_id FROM relevant_chunks)
lightrag/operate.py CHANGED
@@ -1338,7 +1338,9 @@ async def _get_node_data(
1338
 
1339
  text_units_section_list = [["id", "content", "file_path"]]
1340
  for i, t in enumerate(use_text_units):
1341
- text_units_section_list.append([i, t["content"], t["file_path"]])
 
 
1342
  text_units_context = list_of_list_to_csv(text_units_section_list)
1343
  return entities_context, relations_context, text_units_context
1344
 
@@ -1601,7 +1603,9 @@ async def _get_edge_data(
1601
 
1602
  text_units_section_list = [["id", "content", "file_path"]]
1603
  for i, t in enumerate(use_text_units):
1604
- text_units_section_list.append([i, t["content"], t["file_path"]])
 
 
1605
  text_units_context = list_of_list_to_csv(text_units_section_list)
1606
  return entities_context, relations_context, text_units_context
1607
 
 
1338
 
1339
  text_units_section_list = [["id", "content", "file_path"]]
1340
  for i, t in enumerate(use_text_units):
1341
+ text_units_section_list.append(
1342
+ [i, t["content"], t.get("file_path", "unknown_source")]
1343
+ )
1344
  text_units_context = list_of_list_to_csv(text_units_section_list)
1345
  return entities_context, relations_context, text_units_context
1346
 
 
1603
 
1604
  text_units_section_list = [["id", "content", "file_path"]]
1605
  for i, t in enumerate(use_text_units):
1606
+ text_units_section_list.append(
1607
+ [i, t["content"], t.get("file_path", "unknown_source")]
1608
+ )
1609
  text_units_context = list_of_list_to_csv(text_units_section_list)
1610
  return entities_context, relations_context, text_units_context
1611