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.
pull/7378/head
Bearnardd 1 year ago committed by GitHub
parent 7cdf97ba9b
commit 184ede4e48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -75,9 +75,10 @@ class GraphQAChain(Chain):
)
entities = get_entities(entity_string)
context = ""
all_triplets = []
for entity in entities:
triplets = self.graph.get_entity_knowledge(entity)
context += "\n".join(triplets)
all_triplets.extend(self.graph.get_entity_knowledge(entity))
context = "\n".join(all_triplets)
_run_manager.on_text("Full Context:", end="\n", verbose=self.verbose)
_run_manager.on_text(context, color="green", end="\n", verbose=self.verbose)
result = self.qa_chain(

Loading…
Cancel
Save