Construction d'un graphe de connaissances académique avec des vecteurs PDF, GPT-4 et Neo4j
Ceci est unAI RAG, Multimodal AIworkflow d'automatisation du domainecontenant 10 nœuds.Utilise principalement des nœuds comme Code, Neo4j, OpenAi, Postgres, PdfVector. Construire un graphe de connaissances académique à partir d'articles de recherche avec PDF vector, GPT-4 et Neo4j
- •Clé API OpenAI
- •Informations de connexion à la base de données PostgreSQL
Nœuds utilisés (10)
Catégorie
{
"meta": {
"instanceId": "placeholder"
},
"nodes": [
{
"id": "kb-info",
"name": "Infos Base de Connaissances",
"type": "n8n-nodes-base.stickyNote",
"position": [
250,
150
],
"parameters": {
"content": "## Knowledge Base Builder\n\nExtracts and connects:\n- Concepts & Keywords\n- Authors & Institutions\n- Methods & Datasets\n- Citations & References\n\nBuilds searchable knowledge graph"
},
"typeVersion": 1
},
{
"id": "daily-update",
"name": "Mise à Jour Quotidienne KB",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
450,
300
],
"parameters": {
"rule": {
"interval": [
{
"field": "days",
"daysInterval": 1
}
]
}
},
"typeVersion": 1
},
{
"id": "fetch-papers",
"name": "PDF Vector - Récupérer les Articles",
"type": "n8n-nodes-pdfvector.pdfVector",
"position": [
650,
300
],
"parameters": {
"limit": 20,
"query": "={{ $json.domain || 'artificial intelligence' }}",
"fields": [
"title",
"authors",
"abstract",
"year",
"doi",
"pdfUrl",
"totalCitations"
],
"resource": "academic",
"yearFrom": "={{ new Date().getFullYear() }}",
"operation": "search",
"providers": [
"semantic_scholar",
"arxiv"
]
},
"typeVersion": 1
},
{
"id": "parse-papers",
"name": "PDF Vector - Analyser les Articles",
"type": "n8n-nodes-pdfvector.pdfVector",
"position": [
850,
300
],
"parameters": {
"useLlm": "always",
"resource": "document",
"operation": "parse",
"documentUrl": "={{ $json.pdfUrl }}"
},
"typeVersion": 1
},
{
"id": "extract-entities",
"name": "Extraire les Entités",
"type": "n8n-nodes-base.openAi",
"position": [
1050,
300
],
"parameters": {
"model": "gpt-4",
"options": {
"responseFormat": {
"type": "json_object"
}
},
"messages": {
"values": [
{
"content": "Extract knowledge graph entities from this paper:\n\nTitle: {{ $json.title }}\nContent: {{ $json.content }}\n\nExtract:\n1. Key concepts (5-10 main ideas)\n2. Methods used\n3. Datasets mentioned\n4. Research questions\n5. Key findings\n6. Future directions\n\nAlso identify relationships between these entities.\n\nReturn as structured JSON with entities and relationships arrays."
}
]
}
},
"typeVersion": 1
},
{
"id": "build-graph",
"name": "Construire la Structure du Graphe",
"type": "n8n-nodes-base.code",
"position": [
1250,
300
],
"parameters": {
"functionCode": "const extraction = JSON.parse($json.content);\nconst paper = $node['PDF Vector - Fetch Papers'].json;\n\n// Create nodes for Neo4j\nconst nodes = [];\n\n// Paper node\nnodes.push({\n label: 'Paper',\n properties: {\n id: paper.doi || paper.title.replace(/[^a-zA-Z0-9]/g, ''),\n title: paper.title,\n year: paper.year,\n authors: paper.authors.join('; '),\n citations: paper.totalCitations\n }\n});\n\n// Author nodes\npaper.authors.forEach(author => {\n nodes.push({\n label: 'Author',\n properties: {\n name: author\n }\n });\n});\n\n// Concept nodes\nextraction.concepts?.forEach(concept => {\n nodes.push({\n label: 'Concept',\n properties: {\n name: concept\n }\n });\n});\n\n// Method nodes\nextraction.methods?.forEach(method => {\n nodes.push({\n label: 'Method',\n properties: {\n name: method\n }\n });\n});\n\n// Create relationships\nconst relationships = [];\n\n// Paper-Author relationships\npaper.authors.forEach(author => {\n relationships.push({\n from: paper.doi || paper.title,\n to: author,\n type: 'AUTHORED_BY'\n });\n});\n\n// Paper-Concept relationships\nextraction.concepts?.forEach(concept => {\n relationships.push({\n from: paper.doi || paper.title,\n to: concept,\n type: 'DISCUSSES'\n });\n});\n\n// Paper-Method relationships\nextraction.methods?.forEach(method => {\n relationships.push({\n from: paper.doi || paper.title,\n to: method,\n type: 'USES'\n });\n});\n\nreturn { nodes, relationships };"
},
"typeVersion": 1
},
{
"id": "create-nodes",
"name": "Créer les Nœuds du Graphe",
"type": "n8n-nodes-base.neo4j",
"position": [
1450,
250
],
"parameters": {
"query": "=UNWIND $nodes AS node\nMERGE (n:Node {id: node.properties.id})\nSET n += node.properties\nSET n:${node.label}",
"operation": "create",
"parameters": "={{ { nodes: $json.nodes } }}"
},
"typeVersion": 1
},
{
"id": "create-relationships",
"name": "Créer les Relations",
"type": "n8n-nodes-base.neo4j",
"position": [
1450,
350
],
"parameters": {
"query": "=UNWIND $relationships AS rel\nMATCH (a {id: rel.from})\nMATCH (b {id: rel.to})\nMERGE (a)-[r:${rel.type}]->(b)",
"operation": "create",
"parameters": "={{ { relationships: $json.relationships } }}"
},
"typeVersion": 1
},
{
"id": "kb-stats",
"name": "Statistiques KB",
"type": "n8n-nodes-base.code",
"position": [
1650,
300
],
"parameters": {
"functionCode": "// Generate knowledge base statistics\nconst stats = {\n papersProcessed: $items().length,\n conceptsExtracted: $json.nodes.filter(n => n.label === 'Concept').length,\n authorsAdded: $json.nodes.filter(n => n.label === 'Author').length,\n methodsIdentified: $json.nodes.filter(n => n.label === 'Method').length,\n timestamp: new Date().toISOString()\n};\n\nreturn stats;"
},
"typeVersion": 1
},
{
"id": "log-update",
"name": "Journaliser la Mise à Jour KB",
"type": "n8n-nodes-base.postgres",
"position": [
1850,
300
],
"parameters": {
"table": "kb_updates",
"columns": "papers_processed,concepts,authors,methods,updated_at",
"operation": "insert"
},
"typeVersion": 1
}
],
"connections": {
"kb-stats": {
"main": [
[
{
"node": "log-update",
"type": "main",
"index": 0
}
]
]
},
"daily-update": {
"main": [
[
{
"node": "fetch-papers",
"type": "main",
"index": 0
}
]
]
},
"extract-entities": {
"main": [
[
{
"node": "build-graph",
"type": "main",
"index": 0
}
]
]
},
"create-nodes": {
"main": [
[
{
"node": "kb-stats",
"type": "main",
"index": 0
}
]
]
},
"create-relationships": {
"main": [
[
{
"node": "kb-stats",
"type": "main",
"index": 0
}
]
]
},
"build-graph": {
"main": [
[
{
"node": "create-nodes",
"type": "main",
"index": 0
},
{
"node": "create-relationships",
"type": "main",
"index": 0
}
]
]
},
"fetch-papers": {
"main": [
[
{
"node": "parse-papers",
"type": "main",
"index": 0
}
]
]
},
"parse-papers": {
"main": [
[
{
"node": "extract-entities",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Intermédiaire - RAG IA, IA Multimodale
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
PDF Vector
@pdfvectorA fully featured PDF APIs for developers - Parse any PDF or Word document, extract structured data, and access millions of academic papers - all through simple APIs.
Partager ce workflow