{
  "name": "Jarvis – Künstler-Steckbrief",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "kuenstler",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000001",
      "name": "Knopf in Jarvis",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 300],
      "webhookId": "b7f0c2a4-6f2e-4c1a-9d1e-6a2b3c4d5e01"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:8765/api/kuenstler/knopf",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ name: $json.body.name, song: $json.body.song || '', quelle: $json.body.quelle || 'Knopf' }) }}",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000002",
      "name": "In Datenbank nachsehen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose" },
          "conditions": [
            {
              "id": "c1000000-0000-4000-8000-000000000001",
              "leftValue": "={{ $json.zusammenfassung || '' }}",
              "rightValue": "",
              "operator": { "type": "string", "operation": "empty", "singleValue": true }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000003",
      "name": "Schon ein Steckbrief da?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [440, 300]
    },
    {
      "parameters": {
        "url": "https://de.wikipedia.org/w/api.php",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            { "name": "action", "value": "query" },
            { "name": "format", "value": "json" },
            { "name": "generator", "value": "search" },
            { "name": "gsrsearch", "value": "={{ $('In Datenbank nachsehen').item.json.name }} Musik" },
            { "name": "gsrlimit", "value": "1" },
            { "name": "prop", "value": "extracts|info" },
            { "name": "exintro", "value": "1" },
            { "name": "explaintext", "value": "1" },
            { "name": "inprop", "value": "url" }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "User-Agent", "value": "JarvisNowPlaying/1.0 (private home music display)" }
          ]
        },
        "options": { "response": { "response": { "neverError": true } }, "timeout": 20000 }
      },
      "id": "a1000000-0000-4000-8000-000000000004",
      "name": "Wikipedia fragen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [660, 200]
    },
    {
      "parameters": {
        "jsCode": "const k = $('In Datenbank nachsehen').first().json;\nconst pages = ($input.first().json.query || {}).pages || {};\nconst p = Object.values(pages)[0] || {};\nconst text = (p.extract || '').slice(0, 4000);\nreturn [{ json: { name: k.name, neu: k.neu, wiki_titel: p.title || '', wiki_url: p.fullurl || '', text } }];"
      },
      "id": "a1000000-0000-4000-8000-000000000005",
      "name": "Wikipedia-Text herausziehen",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [880, 200]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:11434/api/chat",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'gemma4:e4b', stream: false, think: false, format: 'json', options: { temperature: 0.2, num_ctx: 4096 }, messages: [ { role: 'system', content: 'Du bist Jarvis, der Musik-Assistent von Claus. Antworte nur mit JSON: {\"zusammenfassung\": \"hoechstens drei kurze deutsche Saetze ueber den Kuenstler\", \"genre\": \"Musikrichtung, kurz\", \"herkunft\": \"Stadt und/oder Land\"}. Nutze nur den gegebenen Text. Wenn der Text nicht zum Kuenstler passt oder leer ist, setze alle Felder auf leere Strings.' }, { role: 'user', content: 'Kuenstler: ' + $json.name + '\\n\\nText:\\n' + ($json.text || '(leer)') } ] }) }}",
        "options": { "timeout": 180000 }
      },
      "id": "a1000000-0000-4000-8000-000000000006",
      "name": "Ollama fasst zusammen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1100, 200]
    },
    {
      "parameters": {
        "jsCode": "const w = $('Wikipedia-Text herausziehen').first().json;\nlet a = {};\ntry { a = JSON.parse($input.first().json.message.content); } catch (e) { a = {}; }\nconst felder = { zusammenfassung: a.zusammenfassung || '', genre: a.genre || '', herkunft: a.herkunft || '', wiki_titel: w.wiki_titel, wiki_url: w.wiki_url, quelle: 'Ollama (gemma4:e4b) aus Wikipedia' };\nconst texte = w.text ? [{ art: 'wikipedia', inhalt: w.text, quelle: w.wiki_url || 'de.wikipedia.org' }] : [];\nreturn [{ json: { name: w.name, felder, texte } }];"
      },
      "id": "a1000000-0000-4000-8000-000000000007",
      "name": "Antwort lesen",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1320, 200]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:8765/api/kuenstler/update",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000008",
      "name": "In Datenbank speichern",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1540, 200]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ ok: true, name: $json.name, neu: $('In Datenbank nachsehen').first().json.neu, in_sammlung: $json.in_sammlung, titel: $json.titel_anzahl, zusammenfassung: $json.zusammenfassung, genre: $json.genre, herkunft: $json.herkunft, quelle: 'neu recherchiert' }) }}",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000009",
      "name": "Antwort an Jarvis (neu)",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [1760, 200]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ ok: true, name: $json.name, neu: false, in_sammlung: $json.in_sammlung, titel: $json.titel_anzahl, zusammenfassung: $json.zusammenfassung, genre: $json.genre, herkunft: $json.herkunft, quelle: 'aus der Datenbank' }) }}",
        "options": {}
      },
      "id": "a1000000-0000-4000-8000-000000000010",
      "name": "Antwort an Jarvis (bekannt)",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [660, 420]
    }
  ],
  "connections": {
    "Knopf in Jarvis": { "main": [[{ "node": "In Datenbank nachsehen", "type": "main", "index": 0 }]] },
    "In Datenbank nachsehen": { "main": [[{ "node": "Schon ein Steckbrief da?", "type": "main", "index": 0 }]] },
    "Schon ein Steckbrief da?": { "main": [
      [{ "node": "Wikipedia fragen", "type": "main", "index": 0 }],
      [{ "node": "Antwort an Jarvis (bekannt)", "type": "main", "index": 0 }]
    ] },
    "Wikipedia fragen": { "main": [[{ "node": "Wikipedia-Text herausziehen", "type": "main", "index": 0 }]] },
    "Wikipedia-Text herausziehen": { "main": [[{ "node": "Ollama fasst zusammen", "type": "main", "index": 0 }]] },
    "Ollama fasst zusammen": { "main": [[{ "node": "Antwort lesen", "type": "main", "index": 0 }]] },
    "Antwort lesen": { "main": [[{ "node": "In Datenbank speichern", "type": "main", "index": 0 }]] },
    "In Datenbank speichern": { "main": [[{ "node": "Antwort an Jarvis (neu)", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "active": false,
  "id": "JarvisKuenstlr01",
  "pinData": {}
}
