Session 17 of Going Meta, broadcast on June 1, 2023, demonstrates a live loop between OpenAI’s Completions and Chat APIs and a Neo4j knowledge graph. Jesus Barrasa shows how to ask an LLM a factual question, receive the answer serialised as RDF Turtle (using schema.org and Wikidata URIs), and immediately import that RDF back into Neo4j using neosemantics — all from within a single Cypher statement powered by APOC.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jbarrasa/goingmeta/llms.txt
Use this file to discover all available pages before exploring further.
What You’ll Learn
- How to call OpenAI directly from Cypher using
apoc.ml.openai.chatandapoc.ml.openai.completion - How to initialise a Neo4j database for RDF ingestion with neosemantics (n10s)
- How to chain an OpenAI call with an
n10s.rdf.preview.inlineor import call in one query - How RDF-ified LLM output produces a queryable, linkable knowledge graph
Prerequisites
APOC Library
APOC must be installed and
apoc.ml.openai.* procedures must be enabled in your Neo4j instance.neosemantics (n10s)
Install the n10s plugin to enable RDF import/export procedures in Neo4j.
Step-by-Step Walkthrough
Initialise the database for RDF
Before importing any RDF you must create the uniqueness constraint and initialise the graph configuration:
Without this step, any subsequent RDF import call will fail with
"A Graph Config is required for RDF importing procedures to run".Prompt ChatGPT interactively
The session starts with a sequence of manual ChatGPT prompts to explore what the LLM knows about Rafa Nadal’s commercial endorsements:This iterative prompting shows how the LLM can be guided to produce graph-ready RDF output.
Call OpenAI from Cypher with apoc.ml.openai.chat
Set your API key and message array as Cypher parameters, then invoke the chat procedure:The
value map contains the full API response including the generated RDF in the choices array.Key Concepts
APOC ML Procedures
apoc.ml.openai.chat and apoc.ml.openai.completion expose OpenAI’s API directly inside Cypher queries, eliminating the need for external Python glue code.RDF as the Bridge
Asking the LLM to respond in RDF Turtle (with schema.org and Wikidata URIs) means the output is immediately importable into any n10s-enabled Neo4j database.
Wikidata URIs
Using Wikidata identifiers ensures that entities created by the LLM can be linked to the broader Linked Data web and to existing nodes in your graph.
Iterative Prompting
The session demonstrates how successive prompt refinements — adding JSON format, RDF format, specific vocabularies — improve the graph-readiness of LLM output.
Resources
Watch the Recording
Full session recording on YouTube — June 1, 2023.
Session Code
All queries and prompts from this session on GitHub.