The default is 10.chain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, top_k=2)chain.run("Who played in Top Gun?")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})    RETURN a.name    Full Context:    [{'a.name': 'Tom Cruise'}, {'a.name': 'Val Kilmer'}]        > Finished chain.    'Tom Cruise and Val Kilmer played in Top Gun.'Return intermediate results‚ÄãYou can return intermediate steps from the Cypher QA Chain using the return_intermediate_steps parameterchain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, return_intermediate_steps=True)result = chain("Who played in Top Gun?")print(f"Intermediate steps: {result['intermediate_steps']}")print(f"Final answer: {result['result']}")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})    RETURN a.name    Full Context:    [{'a.name': 'Tom Cruise'}, {'a.name': 'Val Kilmer'}, {'a.name': 'Anthony Edwards'}, {'a.name': 'Meg Ryan'}]        > Finished chain.    Intermediate steps: [{'query': "MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})\nRETURN a.name"}, {'context': [{'a.name': 'Tom Cruise'}, {'a.name': 'Val Kilmer'}, {'a.name': 'Anthony Edwards'}, {'a.name': 'Meg Ryan'}]}]    Final answer: Tom Cruise, Val Kilmer, Anthony Edwards, and Meg Ryan played in Top Gun.Return direct results‚ÄãYou can return direct results from the Cypher QA Chain using the return_direct parameterchain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, return_direct=True)chain.run("Who played in Top Gun?")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})    RETURN a.name        > Finished chain.    [{'a.name': 'Tom Cruise'},     {'a.name': 'Val Kilmer'},     {'a.name':
This notebook shows how to use LLMs to provide a natural language interface to a graph database you can query with the Cypher query language.
This notebook shows how to use LLMs to provide a natural language interface to a graph database you can query with the Cypher query language. ->: The default is 10.chain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, top_k=2)chain.run("Who played in Top Gun?")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})    RETURN a.name    Full Context:    [{'a.name': 'Tom Cruise'}, {'a.name': 'Val Kilmer'}]        > Finished chain.    'Tom Cruise and Val Kilmer played in Top Gun.'Return intermediate results‚ÄãYou can return intermediate steps from the Cypher QA Chain using the return_intermediate_steps parameterchain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, return_intermediate_steps=True)result = chain("Who played in Top Gun?")print(f"Intermediate steps: {result['intermediate_steps']}")print(f"Final answer: {result['result']}")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})    RETURN a.name    Full Context:    [{'a.name': 'Tom Cruise'}, {'a.name': 'Val Kilmer'}, {'a.name': 'Anthony Edwards'}, {'a.name': 'Meg Ryan'}]        > Finished chain.    Intermediate steps: [{'query': "MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})\nRETURN a.name"}, {'context': [{'a.name': 'Tom Cruise'}, {'a.name': 'Val Kilmer'}, {'a.name': 'Anthony Edwards'}, {'a.name': 'Meg Ryan'}]}]    Final answer: Tom Cruise, Val Kilmer, Anthony Edwards, and Meg Ryan played in Top Gun.Return direct results‚ÄãYou can return direct results from the Cypher QA Chain using the return_direct parameterchain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, return_direct=True)chain.run("Who played in Top Gun?")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})    RETURN a.name        > Finished chain.    [{'a.name': 'Tom Cruise'},     {'a.name': 'Val Kilmer'},     {'a.name':