mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 18:23:59 +00:00
Fix buggy output from GraphQAChain (#7372)
fixes https://github.com/hwchase17/langchain/issues/7289 A simple fix of the buggy output of `graph_qa`. If we have several entities with triplets then the last entry of `triplets` for a given entity merges with the first entry of the `triplets` of the next entity.
This commit is contained in:
parent
7cdf97ba9b
commit
184ede4e48
@ -75,9 +75,10 @@ class GraphQAChain(Chain):
|
|||||||
)
|
)
|
||||||
entities = get_entities(entity_string)
|
entities = get_entities(entity_string)
|
||||||
context = ""
|
context = ""
|
||||||
|
all_triplets = []
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
triplets = self.graph.get_entity_knowledge(entity)
|
all_triplets.extend(self.graph.get_entity_knowledge(entity))
|
||||||
context += "\n".join(triplets)
|
context = "\n".join(all_triplets)
|
||||||
_run_manager.on_text("Full Context:", end="\n", verbose=self.verbose)
|
_run_manager.on_text("Full Context:", end="\n", verbose=self.verbose)
|
||||||
_run_manager.on_text(context, color="green", end="\n", verbose=self.verbose)
|
_run_manager.on_text(context, color="green", end="\n", verbose=self.verbose)
|
||||||
result = self.qa_chain(
|
result = self.qa_chain(
|
||||||
|
Loading…
Reference in New Issue
Block a user