diff --git a/lightrag/operate.py b/lightrag/operate.py index 468f4b2f..ec55694d 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -412,15 +412,17 @@ async def extract_entities( ): all_relationships_data.append(await result) - if not len(all_entities_data): - logger.warning("Didn't extract any entities, maybe your LLM is not working") - return None - if not len(all_relationships_data): + if not len(all_entities_data) and not len(all_relationships_data): logger.warning( - "Didn't extract any relationships, maybe your LLM is not working" + "Didn't extract any entities or relationships, maybe your LLM is not working" ) return None + if not len(all_entities_data): + logger.warning("Didn't extract any entities") + if not len(all_relationships_data): + logger.warning("Didn't extract any relationships") + if entity_vdb is not None: data_for_vdb = { compute_mdhash_id(dp["entity_name"], prefix="ent-"): { @@ -630,6 +632,13 @@ async def _build_query_context( text_chunks_db, query_param, ) + if ( + hl_entities_context == "" + and hl_relations_context == "" + and hl_text_units_context == "" + ): + logger.warn("No high level context found. Switching to local mode.") + query_param.mode = "local" if query_param.mode == "hybrid": entities_context, relations_context, text_units_context = combine_contexts( [hl_entities_context, ll_entities_context], @@ -865,7 +874,7 @@ async def _get_edge_data( results = await relationships_vdb.query(keywords, top_k=query_param.top_k) if not len(results): - return None + return "", "", "" edge_datas = await asyncio.gather( *[knowledge_graph_inst.get_edge(r["src_id"], r["tgt_id"]) for r in results]