From aac26b086ed119d325e6e5968be693579ec85003 Mon Sep 17 00:00:00 2001 From: Jiyu Tian Date: Thu, 12 Dec 2024 15:47:57 -0500 Subject: [PATCH] fix: update operate.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 避免变量在赋值之前就被引用 2. 解决未找到entity返回None导致的unpack问题 --- lightrag/operate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lightrag/operate.py b/lightrag/operate.py index 8b8ad85b..4a138564 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -588,6 +588,9 @@ async def _build_query_context( text_chunks_db: BaseKVStorage[TextChunkSchema], query_param: QueryParam, ): + # ll_entities_context, ll_relations_context, ll_text_units_context = "", "", "" + # hl_entities_context, hl_relations_context, hl_text_units_context = "", "", "" + ll_kewwords, hl_keywrds = query[0], query[1] if query_param.mode in ["local", "hybrid"]: if ll_kewwords == "": @@ -686,7 +689,7 @@ async def _get_node_data( # get similar entities results = await entities_vdb.query(query, top_k=query_param.top_k) if not len(results): - return None + return "", "", "" # get entity information node_datas = await asyncio.gather( *[knowledge_graph_inst.get_node(r["entity_name"]) for r in results]