Template multi-agents récursif

Intermédiaire

Ceci est unAI, Marketingworkflow d'automatisation du domainecontenant 11 nœuds.Utilise principalement des nœuds comme If, Set, Code, Agent, ChatTrigger, combinant la technologie d'intelligence artificielle pour une automatisation intelligente. Générer un contenu écrit avec un agent d'écriture et d'édition récursif GPT-4o

Prérequis
  • Clé API OpenAI
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "UnFtEvTPouN6XIIH",
  "meta": {
    "instanceId": "ea11c547d31842d8c1ffb2f9490761ea576cf90dbdb1ce86a951bf99131d1a44",
    "templateCredsSetupCompleted": true
  },
  "name": "Recursive Multi-Agent TEMPLATE",
  "tags": [],
  "nodes": [
    {
      "id": "84b115d5-0c47-4bc9-8997-e45c16e3aa18",
      "name": "Lors de la réception d'un message de chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        40,
        0
      ],
      "webhookId": "037b5b5d-7a59-4812-8327-42f9c7812d5d",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "085fd153-5564-4920-b278-e5fc93f32134",
      "name": "Mémoire tampon de fenêtre",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        920,
        280
      ],
      "parameters": {
        "sessionKey": "={{ $('When chat message received').item.json.sessionId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "0220fe2a-8e8e-4d11-803e-b942f1cf16c5",
      "name": "Définir des variables",
      "type": "n8n-nodes-base.set",
      "position": [
        1380,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "25fcda79-c515-4e2e-bfc0-3b13259c33a0",
              "name": "status",
              "type": "string",
              "value": "={{ $json.output.status }}"
            },
            {
              "id": "26f212df-ed09-4372-ad2f-e069698ab33c",
              "name": "edits",
              "type": "string",
              "value": "={{ $json.output.edits }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0dc0e194-4129-42e3-aedd-6fbd6b875338",
      "name": "chatInput",
      "type": "n8n-nodes-base.set",
      "position": [
        260,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "709fb115-0654-48f6-bbdd-d0661b1135ba",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.chatInput }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "426831d6-2ddb-4ede-99a7-c0c504e6687f",
      "name": "Analyseur de sortie structurée",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1200,
        280
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"status\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"edits\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "4be8a98c-c01f-4e8c-bec7-c6ef4119c392",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        680,
        280
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "93qOKf12nDGJSW30",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b22dd35c-5df2-4966-a7b6-4b146c5d9a09",
      "name": "Gérer les modifications",
      "type": "n8n-nodes-base.code",
      "position": [
        460,
        0
      ],
      "parameters": {
        "jsCode": "let edits = \"\";\ntry {\n\t// Try to retrieve the edits from the node named \"Edit Fields\"\n\tedits =  $node[\"set variables\"].json[\"edits\"] || \"\";\n} catch (err) {\n\t// If the node hasn't executed or its data isn't available, default to empty string\n\tedits = \"\";\n}\nreturn { edits };"
      },
      "typeVersion": 2
    },
    {
      "id": "85524870-798a-4561-a227-06c8f0aa3c26",
      "name": "Si le statut est complet",
      "type": "n8n-nodes-base.if",
      "position": [
        1600,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d2c4ff3a-1674-4edf-b0a0-153543f52900",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Editing Agent').item.json.output.status }}",
              "rightValue": "complete"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e28c4317-1e16-445f-8119-7d53937b651b",
      "name": "Agent de Rédaction",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        660,
        0
      ],
      "parameters": {
        "text": "=Always review chat history.\n\nWrite a blurb based on my input topic:\n{{ $('chatInput').item.json.chatInput }}\n\nIf there are any suggested edits, make sure to incorporated them into the blurb:\n{{ $json.edits }}\n\nONLY OUTPUT THE BLURB, NO ADDITIONAL WORDS. ",
        "options": {
          "systemMessage": "=You are a writer. Write a short blurb about the topic given to you by the user. "
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "fe9d9f32-8be3-49a7-8699-322192e16474",
      "name": "Agent d'Édition",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "maxTries": 5,
      "position": [
        1020,
        0
      ],
      "parameters": {
        "text": "=You are an editor. \n\nReview the input and recommend specific edits to improve the writing. \n\nYou are working with a writing agent that should implement your edits. \n\nHere are the variables that you output and what they mean:\n- status: this is either \"complete\" or \"incomplete\" output string. Once the writing agent implements your edits, you should set \"status\" = \"complete\". If this is the first time you've reviewed their work, status should be set to \"incomplete\". If the writing agent did not correctly implement your edits, you should set status to \"incomplete\".\n- edits: this is your specific suggested edits. The writing agent will be able to see these edits and update the text to incorporate the edits.\n\nUse the structured output parser and output clean JSON in this format (example):\n{\n\"status\": \"complete\",\n\"edits\": \"The writing agent has successfully implemented all the suggested edits. The text is now concise, informative, and focused on the main point while providing a brief introduction to AI. No further edits are necessary at this time.\"\n}\n\nDO NOT INCLUDE ANY OTHER TEXT BESIDES THE JSON OUTPUT.\n\nHere is the input text from the writing agent:\n{{ $json.output }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": false,
      "typeVersion": 1.7
    },
    {
      "id": "e77541dd-0774-4545-a846-0106aa79fbf5",
      "name": "chatOutput",
      "type": "n8n-nodes-base.set",
      "position": [
        1820,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "753c404e-fce4-4173-95d2-6fde9c543d5f",
              "name": "output",
              "type": "string",
              "value": "={{ $('Writing Agent').first().json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "549707c8-55db-4e8e-aecc-68615b6034ee",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 320,
        "content": "## Writing Agent\nThis agent writes and rewrites based on feedback from the editing agent."
      },
      "typeVersion": 1
    },
    {
      "id": "67c3ebb8-6d81-4add-a882-07fd0cc86f50",
      "name": "Note adhésive1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        -160
      ],
      "parameters": {
        "color": 5,
        "width": 340,
        "height": 320,
        "content": "## Editing Agent\nThis agent suggest edits to improve the writing output of the writing agent. It then evaluates whether the edits were incorporated into the writing."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8b9969b0-ae7b-45c0-9f41-72ea972d67cb",
  "connections": {
    "0dc0e194-4129-42e3-aedd-6fbd6b875338": {
      "main": [
        [
          {
            "node": "b22dd35c-5df2-4966-a7b6-4b146c5d9a09",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b22dd35c-5df2-4966-a7b6-4b146c5d9a09": {
      "main": [
        [
          {
            "node": "e28c4317-1e16-445f-8119-7d53937b651b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fe9d9f32-8be3-49a7-8699-322192e16474": {
      "main": [
        [
          {
            "node": "0220fe2a-8e8e-4d11-803e-b942f1cf16c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e28c4317-1e16-445f-8119-7d53937b651b": {
      "main": [
        [
          {
            "node": "fe9d9f32-8be3-49a7-8699-322192e16474",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0220fe2a-8e8e-4d11-803e-b942f1cf16c5": {
      "main": [
        [
          {
            "node": "85524870-798a-4561-a227-06c8f0aa3c26",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4be8a98c-c01f-4e8c-bec7-c6ef4119c392": {
      "ai_languageModel": [
        [
          {
            "node": "e28c4317-1e16-445f-8119-7d53937b651b",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "fe9d9f32-8be3-49a7-8699-322192e16474",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "85524870-798a-4561-a227-06c8f0aa3c26": {
      "main": [
        [
          {
            "node": "e77541dd-0774-4545-a846-0106aa79fbf5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "b22dd35c-5df2-4966-a7b6-4b146c5d9a09",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "085fd153-5564-4920-b278-e5fc93f32134": {
      "ai_memory": [
        [
          {
            "node": "fe9d9f32-8be3-49a7-8699-322192e16474",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "e28c4317-1e16-445f-8119-7d53937b651b",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "426831d6-2ddb-4ede-99a7-c0c504e6687f": {
      "ai_outputParser": [
        [
          {
            "node": "fe9d9f32-8be3-49a7-8699-322192e16474",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "84b115d5-0c47-4bc9-8997-e45c16e3aa18": {
      "main": [
        [
          {
            "node": "0dc0e194-4129-42e3-aedd-6fbd6b875338",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

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 - Intelligence Artificielle, Marketing

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.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds11
Catégorie2
Types de nœuds8
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
Matty Reed

Matty Reed

@mattyreed1

Student and Teacher | Designer and Builder | Helping Founders Flourish

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34