Skip to content

Commit

Permalink
100% coverage for GraphCypherQAChain
Browse files Browse the repository at this point in the history
  • Loading branch information
alexthomas93 committed Dec 16, 2024
1 parent 2049cb1 commit 6761ffe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_cypher_generating_run() -> None:
chain = GraphCypherQAChain.from_llm(
llm=llm,
graph=graph,
validate_cypher=True,
allow_dangerous_requests=True,
)
output = chain.run("Who starred in Pulp Fiction?")
Expand Down
13 changes: 13 additions & 0 deletions libs/neo4j/tests/unit_tests/chains/test_graph_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,19 @@ def test_graph_cypher_qa_chain() -> None:
assert True


def test_cypher_generation_failure() -> None:
"""Test the chain doesn't fail if the Cypher query fails to be generated."""
llm = FakeLLM(queries={"query": ""}, sequential_responses=True)
chain = GraphCypherQAChain.from_llm(
llm=llm,
graph=FakeGraphStore(),
allow_dangerous_requests=True,
return_direct=True,
)
response = chain.run("Test question")
assert response == []


def test_no_backticks() -> None:
"""Test if there are no backticks, so the original text should be returned."""
query = "MATCH (n) RETURN n"
Expand Down

0 comments on commit 6761ffe

Please sign in to comment.