Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix graphrag : "role" user (#2273)

Hc6e723f2ee55
diff --git a/agent/component/jin10.py b/agent/component/jin10.py
index b133f8d140..9ff064da17 100644
--- a/agent/component/jin10.py
+++ b/agent/component/jin10.py
@@ -100,8 +100,8 @@ class Jin10(ComponentBase, ABC):
if self._param.symbols_datatype == "quotes":
for i in response['data']:
i['Selling Price'] = i['a']
- i['buying price'] = i['b']
- i['commodity code'] = i['c']
+ i['Buying Price'] = i['b']
+ i['Commodity Code'] = i['c']
i['Stock Exchange'] = i['e']
i['Highest Price'] = i['h']
i['Yesterday’s Closing Price'] = i['hc']
diff --git a/graphrag/claim_extractor.py b/graphrag/claim_extractor.py
index 942bafa3f8..d3c6864296 100644
--- a/graphrag/claim_extractor.py
+++ b/graphrag/claim_extractor.py
@@ -170,7 +170,7 @@ class ClaimExtractor:
}
text = perform_variable_replacements(self._extraction_prompt, variables=variables)
gen_conf = {"temperature": 0.5}
- results = self._llm.chat(text, [], gen_conf)
+ results = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
claims = results.strip().removesuffix(completion_delimiter)
history = [{"role": "system", "content": text}, {"role": "assistant", "content": results}]
diff --git a/graphrag/community_reports_extractor.py b/graphrag/community_reports_extractor.py
index 27b805ff44..1412555e49 100644
--- a/graphrag/community_reports_extractor.py
+++ b/graphrag/community_reports_extractor.py
@@ -76,7 +76,7 @@ class CommunityReportsExtractor:
text = perform_variable_replacements(self._extraction_prompt, variables=prompt_variables)
gen_conf = {"temperature": 0.3}
try:
- response = self._llm.chat(text, [], gen_conf)
+ response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
token_count += num_tokens_from_string(text + response)
response = re.sub(r"^[^\{]*", "", response)
response = re.sub(r"[^\}]*$", "", response)
@@ -125,4 +125,5 @@ class CommunityReportsExtractor:
report_sections = "\n\n".join(
f"## {finding_summary(f)}\n\n{finding_explanation(f)}" for f in findings
)
- return f"# {title}\n\n{summary}\n\n{report_sections}"
\ No newline at end of file
+
+ return f"# {title}\n\n{summary}\n\n{report_sections}"
diff --git a/graphrag/entity_resolution.py b/graphrag/entity_resolution.py
index 92152aa9a5..c4c0dc3496 100644
--- a/graphrag/entity_resolution.py
+++ b/graphrag/entity_resolution.py
@@ -125,7 +125,7 @@ class EntityResolution:
}
text = perform_variable_replacements(self._resolution_prompt, variables=variables)
- response = self._llm.chat(text, [], gen_conf)
+ response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
result = self._process_results(len(candidate_resolution_i[1]), response,
prompt_variables.get(self._record_delimiter_key,
DEFAULT_RECORD_DELIMITER),
diff --git a/graphrag/graph_extractor.py b/graphrag/graph_extractor.py
index 837f6ff2f4..dce15cbf75 100644
--- a/graphrag/graph_extractor.py
+++ b/graphrag/graph_extractor.py
@@ -163,7 +163,7 @@ class GraphExtractor:
token_count = 0
text = perform_variable_replacements(self._extraction_prompt, variables=variables)
gen_conf = {"temperature": 0.3}
- response = self._llm.chat(text, [], gen_conf)
+ response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
token_count = num_tokens_from_string(text + response)
results = response or ""
diff --git a/graphrag/mind_map_extractor.py b/graphrag/mind_map_extractor.py
index 2968e9e361..d338889d44 100644
--- a/graphrag/mind_map_extractor.py
+++ b/graphrag/mind_map_extractor.py
@@ -180,7 +180,7 @@ class MindMapExtractor:
}
text = perform_variable_replacements(self._mind_map_prompt, variables=variables)
gen_conf = {"temperature": 0.5}
- response = self._llm.chat(text, [], gen_conf)
+ response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
response = re.sub(r"```[^\n]*", "", response)
print(response)
print("---------------------------------------------------\n", self._todict(markdown_to_json.dictify(response)))