'Adventure'})RETURN g, genreFull Context:[{'g': {'name': "Baldur's Gate 3"}, 'genre': {'name': 'Adventure'}}]> Finished chain.Intermediate steps: [{'query': "MATCH (g:Game {name: 'Baldur\\'s Gate 3'})-[:HAS_GENRE]->(genre:Genre {name: 'Adventure'})\nRETURN g, genre"}, {'context': [{'g': {'name': "Baldur's Gate 3"}, 'genre': {'name': 'Adventure'}}]}]Final response: Yes, Baldur's Gate 3 is an Adventure game.Limit the number of query results‚ÄãThe top_k modifier can be used when you want to restrict the maximum number of query results.# Limit the maximum number of results returned by querychain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, top_k=2)response = chain.run("What genres are associated with Baldur's Gate 3?")print(response)> Entering new GraphCypherQAChain chain...Generated Cypher:MATCH (:Game {name: 'Baldur\'s Gate 3'})-[:HAS_GENRE]->(g:Genre)RETURN g.nameFull Context:[{'g.name': 'Adventure'}, {'g.name': 'Role-Playing Game'}]> Finished chain.Baldur's Gate 3 is associated with the genres Adventure and Role-Playing Game.Advanced queryingAs the complexity of your solution grows, you might encounter different use-cases that require careful handling. Ensuring your application's scalability is essential to maintain a smooth user flow without any hitches.Let's instantiate our chain once again and attempt to ask some questions that users might potentially ask.chain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, model_name='gpt-3.5-turbo')response = chain.run("Is Baldur's Gate 3 available on PS5?")print(response)> Entering new GraphCypherQAChain chain...Generated Cypher:MATCH (g:Game {name: 'Baldur\'s Gate 3'})-[:AVAILABLE_ON]->(p:Platform {name: 'PS5'})RETURN g.name, p.nameFull Context:[]> Finished chain.I'm sorry, but I don't have the information to answer your question.The generated Cypher query looks fine, but we didn't receive any information in response. This illustrates a
This notebook shows how to use LLMs to provide a natural language interface to a Memgraph database. To complete this tutorial, you will need Docker and Python 3.x installed.
This notebook shows how to use LLMs to provide a natural language interface to a Memgraph database. To complete this tutorial, you will need Docker and Python 3.x installed. ->: 'Adventure'})RETURN g, genreFull Context:[{'g': {'name': "Baldur's Gate 3"}, 'genre': {'name': 'Adventure'}}]> Finished chain.Intermediate steps: [{'query': "MATCH (g:Game {name: 'Baldur\\'s Gate 3'})-[:HAS_GENRE]->(genre:Genre {name: 'Adventure'})\nRETURN g, genre"}, {'context': [{'g': {'name': "Baldur's Gate 3"}, 'genre': {'name': 'Adventure'}}]}]Final response: Yes, Baldur's Gate 3 is an Adventure game.Limit the number of query results‚ÄãThe top_k modifier can be used when you want to restrict the maximum number of query results.# Limit the maximum number of results returned by querychain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, top_k=2)response = chain.run("What genres are associated with Baldur's Gate 3?")print(response)> Entering new GraphCypherQAChain chain...Generated Cypher:MATCH (:Game {name: 'Baldur\'s Gate 3'})-[:HAS_GENRE]->(g:Genre)RETURN g.nameFull Context:[{'g.name': 'Adventure'}, {'g.name': 'Role-Playing Game'}]> Finished chain.Baldur's Gate 3 is associated with the genres Adventure and Role-Playing Game.Advanced queryingAs the complexity of your solution grows, you might encounter different use-cases that require careful handling. Ensuring your application's scalability is essential to maintain a smooth user flow without any hitches.Let's instantiate our chain once again and attempt to ask some questions that users might potentially ask.chain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, model_name='gpt-3.5-turbo')response = chain.run("Is Baldur's Gate 3 available on PS5?")print(response)> Entering new GraphCypherQAChain chain...Generated Cypher:MATCH (g:Game {name: 'Baldur\'s Gate 3'})-[:AVAILABLE_ON]->(p:Platform {name: 'PS5'})RETURN g.name, p.nameFull Context:[]> Finished chain.I'm sorry, but I don't have the information to answer your question.The generated Cypher query looks fine, but we didn't receive any information in response. This illustrates a