schema, you can print it using the following statement.print(graph.schema)Node properties are the following:Node name: 'Game', Node properties: [{'property': 'name', 'type': 'str'}]Node name: 'Platform', Node properties: [{'property': 'name', 'type': 'str'}]Node name: 'Genre', Node properties: [{'property': 'name', 'type': 'str'}]Node name: 'Publisher', Node properties: [{'property': 'name', 'type': 'str'}]Relationship properties are the following:The relationships are the following:['(:Game)-[:AVAILABLE_ON]->(:Platform)']['(:Game)-[:HAS_GENRE]->(:Genre)']['(:Game)-[:PUBLISHED_BY]->(:Publisher)']Querying the database‚ÄãTo interact with the OpenAI API, you must configure your API key as an environment variable using the Python os package. This ensures proper authorization for your requests. You can find more information on obtaining your API key here.os.environ["OPENAI_API_KEY"] = "your-key-here"You should create the graph chain using the following script, which will be utilized in the question-answering process based on your graph data. While it defaults to GPT-3.5-turbo, you might also consider experimenting with other models like GPT-4 for notably improved Cypher queries and outcomes. We'll utilize the OpenAI chat, utilizing the key you previously configured. We'll set the temperature to zero, ensuring predictable and consistent answers. Additionally, we'll use our Memgraph-LangChain graph and set the verbose parameter, which defaults to False, to True to receive more detailed messages regarding query generation.chain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, model_name='gpt-3.5-turbo')Now you can start asking questions!response = chain.run("Which platforms is Baldur's Gate 3 available on?")print(response)> Entering new GraphCypherQAChain chain...Generated Cypher:MATCH (g:Game {name: 'Baldur\'s Gate 3'})-[:AVAILABLE_ON]->(p:Platform)RETURN p.nameFull Context:[{'p.name': 'PlayStation 5'}, {'p.name': 'Mac OS'},
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. ->: schema, you can print it using the following statement.print(graph.schema)Node properties are the following:Node name: 'Game', Node properties: [{'property': 'name', 'type': 'str'}]Node name: 'Platform', Node properties: [{'property': 'name', 'type': 'str'}]Node name: 'Genre', Node properties: [{'property': 'name', 'type': 'str'}]Node name: 'Publisher', Node properties: [{'property': 'name', 'type': 'str'}]Relationship properties are the following:The relationships are the following:['(:Game)-[:AVAILABLE_ON]->(:Platform)']['(:Game)-[:HAS_GENRE]->(:Genre)']['(:Game)-[:PUBLISHED_BY]->(:Publisher)']Querying the database‚ÄãTo interact with the OpenAI API, you must configure your API key as an environment variable using the Python os package. This ensures proper authorization for your requests. You can find more information on obtaining your API key here.os.environ["OPENAI_API_KEY"] = "your-key-here"You should create the graph chain using the following script, which will be utilized in the question-answering process based on your graph data. While it defaults to GPT-3.5-turbo, you might also consider experimenting with other models like GPT-4 for notably improved Cypher queries and outcomes. We'll utilize the OpenAI chat, utilizing the key you previously configured. We'll set the temperature to zero, ensuring predictable and consistent answers. Additionally, we'll use our Memgraph-LangChain graph and set the verbose parameter, which defaults to False, to True to receive more detailed messages regarding query generation.chain = GraphCypherQAChain.from_llm(    ChatOpenAI(temperature=0), graph=graph, verbose=True, model_name='gpt-3.5-turbo')Now you can start asking questions!response = chain.run("Which platforms is Baldur's Gate 3 available on?")print(response)> Entering new GraphCypherQAChain chain...Generated Cypher:MATCH (g:Game {name: 'Baldur\'s Gate 3'})-[:AVAILABLE_ON]->(p:Platform)RETURN p.nameFull Context:[{'p.name': 'PlayStation 5'}, {'p.name': 'Mac OS'},