From 4580ad2fd75af9d6bdffddbce49b9cb2fe6cff04 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Thu, 22 Aug 2024 09:28:23 +0800 Subject: [PATCH] show error log of KG extraction (#2045) ### What problem does this PR solve? ### Type of change - [x] Performance Improvement --- graphrag/graph_extractor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphrag/graph_extractor.py b/graphrag/graph_extractor.py index 6246ef7ff..00d0f72ad 100644 --- a/graphrag/graph_extractor.py +++ b/graphrag/graph_extractor.py @@ -142,6 +142,7 @@ class GraphExtractor: total_token_count += token_count if callback: callback(msg=f"{doc_index+1}/{total}, elapsed: {timer() - st}s, used tokens: {total_token_count}") except Exception as e: + if callback: callback("Knowledge graph extraction error:{}".format(str(e))) logging.exception("error extracting graph") self._on_error( e, @@ -184,6 +185,7 @@ class GraphExtractor: text = perform_variable_replacements(CONTINUE_PROMPT, history=history, variables=variables) history.append({"role": "user", "content": text}) response = self._llm.chat("", history, gen_conf) + if response.find("**ERROR**") >=0: raise Exception(response) results += response or "" # if this is the final glean, don't bother updating the continuation flag