Construcción de una red de conocimiento académica con PDF vectoriales, GPT-4 y Neo4j
Este es unAI RAG, Multimodal AIflujo de automatización del dominio deautomatización que contiene 10 nodos.Utiliza principalmente nodos como Code, Neo4j, OpenAi, Postgres, PdfVector. Construir un grafo de conocimiento académico a partir de artículos de investigación usando PDF vectors, GPT-4 y Neo4j
- •Clave de API de OpenAI
- •Información de conexión de la base de datos PostgreSQL
Nodos utilizados (10)
Categoría
{
"meta": {
"instanceId": "placeholder"
},
"nodes": [
{
"id": "kb-info",
"name": "Información de la Base de Conocimiento",
"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": "Actualización Diaria de la KB",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
450,
300
],
"parameters": {
"rule": {
"interval": [
{
"field": "days",
"daysInterval": 1
}
]
}
},
"typeVersion": 1
},
{
"id": "fetch-papers",
"name": "PDF Vector - Obtener Artículos",
"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 - Analizar Artículos",
"type": "n8n-nodes-pdfvector.pdfVector",
"position": [
850,
300
],
"parameters": {
"useLlm": "always",
"resource": "document",
"operation": "parse",
"documentUrl": "={{ $json.pdfUrl }}"
},
"typeVersion": 1
},
{
"id": "extract-entities",
"name": "Extraer Entidades",
"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": "Construir Estructura del Grafo",
"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": "Crear Nodos del Grafo",
"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": "Crear Relaciones",
"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": "Estadísticas de la 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": "Registrar Actualización de la 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
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Intermedio - RAG de IA, IA Multimodal
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
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.
Compartir este flujo de trabajo