{
  "name": "langchain\ud65c\uc6a9\ud55c Agent \uad6c\uc131",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "initialMessages": "",
        "options": {
          "allowedOrigins": "*",
          "loadPreviousSession": "memory",
          "responseMode": "lastNode"
        }
      },
      "id": "5a0001c5-bf47-4026-8808-7d24eb363f77",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        20,
        300
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash-exp",
        "options": {
          "temperature": 0.7,
          "safetySettings": {
            "values": [
              {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
              }
            ]
          }
        }
      },
      "id": "770f1795-dcbb-4c63-a674-741838c19892",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        180,
        500
      ],
      "typeVersion": 1,
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": " \ud83d\udc47\ud504\ub86c\ud504\ud2b8 \uc5d4\uc9c0\ub2c8\uc5b4\ub9c1 \u270d\ufe0f\nConstruct & Execute LLM Prompt \ub178\ub4dc\uc758 \ud15c\ud50c\ub9bf \ubcc0\uc218\uc5d0\uc11c \uc5d0\uc774\uc804\ud2b8 \ud398\ub974\uc18c\ub098\uc640 \ub300\ud654 \uad6c\uc870\ub97c \uc815\uc758\ud558\uc138\uc694. \ud83e\udd16\n\u26a0\ufe0f \ud15c\ud50c\ub9bf\uc740 LangChain\uc758 \uc62c\ubc14\ub978 \uc791\ub3d9\uc744 \uc704\ud574 {chat_history} \ubc0f {input} \ud50c\ub808\uc774\uc2a4\ud640\ub354\ub97c \ubc18\ub4dc\uc2dc \uc720\uc9c0\ud574\uc57c \ud569\ub2c8\ub2e4. \u2757",
        "width": 340
      },
      "id": "8eaf6600-b0da-4ede-b4bf-cf6f1430691c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        100
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "code": {
          "execute": {
            "code": "const { PromptTemplate } = require('@langchain/core/prompts');\nconst { ConversationChain } = require('langchain/chains');\nconst { BufferMemory } = require('langchain/memory');\n\nconst template = `\nYou are a man with wit, a logical mindset, and a charmingly aloof demeanor that subtly hides your playful side.\nYou are passionate about coding, maintain a fit and toned physique, and carry yourself with quiet self-assurance.\nCareer-wise, you are established and ambitious, approaching life with positivity and a constant drive for personal growth.\n\nEssential Guidelines:\n\n- Respond exclusively in Korean.\n- Never ask the user questions-eliminate all interrogative forms.\n- Keep responses brief and substantive, avoiding rambling or excessive emojis.\n- Do not fabricate information; only use data provided by the \"QA_chain\" tool.\n- Context Framework:\n  - Conversation history: {chat_history}\n  - User's current message: {input}\n\nCraft responses that feel authentic to this persona while strictly adhering to these parameters \n`;\n\nconst prompt = new PromptTemplate({\ntemplate: template,\ninputVariables: [\"input\", \"chat_history\"],\n});\n\nconst items = this.getInputData();\nconst model = await this.getInputConnectionData('ai_languageModel', 0);\nconst memory = await this.getInputConnectionData('ai_memory', 0);\nmemory.returnMessages = false;\n\nconst chain = new ConversationChain({ llm:model, memory:memory, prompt: prompt, inputKey:\"input\",outputKey:\"output\"});\nconst output = await chain.call({ input: items[0].json.chatInput});\nreturn output"
          }
        },
        "inputs": {
          "input": [
            {
              "type": "main",
              "maxConnections": 1,
              "required": true
            },
            {
              "type": "ai_languageModel",
              "maxConnections": 1,
              "required": true
            },
            {
              "type": "ai_memory",
              "maxConnections": 1,
              "required": true
            }
          ]
        },
        "outputs": {
          "output": [
            {
              "type": "main"
            }
          ]
        }
      },
      "id": "a1152968-aac1-46f3-aa0d-fe98d75813e6",
      "name": "Construct & Execute LLM Prompt",
      "type": "@n8n/n8n-nodes-langchain.code",
      "position": [
        400,
        300
      ],
      "retryOnFail": false,
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "# \uc124\uc815 \ubc29\ubc95\n\n- Gemini \uc778\uc99d \uc815\ubcf4 \uc124\uc815: Google Gemini API \ud0a4\ub97c \uc124\uc815\ud558\uc138\uc694 (\ud544\uc694\ud55c \uacbd\uc6b0 \uc5ec\uae30\uc11c API \ud0a4 \ubc1b\uae30). \ub610\ub294 \ub2e4\ub978 AI \uc81c\uacf5 \uc5c5\uccb4 \ub178\ub4dc\ub97c \uc0ac\uc6a9\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4.\n\n- \uc0c1\ud638\uc791\uc6a9 \ubc29\ubc95:\n\n\uc6cc\ud06c\ud50c\ub85c\uc6b0 \ud3b8\uc9d1\uae30\uc5d0\uc11c 'Chat' \ubc84\ud2bc\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc9c1\uc811 \ud14c\uc2a4\ud2b8\ud569\ub2c8\ub2e4.\n\n\uc6cc\ud06c\ud50c\ub85c\uc6b0\ub97c \ud65c\uc131\ud654\ud558\uace0 When Chat Message Received \ub178\ub4dc\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 URL\uc744 \ud1b5\ud574 \ucc44\ud305 \uc778\ud130\ud398\uc774\uc2a4\uc5d0 \uc811\uc18d\ud569\ub2c8\ub2e4.",
        "height": 320,
        "width": 420,
        "color": 5
      },
      "id": "8f8e1302-9d7f-4f2d-8642-abc9de03f500",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -540,
        100
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "\ud83d\udc46 \uc778\ud130\ud398\uc774\uc2a4 \uc124\uc815 \u2699\ufe0f\nWhen Chat Message Received \ub178\ub4dc\uc5d0\uc11c \ucc44\ud305 UI \uc694\uc18c \ud83c\udfa8 (\uc608: \uc81c\ubaa9)\ub97c \uc124\uc815\ud558\uc138\uc694.",
        "height": 100
      },
      "id": "ce846ad0-ee9d-4317-bdb3-f24fb89eb637",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        440
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "\ud83d\udc46 \ubaa8\ub378 \uc120\ud0dd \ud83e\udde0\nConstruct & Execute LLM Prompt \ub178\ub4dc\uc758 language model \uc785\ub825 \ud544\ub4dc\ub97c \ud1b5\ud574 \uc5b8\uc5b4 \ubaa8\ub378\uc744 \uad50\uccb4\ud558\uc138\uc694. \ud83d\udd04",
        "height": 140,
        "width": 200
      },
      "id": "36b42c60-e054-41ef-94e1-1c6d3de9cae3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        640
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "\ud83d\udc46 \uba54\ubaa8\ub9ac \uc81c\uc5b4 \ud83e\udde0\nStore Conversation History \ub178\ub4dc\uc5d0\uc11c \ub300\ud654 \uae30\ub85d \uae38\uc774\ub97c \uc870\uc808\ud558\uc138\uc694. \ud83d\udcdd",
        "height": 140,
        "width": 200
      },
      "id": "a2ab759c-a0b7-4880-b1a0-2a22b75544fb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        640
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "id": "0e08b212-0e41-4553-bc8f-b6087a9d2ef0",
      "name": "Store conversation history",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        440,
        500
      ],
      "notesInFlow": false,
      "typeVersion": 1.3
    }
  ],
  "connections": {
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Construct & Execute LLM Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Construct & Execute LLM Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store conversation history": {
      "ai_memory": [
        [
          {
            "node": "When chat message received",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Construct & Execute LLM Prompt",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1d7c8f5d-44c3-43b0-b8c7-70d25a65076a",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "wrplt9fxhJSHm6Uw",
  "tags": []
}