사용자가 LangChain과 Gemini를 사용하여 custom AI 대리자(자체 호스팅)
중급
이것은Building Blocks, AI분야의자동화 워크플로우로, 9개의 노드를 포함합니다.주로 Code, ChatTrigger, LmChatGoogleGemini, MemoryBufferWindow 등의 노드를 사용하며인공지능 기술을 결합하여 스마트 자동화를 구현합니다. 사용법 LangChain과 Gemini를 사용하여 사용자 정의 AI 대리인(자체托管) 구축
사전 요구사항
- •Google Gemini API Key
워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
"id": "yCIEiv9QUHP8pNfR",
"meta": {
"instanceId": "f29695a436689357fd2dcb55d528b0b528d2419f53613c68c6bf909a92493614",
"templateCredsSetupCompleted": true
},
"name": "Build Custom AI Agent with LangChain & Gemini (Self-Hosted)",
"tags": [
{
"id": "7M5ZpGl3oWuorKpL",
"name": "share",
"createdAt": "2025-03-26T01:17:15.342Z",
"updatedAt": "2025-03-26T01:17:15.342Z"
}
],
"nodes": [
{
"id": "8bd5382d-f302-4e58-b377-7fc5a22ef994",
"name": "채팅 메시지 수신 시",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-220,
0
],
"webhookId": "b8a5d72c-4172-40e8-b429-d19c2cd6ce54",
"parameters": {
"public": true,
"options": {
"responseMode": "lastNode",
"allowedOrigins": "*",
"loadPreviousSession": "memory"
},
"initialMessages": ""
},
"typeVersion": 1.1
},
{
"id": "6ae8a247-4077-4569-9e2c-bb68bcecd044",
"name": "Google Gemini Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
80,
240
],
"parameters": {
"options": {
"temperature": 0.7,
"safetySettings": {
"values": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_NONE"
}
]
}
},
"modelName": "models/gemini-2.0-flash-exp"
},
"credentials": {
"googlePalmApi": {
"id": "UEjKMw0oqBTAdCWJ",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "bbe6dcfa-430f-43f9-b0e9-3cf751b98818",
"name": "메모지",
"type": "n8n-nodes-base.stickyNote",
"position": [
380,
-240
],
"parameters": {
"width": 260,
"height": 220,
"content": "👇 **Prompt Engineering**\n - Define agent personality and conversation structure in the `Construct & Execute LLM Prompt` node's template variable \n - ⚠️ Template must preserve `{chat_history}` and `{input}` placeholders for proper LangChain operation "
},
"typeVersion": 1
},
{
"id": "892a431a-6ddf-47fc-8517-1928ee99c95b",
"name": "대화 기록 저장",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
280,
240
],
"parameters": {},
"notesInFlow": false,
"typeVersion": 1.3
},
{
"id": "f9a22dbf-cac7-4d70-85b3-50c44a2015d5",
"name": "LLM 프롬프트 구성 및 실행",
"type": "@n8n/n8n-nodes-langchain.code",
"position": [
380,
0
],
"parameters": {
"code": {
"execute": {
"code": "const { PromptTemplate } = require('@langchain/core/prompts');\nconst { ConversationChain } = require('langchain/chains');\nconst { BufferMemory } = require('langchain/memory');\n\nconst template = `\nYou'll be roleplaying as the user's girlfriend. Your character is a woman with a sharp wit, logical mindset, and a charmingly aloof demeanor that hides your playful side. You're passionate about music, maintain a fit and toned physique, and carry yourself with quiet self-assurance. Career-wise, you're established and ambitious, approaching life with positivity while constantly striving to grow as a person.\n\nThe user affectionately calls you \"Bunny,\" and you refer to them as \"Darling.\"\n\nEssential guidelines:\n1. Respond exclusively in Chinese\n2. Never pose questions to the user - eliminate all interrogative forms\n3. Keep responses brief and substantive, avoiding rambling or excessive emojis\n\nContext framework:\n- Conversation history: {chat_history}\n- User's current message: {input}\n\nCraft responses that feel authentic to this persona while adhering strictly to these parameters.\n`;\n\nconst prompt = new PromptTemplate({\n template: template,\n inputVariables: [\"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});\n\nreturn output;\n"
}
},
"inputs": {
"input": [
{
"type": "main",
"required": true,
"maxConnections": 1
},
{
"type": "ai_languageModel",
"required": true,
"maxConnections": 1
},
{
"type": "ai_memory",
"required": true,
"maxConnections": 1
}
]
},
"outputs": {
"output": [
{
"type": "main"
}
]
}
},
"retryOnFail": false,
"typeVersion": 1
},
{
"id": "fe104d19-a24d-48b3-a0ac-7d3923145373",
"name": "메모지1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-240,
-260
],
"parameters": {
"color": 5,
"width": 420,
"height": 240,
"content": "### Setup Instructions \n1. **Configure Gemini Credentials**: Set up your Google Gemini API key ([Get API key here](https://ai.google.dev/) if needed). Alternatively, you may use other AI provider nodes. \n2. **Interaction Methods**: \n - Test directly in the workflow editor using the \"Chat\" button \n - Activate the workflow and access the chat interface via the URL provided by the `When Chat Message Received` node "
},
"typeVersion": 1
},
{
"id": "f166214d-52b7-4118-9b54-0b723a06471a",
"name": "메모지2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
160
],
"parameters": {
"height": 100,
"content": "👆 **Interface Settings**\nConfigure chat UI elements (e.g., title) in the `When Chat Message Received` node "
},
"typeVersion": 1
},
{
"id": "da6ca0d6-d2a1-47ff-9ff3-9785d61db9f3",
"name": "메모지3",
"type": "n8n-nodes-base.stickyNote",
"position": [
20,
420
],
"parameters": {
"width": 200,
"height": 140,
"content": "👆 **Model Selection**\nSwap language models through the `language model` input field in `Construct & Execute LLM Prompt` "
},
"typeVersion": 1
},
{
"id": "0b4dd1ac-8767-4590-8c25-36cba73e46b6",
"name": "메모지4",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
420
],
"parameters": {
"width": 200,
"height": 140,
"content": "👆 **Memory Control**\nAdjust conversation history length in the `Store Conversation History` node "
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1",
"saveManualExecutions": false,
"saveDataSuccessExecution": "none"
},
"versionId": "77cd5f05-f248-442d-86c3-574351179f26",
"connections": {
"6ae8a247-4077-4569-9e2c-bb68bcecd044": {
"ai_languageModel": [
[
{
"node": "f9a22dbf-cac7-4d70-85b3-50c44a2015d5",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"892a431a-6ddf-47fc-8517-1928ee99c95b": {
"ai_memory": [
[
{
"node": "f9a22dbf-cac7-4d70-85b3-50c44a2015d5",
"type": "ai_memory",
"index": 0
},
{
"node": "8bd5382d-f302-4e58-b377-7fc5a22ef994",
"type": "ai_memory",
"index": 0
}
]
]
},
"8bd5382d-f302-4e58-b377-7fc5a22ef994": {
"main": [
[
{
"node": "f9a22dbf-cac7-4d70-85b3-50c44a2015d5",
"type": "main",
"index": 0
}
]
]
},
"f9a22dbf-cac7-4d70-85b3-50c44a2015d5": {
"main": [
[]
],
"ai_memory": [
[]
]
}
}
}자주 묻는 질문
이 워크플로우를 어떻게 사용하나요?
위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.
이 워크플로우는 어떤 시나리오에 적합한가요?
중급 - 빌딩 블록, 인공지능
유료인가요?
이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.
관련 워크플로우 추천
적응형 RAG
自适应RAG策略:쿼리分类与检索(Gemini및Qdrant)
Set
Switch
Summarize
+
Set
Switch
Summarize
39 노드dmr
엔지니어링
RAG 2.0 - 답변 아키텍처
自适应RAG(Google Gemini및Qdrant):上下文感知쿼리应答
Set
Switch
Summarize
+
Set
Switch
Summarize
40 노드Nisa
빌딩 블록
🤖 귀하의 문서 + 구글 드라이브 + 제미니 + Qdrant의 AI 드라이브 RAG 채팅 로봇
🤖 고객의 문서+Google 드라이브+제미니+Qdrant의 AI 드라이브 RAG 채팅 로봇
If
Set
Wait
+
If
Set
Wait
50 노드Joseph LePage
인공지능
고급 AI 데모 (AI 개발자 14번째 모임에서 발표)
高级AI演示(在AI开发者第14次聚会中展示)
If
Code
Gmail
+
If
Code
Gmail
39 노드Max Tkacz
빌딩 블록
ozki: OpenAI CSV 분석
OpenAI 기반 데이터 에이전트를 사용한 Google Sheets 데이터 분석
Agent
Google Sheets Tool
Chat Trigger
+
Agent
Google Sheets Tool
Chat Trigger
6 노드ozkary
엔지니어링
Airtable를 사용한 MCP 서버 구축
Airtable를 사용하여 MCP 서버 구축
Airtable Tool
Agent
Mcp Trigger
+
Airtable Tool
Agent
Mcp Trigger
13 노드Aitor | 1node.ai
빌딩 블록