diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 837d48ed..df879fc5 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1891,9 +1891,9 @@ SQL_TEMPLATES = { FROM LIGHTRAG_DOC_CHUNKS WHERE {doc_ids} IS NULL OR full_doc_id = ANY(ARRAY[{doc_ids}]) ) - SELECT id FROM + SELECT id, content, file_path FROM ( - SELECT id, 1 - (content_vector <=> '[{embedding_string}]'::vector) as distance + SELECT id, content, file_path, 1 - (content_vector <=> '[{embedding_string}]'::vector) as distance FROM LIGHTRAG_DOC_CHUNKS where workspace=$1 AND id IN (SELECT chunk_id FROM relevant_chunks) diff --git a/lightrag/operate.py b/lightrag/operate.py index 5da02683..e0351075 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -1338,7 +1338,9 @@ async def _get_node_data( text_units_section_list = [["id", "content", "file_path"]] for i, t in enumerate(use_text_units): - text_units_section_list.append([i, t["content"], t["file_path"]]) + text_units_section_list.append( + [i, t["content"], t.get("file_path", "unknown_source")] + ) text_units_context = list_of_list_to_csv(text_units_section_list) return entities_context, relations_context, text_units_context @@ -1601,7 +1603,9 @@ async def _get_edge_data( text_units_section_list = [["id", "content", "file_path"]] for i, t in enumerate(use_text_units): - text_units_section_list.append([i, t["content"], t["file_path"]]) + text_units_section_list.append( + [i, t["content"], t.get("file_path", "unknown_source")] + ) text_units_context = list_of_list_to_csv(text_units_section_list) return entities_context, relations_context, text_units_context