mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix errors detected by Ruff (#3918)
### What problem does this PR solve? Fix errors detected by Ruff ### Type of change - [x] Refactoring
This commit is contained in:
@ -129,9 +129,11 @@ class GraphExtractor:
|
||||
source_doc_map[doc_index] = text
|
||||
all_records[doc_index] = result
|
||||
total_token_count += token_count
|
||||
if callback: callback(msg=f"{doc_index+1}/{total}, elapsed: {timer() - st}s, used tokens: {total_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(msg="Knowledge graph extraction error:{}".format(str(e)))
|
||||
if callback:
|
||||
callback(msg="Knowledge graph extraction error:{}".format(str(e)))
|
||||
logging.exception("error extracting graph")
|
||||
self._on_error(
|
||||
e,
|
||||
@ -164,7 +166,8 @@ class GraphExtractor:
|
||||
text = perform_variable_replacements(self._extraction_prompt, variables=variables)
|
||||
gen_conf = {"temperature": 0.3}
|
||||
response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
|
||||
if response.find("**ERROR**") >= 0: raise Exception(response)
|
||||
if response.find("**ERROR**") >= 0:
|
||||
raise Exception(response)
|
||||
token_count = num_tokens_from_string(text + response)
|
||||
|
||||
results = response or ""
|
||||
@ -175,7 +178,8 @@ 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)
|
||||
if response.find("**ERROR**") >=0:
|
||||
raise Exception(response)
|
||||
results += response or ""
|
||||
|
||||
# if this is the final glean, don't bother updating the continuation flag
|
||||
|
||||
Reference in New Issue
Block a user