"MATCH (p:Person), (m:Movie) WHERE p.name = 'Al Pacino' AND m.name = 'The Godfather Coda: The Death of Michael Corleone' CREATE (p)-[:ActedIn]->(m)")conn.execute(    "MATCH (p:Person), (m:Movie) WHERE p.name = 'Robert De Niro' AND m.name = 'The Godfather: Part II' CREATE (p)-[:ActedIn]->(m)")    <kuzu.query_result.QueryResult at 0x107016210>Creating KuzuQAChain‚ÄãWe can now create the KuzuGraph and KuzuQAChain. To create the KuzuGraph we simply need to pass the database object to the KuzuGraph constructor.from langchain.chat_models import ChatOpenAIfrom langchain.graphs import KuzuGraphfrom langchain.chains import KuzuQAChaingraph = KuzuGraph(db)chain = KuzuQAChain.from_llm(ChatOpenAI(temperature=0), graph=graph, verbose=True)Refresh graph schema information‚ÄãIf the schema of database changes, you can refresh the schema information needed to generate Cypher statements.# graph.refresh_schema()print(graph.get_schema)    Node properties: [{'properties': [('name', 'STRING')], 'label': 'Movie'}, {'properties': [('name', 'STRING'), ('birthDate', 'STRING')], 'label': 'Person'}]    Relationships properties: [{'properties': [], 'label': 'ActedIn'}]    Relationships: ['(:Person)-[:ActedIn]->(:Movie)']    Querying the graph‚ÄãWe can now use the KuzuQAChain to ask question of the graphchain.run("Who played in The Godfather: Part II?")            > Entering new  chain...    Generated Cypher:    MATCH (p:Person)-[:ActedIn]->(m:Movie {name: 'The Godfather: Part II'}) RETURN p.name    Full Context:    [{'p.name': 'Al Pacino'}, {'p.name': 'Robert De Niro'}]        > Finished chain.    'Al Pacino and Robert De Niro both played in The Godfather: Part II.'chain.run("Robert De Niro played in which movies?")            > Entering new  chain...    Generated Cypher:    MATCH (p:Person {name: 'Robert De Niro'})-[:ActedIn]->(m:Movie)    RETURN m.name    Full Context:    [{'m.name': 'The Godfather: Part II'}]        > Finished chain.    'Robert De Niro played in The Godfather: Part
This notebook shows how to use LLMs to provide a natural language interface to K√πzu database.
This notebook shows how to use LLMs to provide a natural language interface to K√πzu database. ->: "MATCH (p:Person), (m:Movie) WHERE p.name = 'Al Pacino' AND m.name = 'The Godfather Coda: The Death of Michael Corleone' CREATE (p)-[:ActedIn]->(m)")conn.execute(    "MATCH (p:Person), (m:Movie) WHERE p.name = 'Robert De Niro' AND m.name = 'The Godfather: Part II' CREATE (p)-[:ActedIn]->(m)")    <kuzu.query_result.QueryResult at 0x107016210>Creating KuzuQAChain‚ÄãWe can now create the KuzuGraph and KuzuQAChain. To create the KuzuGraph we simply need to pass the database object to the KuzuGraph constructor.from langchain.chat_models import ChatOpenAIfrom langchain.graphs import KuzuGraphfrom langchain.chains import KuzuQAChaingraph = KuzuGraph(db)chain = KuzuQAChain.from_llm(ChatOpenAI(temperature=0), graph=graph, verbose=True)Refresh graph schema information‚ÄãIf the schema of database changes, you can refresh the schema information needed to generate Cypher statements.# graph.refresh_schema()print(graph.get_schema)    Node properties: [{'properties': [('name', 'STRING')], 'label': 'Movie'}, {'properties': [('name', 'STRING'), ('birthDate', 'STRING')], 'label': 'Person'}]    Relationships properties: [{'properties': [], 'label': 'ActedIn'}]    Relationships: ['(:Person)-[:ActedIn]->(:Movie)']    Querying the graph‚ÄãWe can now use the KuzuQAChain to ask question of the graphchain.run("Who played in The Godfather: Part II?")            > Entering new  chain...    Generated Cypher:    MATCH (p:Person)-[:ActedIn]->(m:Movie {name: 'The Godfather: Part II'}) RETURN p.name    Full Context:    [{'p.name': 'Al Pacino'}, {'p.name': 'Robert De Niro'}]        > Finished chain.    'Al Pacino and Robert De Niro both played in The Godfather: Part II.'chain.run("Robert De Niro played in which movies?")            > Entering new  chain...    Generated Cypher:    MATCH (p:Person {name: 'Robert De Niro'})-[:ActedIn]->(m:Movie)    RETURN m.name    Full Context:    [{'m.name': 'The Godfather: Part II'}]        > Finished chain.    'Robert De Niro played in The Godfather: Part