From 4e58c7d7da236ce662633ea1fd7025b28b6d67be Mon Sep 17 00:00:00 2001 From: pengjunfeng11 <34857167+pengjunfeng11@users.noreply.github.com> Date: Mon, 17 Mar 2025 10:47:17 +0800 Subject: [PATCH 1/2] Update postgres_impl.py There is aBUG. When lighttrag uses the postgres@15 version, there will be an error.The BUG detail as follow: PostgreSQL database, error:subquery in FROM must have an alias HINT: For example, FROM (SELECT ...) [AS] foo. It roughly means that there is an error in SQL template, and you need to use the alias alias to declare the content of the subquery. --- lightrag/kg/postgres_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 6a3e7c5f..99e4f5c4 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1739,7 +1739,7 @@ SQL_TEMPLATES = { FROM LIGHTRAG_VDB_ENTITY where workspace=$1 AND chunk_id IN (SELECT chunk_id FROM relevant_chunks) - ) + ) as chunk_distances WHERE distance>$2 ORDER BY distance DESC LIMIT $3 @@ -1756,7 +1756,7 @@ SQL_TEMPLATES = { FROM LIGHTRAG_DOC_CHUNKS where workspace=$1 AND id IN (SELECT chunk_id FROM relevant_chunks) - ) + ) as chunk_distances WHERE distance>$2 ORDER BY distance DESC LIMIT $3 From 60dd13f17e43624cf0b6d5d2d4c63ed267957765 Mon Sep 17 00:00:00 2001 From: zrguo Date: Mon, 17 Mar 2025 16:58:04 +0800 Subject: [PATCH 2/2] fix continue prompt format error --- lightrag/operate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightrag/operate.py b/lightrag/operate.py index 1815f308..d062ae73 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -404,7 +404,7 @@ async def extract_entities( language=language, ) - continue_prompt = PROMPTS["entity_continue_extraction"] + continue_prompt = PROMPTS["entity_continue_extraction"].format(**context_base) if_loop_prompt = PROMPTS["entity_if_loop_extraction"] processed_chunks = 0