Traitement groupé de requêtes avec l'API Anthropic Claude

Avancé

Ceci est unBuilding Blocks, AIworkflow d'automatisation du domainecontenant 39 nœuds.Utilise principalement des nœuds comme If, Set, Code, Wait, Merge, combinant la technologie d'intelligence artificielle pour une automatisation intelligente. Traitement groupé de requêtes avec l'API Claude d'Anthropic

Prérequis
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
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
{
  "meta": {
    "instanceId": "97d44c78f314fab340d7a5edaf7e2c274a7fbb8a7cd138f53cc742341e706fe7"
  },
  "nodes": [
    {
      "id": "fa4f8fd6-3272-4a93-8547-32d13873bbc1",
      "name": "Soumettre le lot",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        180,
        40
      ],
      "parameters": {
        "url": "https://api.anthropic.com/v1/messages/batches",
        "method": "POST",
        "options": {},
        "jsonBody": "={ \"requests\": {{ JSON.stringify($json.requests) }} }",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "={{ $json[\"anthropic-version\"] }}"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "id": "ub0zN7IP2V83OeTf",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2916dc85-829d-491a-a7a8-de79d5356a53",
      "name": "Vérifier l'état du lot",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        840,
        115
      ],
      "parameters": {
        "url": "=https://api.anthropic.com/v1/messages/batches/{{ $json.id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "={{ $('When Executed by Another Workflow').item.json[\"anthropic-version\"] }}"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "id": "ub0zN7IP2V83OeTf",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1552ec92-2f18-42f6-b67f-b6f131012b3c",
      "name": "Lorsqu'exécuté par un autre workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -40,
        40
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "anthropic-version"
            },
            {
              "name": "requests",
              "type": "array"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "4bd40f02-caf1-419d-8261-a149cd51a534",
      "name": "Obtenir les résultats",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        620,
        -160
      ],
      "parameters": {
        "url": "={{ $json.results_url }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "={{ $('When Executed by Another Workflow').item.json[\"anthropic-version\"] }}"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "id": "ub0zN7IP2V83OeTf",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5df366af-a54d-4594-a1ab-7a9df968101e",
      "name": "Analyser la réponse",
      "type": "n8n-nodes-base.code",
      "notes": "JSONL separated by newlines",
      "position": [
        840,
        -160
      ],
      "parameters": {
        "jsCode": "for (const item of $input.all()) {\n  if (item.json && item.json.data) {\n    // Split the string into individual JSON objects\n    const jsonStrings = item.json.data.split('\\n');\n\n    // Parse each JSON string and store them in an array\n    const parsedData = jsonStrings.filter(str => str.trim() !== '').map(str => JSON.parse(str));\n\n    // Replace the original json with the parsed array.\n    item.json.parsed = parsedData;\n  }\n}\n\nreturn $input.all();"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "68aa4ee2-e925-4e30-a7ab-317d8df4d9bc",
      "name": "Si le traitement est terminé",
      "type": "n8n-nodes-base.if",
      "position": [
        400,
        40
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9494c5a3-d093-49c5-837f-99cd700a2f13",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.processing_status }}",
              "rightValue": "ended"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2b974e3b-495b-48af-8080-c7913d7a2ba8",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -720
      ],
      "parameters": {
        "width": 1060,
        "height": 520,
        "content": "### This workflow automates sending batched prompts to Claude using the Anthropic API. It submits multiple prompts at once and retrieves the results.\n\n#### How to use\n\nCall this workflow with array of `requests`\n\n```json\n{\n    \"anthropic-version\": \"2023-06-01\",\n    \"requests\": [\n        {\n            \"custom_id\": \"first-prompt-in-my-batch\",\n            \"params\": {\n                \"max_tokens\": 100,\n                \"messages\": [\n                    {\n                        \"content\": \"Hey Claude, tell me a short fun fact about video games!\",\n                        \"role\": \"user\"\n                    }\n                ],\n                \"model\": \"claude-3-5-haiku-20241022\"\n            }\n        }\n    ]\n}\n```\n"
      },
      "typeVersion": 1
    },
    {
      "id": "928a30b5-5d90-4648-a82e-e4f1a01e47a5",
      "name": "Note adhésive 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -720
      ],
      "parameters": {
        "width": 980,
        "height": 600,
        "content": "#### Results\n\nThis workflow returns an array of results with custom_ids.\n\n```json\n[\n    {\n        \"custom_id\": \"first-prompt-in-my-batch\",\n        \"result\": {\n            \"message\": {\n                \"content\": [\n                    {\n                        \"text\": \"Did you know that the classic video game Tetris was...\",\n                        \"type\": \"text\"\n                    }\n                ],\n                \"id\": \"msg_01AiLiVZT18XnoBD4r2w9x2t\",\n                \"model\": \"claude-3-5-haiku-20241022\",\n                \"role\": \"assistant\",\n                \"stop_reason\": \"end_turn\",\n                \"stop_sequence\": null,\n                \"type\": \"message\",\n                \"usage\": {\n                    \"cache_creation_input_tokens\": 0,\n                    \"cache_read_input_tokens\": 0,\n                    \"input_tokens\": 45,\n                    \"output_tokens\": 83\n                }\n            },\n            \"type\": \"succeeded\"\n        }\n    }\n]\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "5dcb554e-32df-4883-b5a1-b40305756201",
      "name": "Intervalle d'interrogation de l'état du lot",
      "type": "n8n-nodes-base.wait",
      "position": [
        620,
        40
      ],
      "webhookId": "7efafe72-063a-45c6-8775-fcec14e1d263",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "c25cfde5-ab83-4e5a-a66f-8cc9f23a01f6",
      "name": "Note adhésive 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        325
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 620,
        "content": "# Usage example"
      },
      "typeVersion": 1
    },
    {
      "id": "6062ca7c-aa08-4805-9c96-65e5be8a38fd",
      "name": "Exécuter l'exemple",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -40,
        625
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9878729a-123d-4460-a582-691ca8cedf98",
      "name": "Exemple de requête unique",
      "type": "n8n-nodes-base.set",
      "position": [
        634,
        775
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1ea47ba2-64be-4d69-b3db-3447cde71645",
              "name": "query",
              "type": "string",
              "value": "Hey Claude, tell me a short fun fact about bees!"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "df06c209-8b6a-4b6d-8045-230ebdfcfbad",
      "name": "Supprimer les propriétés d'origine",
      "type": "n8n-nodes-base.set",
      "position": [
        1528,
        775
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d238d62b-2e91-4242-b509-8cfc698d2252",
              "name": "custom_id",
              "type": "string",
              "value": "={{ $json.custom_id }}"
            },
            {
              "id": "21e07c09-92e3-41e7-8335-64653722e7e9",
              "name": "params",
              "type": "object",
              "value": "={{ $json.params }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f66d6a89-ee33-4494-9476-46f408976b29",
      "name": "Construire le tableau 'requests'",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1968,
        625
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "requests"
      },
      "typeVersion": 1
    },
    {
      "id": "0f9eb605-d629-4cb7-b9cb-39702d201567",
      "name": "Définir la version 'anthropic' souhaitée",
      "type": "n8n-nodes-base.set",
      "notes": "2023-06-01",
      "position": [
        2188,
        625
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9f9e94a0-304b-487a-8762-d74421ef4cc0",
              "name": "anthropic-version",
              "type": "string",
              "value": "2023-06-01"
            }
          ]
        },
        "includeOtherFields": true
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "f71f261c-f4ad-4c9f-bd72-42ab386a65e1",
      "name": "Exécuter le workflow 'Traiter plusieurs prompts en parallèle avec Anthropic Claude Lot API'",
      "type": "n8n-nodes-base.executeWorkflow",
      "notes": "See above",
      "position": [
        2408,
        625
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": true
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "xQU4byMGhgFxnTIH",
          "cachedResultName": "Process Multiple Prompts in Parallel with Anthropic Claude Batch API"
        },
        "workflowInputs": {
          "value": {
            "requests": "={{ $json.requests }}",
            "anthropic-version": "={{ $json['anthropic-version'] }}"
          },
          "schema": [
            {
              "id": "anthropic-version",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "anthropic-version",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "requests",
              "type": "array",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "requests",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "requests"
          ],
          "attemptToConvertTypes": true,
          "convertFieldsToString": true
        }
      },
      "notesInFlow": true,
      "typeVersion": 1.2
    },
    {
      "id": "bd27c1a6-572c-420d-84ab-4d8b7d14311b",
      "name": "Construire l'objet 'request' de lot pour une requête unique",
      "type": "n8n-nodes-base.code",
      "position": [
        1308,
        775
      ],
      "parameters": {
        "jsCode": "// Loop over input items and modify them to match the response example, then return input.all()\nfor (const item of $input.all()) {\n  item.json.params = {\n    max_tokens: item.json.max_tokens,\n    messages: [\n      {\n        content: item.json.query,\n        role: \"user\"\n      }\n    ],\n    model: item.json.model\n  };\n}\n\nreturn $input.all();\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fa342231-ea94-43ab-8808-18c8d04fdaf8",
      "name": "Simple Memory Store",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        644,
        595
      ],
      "parameters": {
        "sessionKey": "\"Process Multiple Prompts in Parallel with Anthropic Claude Batch API example\"",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "67047fe6-8658-45ba-be61-52cf6115f4e4",
      "name": "Remplir la mémoire de chat avec des exemples de données",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        556,
        375
      ],
      "parameters": {
        "mode": "insert",
        "messages": {
          "messageValues": [
            {
              "message": "You are a helpful AI assistant"
            },
            {
              "type": "user",
              "message": "Hey Claude, tell me a short fun fact about video games!"
            },
            {
              "type": "ai",
              "message": "short fun fact about video games!"
            },
            {
              "type": "user",
              "message": "No, an actual fun fact"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "dbb295b8-01fd-445f-ab66-948442b6c71d",
      "name": "Construire l'objet 'request' de lot à partir de la mémoire de chat et des données d'exécution",
      "type": "n8n-nodes-base.code",
      "position": [
        1528,
        475
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (const item of $input.all()) {\n  const inputMessages = item.json.messages;\n  const customId = item.json.custom_id;\n  const model = item.json.model;\n  const maxTokens = item.json.max_tokens;\n\n  if (inputMessages && inputMessages.length > 0) {\n    let systemMessageContent = undefined;\n    const transformedMessages = [];\n\n    // Process each message entry in sequence\n    for (const messageObj of inputMessages) {\n      // Extract system message if present\n      if ('system' in messageObj) {\n        systemMessageContent = messageObj.system;\n      }\n      \n      // Process human and AI messages in the order they appear in the object keys\n      // We need to determine what order the keys appear in the original object\n      const keys = Object.keys(messageObj);\n      \n      for (const key of keys) {\n        if (key === 'human') {\n          transformedMessages.push({\n            role: \"user\",\n            content: messageObj.human\n          });\n        } else if (key === 'ai') {\n          transformedMessages.push({\n            role: \"assistant\",\n            content: messageObj.ai\n          });\n        }\n        // Skip 'system' as we already processed it\n      }\n    }\n\n    const params = {\n      model: model,\n      max_tokens: maxTokens,\n      messages: transformedMessages\n    };\n\n    if (systemMessageContent !== undefined) {\n      params.system = systemMessageContent;\n    }\n\n    output.push({\n      custom_id: customId,\n      params: params\n    });\n  }\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "f9edb335-c33d-45fc-8f9b-12d7f37cc23e",
      "name": "Charger les données de la mémoire de chat",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        932,
        475
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "22399660-ebe5-4838-bad3-c542d6d921a3",
      "name": "Résultat du premier prompt",
      "type": "n8n-nodes-base.executionData",
      "position": [
        2848,
        525
      ],
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "assistant_response",
              "value": "={{ $json.result.message.content[0].text }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0e7f44f4-c931-4e0f-aebc-1b8f0327647f",
      "name": "Résultat du deuxième prompt",
      "type": "n8n-nodes-base.executionData",
      "position": [
        2848,
        725
      ],
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "assistant_response",
              "value": "={{ $json.result.message.content[0].text }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e42b01e0-8fc5-42e1-aa45-aa85477e766b",
      "name": "Séparer les résultats analysés",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1060,
        -160
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "parsed"
      },
      "typeVersion": 1
    },
    {
      "id": "343676b9-f147-4981-b555-8af570374e8c",
      "name": "Filtrer les résultats du deuxième prompt",
      "type": "n8n-nodes-base.filter",
      "position": [
        2628,
        725
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e4b3524-7066-46cc-a365-8d23d08c1bda",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.custom_id }}",
              "rightValue": "={{ $('Append execution data for single query example').item.json.custom_id }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c9f5f366-27c4-4401-965b-67c314036fb6",
      "name": "Filtrer les résultats du premier prompt",
      "type": "n8n-nodes-base.filter",
      "position": [
        2628,
        525
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e4b3524-7066-46cc-a365-8d23d08c1bda",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.custom_id }}",
              "rightValue": "={{ $('Append execution data for chat memory example').item.json.custom_id }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0a5b9c3d-665b-4e35-be9e-c8297314969d",
      "name": "Note adhésive 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        110,
        -100
      ],
      "parameters": {
        "height": 300,
        "content": "## Submit batch request to Anthropic"
      },
      "typeVersion": 1
    },
    {
      "id": "f19813a5-f669-45dd-a446-947a30b02b09",
      "name": "Note adhésive 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        350,
        -5
      ],
      "parameters": {
        "width": 640,
        "height": 300,
        "content": "## Loop until processing status is 'ended'"
      },
      "typeVersion": 1
    },
    {
      "id": "9f424fce-5610-4b85-9be6-4c2c403002db",
      "name": "Note adhésive 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -200
      ],
      "parameters": {
        "width": 280,
        "height": 180,
        "content": "### Retrieve Message Batch Results\n\n[User guide](https://docs.anthropic.com/en/docs/build-with-claude/batch-processing)"
      },
      "typeVersion": 1
    },
    {
      "id": "b87673b1-f08d-4c51-8ee5-4d54557cb382",
      "name": "Note adhésive 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        380
      ],
      "parameters": {
        "color": 5,
        "width": 820,
        "height": 340,
        "content": "# Example usage with Chat History Node"
      },
      "typeVersion": 1
    },
    {
      "id": "d6d8ac02-7005-40a1-9950-9517e98e315c",
      "name": "Note adhésive 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        720
      ],
      "parameters": {
        "width": 1540,
        "height": 220,
        "content": "# Example usage with single query string"
      },
      "typeVersion": 1
    },
    {
      "id": "0d63deb0-dece-4502-9020-d67c1f194466",
      "name": "Note adhésive 8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        320
      ],
      "parameters": {
        "color": 3,
        "width": 660,
        "height": 400,
        "content": "# Environment setup\nFor Chat History Node"
      },
      "typeVersion": 1
    },
    {
      "id": "cab94e09-6b84-4a38-b854-670241744db5",
      "name": "Note adhésive 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2120,
        800
      ],
      "parameters": {
        "height": 220,
        "content": "## anthropic-version\n\n[Documentation](https://docs.anthropic.com/en/api/versioning)\n\nWhen making API requests, you must send an anthropic-version request header. For example, anthropic-version: `2023-06-01` (latest supported version)"
      },
      "typeVersion": 1
    },
    {
      "id": "ab0a51a1-3c84-4a88-968b-fd46ab07de85",
      "name": "Note adhésive 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 480,
        "height": 300,
        "content": "# Example usage with Chat History Node (result)"
      },
      "typeVersion": 1
    },
    {
      "id": "d91b9be7-ef32-48d6-b880-cab0e99ba9bc",
      "name": "Note adhésive 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        700
      ],
      "parameters": {
        "width": 480,
        "height": 300,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Example usage with single query string (result)"
      },
      "typeVersion": 1
    },
    {
      "id": "341811e9-6677-42d9-be28-c388dbf68101",
      "name": "Joindre deux exemples de requêtes dans un tableau",
      "type": "n8n-nodes-base.merge",
      "position": [
        1748,
        625
      ],
      "parameters": {},
      "typeVersion": 3.1
    },
    {
      "id": "45a09f05-7610-4b0a-ab7f-0094c4b3f318",
      "name": "Ajouter les données d'exécution pour l'exemple de requête unique",
      "type": "n8n-nodes-base.set",
      "notes": "custom_id, model and max tokens",
      "position": [
        1010,
        775
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8276602f-689f-45c2-bce0-5df8500912b6",
              "name": "custom_id",
              "type": "string",
              "value": "second-prompt-in-my-batch"
            },
            {
              "id": "2c513dc2-d8cb-4ba3-b3c1-ea79517b9434",
              "name": "model",
              "type": "string",
              "value": "claude-3-5-haiku-20241022"
            },
            {
              "id": "b052140b-1152-4327-9c5a-5030b78990b7",
              "name": "max_tokens",
              "type": "number",
              "value": 100
            }
          ]
        },
        "includeOtherFields": true
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "c4e35349-840c-4c81-852c-0d8cd9331364",
      "name": "Ajouter les données d'exécution pour l'exemple de mémoire de chat",
      "type": "n8n-nodes-base.set",
      "notes": "custom_id, model and max tokens",
      "position": [
        1308,
        475
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8276602f-689f-45c2-bce0-5df8500912b6",
              "name": "custom_id",
              "type": "string",
              "value": "first-prompt-in-my-batch"
            },
            {
              "id": "2c513dc2-d8cb-4ba3-b3c1-ea79517b9434",
              "name": "model",
              "type": "string",
              "value": "claude-3-5-haiku-20241022"
            },
            {
              "id": "b052140b-1152-4327-9c5a-5030b78990b7",
              "name": "max_tokens",
              "type": "number",
              "value": 100
            }
          ]
        },
        "includeOtherFields": true
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "058aedb1-fdfe-4edc-8d51-3b93ec7d232d",
      "name": "Tronquer la mémoire de chat",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "notes": "ensure clean state",
      "position": [
        180,
        475
      ],
      "parameters": {
        "mode": "delete",
        "deleteMode": "all"
      },
      "notesInFlow": true,
      "typeVersion": 1.1
    }
  ],
  "pinData": {},
  "connections": {
    "4bd40f02-caf1-419d-8261-a149cd51a534": {
      "main": [
        [
          {
            "node": "5df366af-a54d-4594-a1ab-7a9df968101e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6062ca7c-aa08-4805-9c96-65e5be8a38fd": {
      "main": [
        [
          {
            "node": "9878729a-123d-4460-a582-691ca8cedf98",
            "type": "main",
            "index": 0
          },
          {
            "node": "058aedb1-fdfe-4edc-8d51-3b93ec7d232d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fa4f8fd6-3272-4a93-8547-32d13873bbc1": {
      "main": [
        [
          {
            "node": "68aa4ee2-e925-4e30-a7ab-317d8df4d9bc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5df366af-a54d-4594-a1ab-7a9df968101e": {
      "main": [
        [
          {
            "node": "e42b01e0-8fc5-42e1-aa45-aa85477e766b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9878729a-123d-4460-a582-691ca8cedf98": {
      "main": [
        [
          {
            "node": "45a09f05-7610-4b0a-ab7f-0094c4b3f318",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2916dc85-829d-491a-a7a8-de79d5356a53": {
      "main": [
        [
          {
            "node": "68aa4ee2-e925-4e30-a7ab-317d8df4d9bc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "68aa4ee2-e925-4e30-a7ab-317d8df4d9bc": {
      "main": [
        [
          {
            "node": "4bd40f02-caf1-419d-8261-a149cd51a534",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "5dcb554e-32df-4883-b5a1-b40305756201",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fa342231-ea94-43ab-8808-18c8d04fdaf8": {
      "ai_memory": [
        [
          {
            "node": "f9edb335-c33d-45fc-8f9b-12d7f37cc23e",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "67047fe6-8658-45ba-be61-52cf6115f4e4",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "058aedb1-fdfe-4edc-8d51-3b93ec7d232d",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "058aedb1-fdfe-4edc-8d51-3b93ec7d232d": {
      "main": [
        [
          {
            "node": "67047fe6-8658-45ba-be61-52cf6115f4e4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f9edb335-c33d-45fc-8f9b-12d7f37cc23e": {
      "main": [
        [
          {
            "node": "c4e35349-840c-4c81-852c-0d8cd9331364",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5dcb554e-32df-4883-b5a1-b40305756201": {
      "main": [
        [
          {
            "node": "2916dc85-829d-491a-a7a8-de79d5356a53",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f66d6a89-ee33-4494-9476-46f408976b29": {
      "main": [
        [
          {
            "node": "0f9eb605-d629-4cb7-b9cb-39702d201567",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "df06c209-8b6a-4b6d-8045-230ebdfcfbad": {
      "main": [
        [
          {
            "node": "341811e9-6677-42d9-be28-c388dbf68101",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "c9f5f366-27c4-4401-965b-67c314036fb6": {
      "main": [
        [
          {
            "node": "22399660-ebe5-4838-bad3-c542d6d921a3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "343676b9-f147-4981-b555-8af570374e8c": {
      "main": [
        [
          {
            "node": "0e7f44f4-c931-4e0f-aebc-1b8f0327647f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0f9eb605-d629-4cb7-b9cb-39702d201567": {
      "main": [
        [
          {
            "node": "f71f261c-f4ad-4c9f-bd72-42ab386a65e1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1552ec92-2f18-42f6-b67f-b6f131012b3c": {
      "main": [
        [
          {
            "node": "fa4f8fd6-3272-4a93-8547-32d13873bbc1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "67047fe6-8658-45ba-be61-52cf6115f4e4": {
      "main": [
        [
          {
            "node": "f9edb335-c33d-45fc-8f9b-12d7f37cc23e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "341811e9-6677-42d9-be28-c388dbf68101": {
      "main": [
        [
          {
            "node": "f66d6a89-ee33-4494-9476-46f408976b29",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c4e35349-840c-4c81-852c-0d8cd9331364": {
      "main": [
        [
          {
            "node": "dbb295b8-01fd-445f-ab66-948442b6c71d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bd27c1a6-572c-420d-84ab-4d8b7d14311b": {
      "main": [
        [
          {
            "node": "df06c209-8b6a-4b6d-8045-230ebdfcfbad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "45a09f05-7610-4b0a-ab7f-0094c4b3f318": {
      "main": [
        [
          {
            "node": "bd27c1a6-572c-420d-84ab-4d8b7d14311b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dbb295b8-01fd-445f-ab66-948442b6c71d": {
      "main": [
        [
          {
            "node": "341811e9-6677-42d9-be28-c388dbf68101",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f71f261c-f4ad-4c9f-bd72-42ab386a65e1": {
      "main": [
        [
          {
            "node": "c9f5f366-27c4-4401-965b-67c314036fb6",
            "type": "main",
            "index": 0
          },
          {
            "node": "343676b9-f147-4981-b555-8af570374e8c",
            "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é ?

Avancé - Blocs de construction, Intelligence Artificielle

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é
Avancé
Nombre de nœuds39
Catégorie2
Types de nœuds16
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Auteur
Greg Evseev

Greg Evseev

@greg

15+ years in AI/ML development & integration. Now specializing in establishing ISO 42001-compliant AI management systems. Background includes AI/ML research, system development, AI governance, and ISO 42001 Lead Auditor training (in progress). Helping organizations: ✓ Evaluate AI maturity & governance ✓ Implement ISO 42001 systems ✓ Bridge technical & regulatory requirements ✓ Design practical AI governance frameworks Expertise: AI Risk Assessment, Compliance Strategy, Technical Due Diligence.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34