Skip to content

Commit

Permalink
community[minor]: GraphCypherQAChain to accept additional inputs as p…
Browse files Browse the repository at this point in the history
…rovided by the user for cypher generation (#24300)

**Description:** This PR introduces a change to the
`cypher_generation_chain` to dynamically concatenate inputs. This
improvement aims to streamline the input handling process and make the
method more flexible. The change involves updating the arguments
dictionary with all elements from the `inputs` dictionary, ensuring that
all necessary inputs are dynamically appended. This will ensure that any
cypher generation template will not require a new `_call` method patch.

**Issue:** This PR fixes issue #24260.
  • Loading branch information
RafaelXokito committed Jul 19, 2024
1 parent f585668 commit 6a45bf9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libs/community/langchain_community/chains/graph_qa/cypher.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,15 @@ def _call(
_run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
callbacks = _run_manager.get_child()
question = inputs[self.input_key]
args = {
"question": question,
"schema": self.graph_schema,
}
args.update(inputs)

intermediate_steps: List = []

generated_cypher = self.cypher_generation_chain.run(
{"question": question, "schema": self.graph_schema}, callbacks=callbacks
)
generated_cypher = self.cypher_generation_chain.run(args, callbacks=callbacks)

# Extract Cypher code if it is wrapped in backticks
generated_cypher = extract_cypher(generated_cypher)
Expand Down

0 comments on commit 6a45bf9

Please sign in to comment.