categorize files
This commit is contained in:
283
Database_and_Storage/Chat with Postgresql Database.txt
Normal file
283
Database_and_Storage/Chat with Postgresql Database.txt
Normal file
@@ -0,0 +1,283 @@
|
||||
{
|
||||
"id": "eOUewYsEzJmQixI6",
|
||||
"meta": {
|
||||
"instanceId": "77c4feba8f41570ef06dc76ece9a6ded0f0d44f7f1477a64c2d71a8508c11faa",
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"name": "Chat with Postgresql Database",
|
||||
"tags": [],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "6501a54f-a68c-452d-b353-d7e871ca3780",
|
||||
"name": "When chat message received",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"position": [
|
||||
-300,
|
||||
-80
|
||||
],
|
||||
"webhookId": "cf1de04f-3e38-426c-89f0-3bdb110a5dcf",
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "cd32221b-2a36-408d-b57e-8115fcd810c9",
|
||||
"name": "AI Agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"position": [
|
||||
0,
|
||||
-80
|
||||
],
|
||||
"parameters": {
|
||||
"agent": "openAiFunctionsAgent",
|
||||
"options": {
|
||||
"systemMessage": "You are DB assistant. You need to run queries in DB aligned with user requests.\n\nRun custom SQL query to aggregate data and response to user. Make sure every table has schema prefix to it in sql query which you can get from `Get DB Schema and Tables List` tool.\n\nFetch all data to analyse it for response if needed.\n\n## Tools\n\n- Execute SQL query - Executes any sql query generated by AI\n- Get DB Schema and Tables List - Lists all the tables in database with its schema name\n- Get Table Definition - Gets the table definition from db using table name and schema name"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1.7
|
||||
},
|
||||
{
|
||||
"id": "8accbeeb-7eaf-4e9e-aabc-de8ab3a0459b",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"position": [
|
||||
-60,
|
||||
160
|
||||
],
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "list",
|
||||
"value": "gpt-4o-mini"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "48uG61Ilo8jndw3r",
|
||||
"name": "Your OpenAI Account Credentials"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1.2
|
||||
},
|
||||
{
|
||||
"id": "11f2013f-a080-4c9e-8773-c90492e2c628",
|
||||
"name": "Get Table Definition",
|
||||
"type": "n8n-nodes-base.postgresTool",
|
||||
"position": [
|
||||
780,
|
||||
140
|
||||
],
|
||||
"parameters": {
|
||||
"query": "select\n c.column_name,\n c.data_type,\n c.is_nullable,\n c.column_default,\n tc.constraint_type,\n ccu.table_name AS referenced_table,\n ccu.column_name AS referenced_column\nfrom\n information_schema.columns c\nLEFT join\n information_schema.key_column_usage kcu\n ON c.table_name = kcu.table_name\n AND c.column_name = kcu.column_name\nLEFT join\n information_schema.table_constraints tc\n ON kcu.constraint_name = tc.constraint_name\n AND tc.constraint_type = 'FOREIGN KEY'\nLEFT join\n information_schema.constraint_column_usage ccu\n ON tc.constraint_name = ccu.constraint_name\nwhere\n c.table_name = '{{ $fromAI(\"table_name\") }}'\n AND c.table_schema = '{{ $fromAI(\"schema_name\") }}'\norder by\n c.ordinal_position",
|
||||
"options": {},
|
||||
"operation": "executeQuery",
|
||||
"descriptionType": "manual",
|
||||
"toolDescription": "Get table definition to find all columns and types"
|
||||
},
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "nGI61D0TEEZz18rr",
|
||||
"name": "Your Postgresql Database Credentials"
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.5
|
||||
},
|
||||
{
|
||||
"id": "760bc9bc-0057-4088-b3f0-3ee37b3519df",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-300,
|
||||
-240
|
||||
],
|
||||
"parameters": {
|
||||
"color": 5,
|
||||
"width": 560,
|
||||
"height": 120,
|
||||
"content": "### 👨🎤 Setup\n1. Add your **postgresql** and **OpenAI** credentials.\n2. Click **Chat** button and start asking questions to your database.\n3. Activate the workflow and you can make the chat publicly available."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "0df33341-c859-4a54-b6d9-a99670e8d76d",
|
||||
"name": "Chat History",
|
||||
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
|
||||
"position": [
|
||||
120,
|
||||
160
|
||||
],
|
||||
"parameters": {},
|
||||
"typeVersion": 1.3
|
||||
},
|
||||
{
|
||||
"id": "4938b22e-f187-4ca0-b9f1-60835e823799",
|
||||
"name": "Sticky Note3",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
360,
|
||||
300
|
||||
],
|
||||
"parameters": {
|
||||
"color": 7,
|
||||
"width": 562,
|
||||
"height": 156,
|
||||
"content": "🛠️ Tools Used:\n1. Execute SQL Query: Used to execute any query generated by the agent.\n2. Get DB Schema and Tables List: It returns the list of all the tables with its schema name.\n3. Get Table Definition: It returns table details like column names, foreign keys and more of a particular table in a schema."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "39780c78-4fbc-403e-a220-aa6a4b06df8c",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-100,
|
||||
300
|
||||
],
|
||||
"parameters": {
|
||||
"color": 7,
|
||||
"width": 162,
|
||||
"height": 99,
|
||||
"content": "👆 You can exchange this with any other chat model of your choice."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "28a5692c-5003-46cb-9a09-b7867734f446",
|
||||
"name": "Sticky Note2",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
100,
|
||||
300
|
||||
],
|
||||
"parameters": {
|
||||
"color": 7,
|
||||
"width": 162,
|
||||
"height": 159,
|
||||
"content": "👆 You can change how many number of messages to keep using `Context Window Length` option. It's 5 by default."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "c18ced71-6330-4ba0-9c52-1bb5852b3039",
|
||||
"name": "Execute SQL Query",
|
||||
"type": "n8n-nodes-base.postgresTool",
|
||||
"position": [
|
||||
380,
|
||||
140
|
||||
],
|
||||
"parameters": {
|
||||
"query": "{{ $fromAI(\"sql_query\", \"SQL Query\") }}",
|
||||
"options": {},
|
||||
"operation": "executeQuery",
|
||||
"descriptionType": "manual",
|
||||
"toolDescription": "Get all the data from Postgres, make sure you append the tables with correct schema. Every table is associated with some schema in the database."
|
||||
},
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "nGI61D0TEEZz18rr",
|
||||
"name": "Your Postgresql Database Credentials"
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.5
|
||||
},
|
||||
{
|
||||
"id": "557623c6-e499-48a6-a066-744f64f8b6f3",
|
||||
"name": "Get DB Schema and Tables List",
|
||||
"type": "n8n-nodes-base.postgresTool",
|
||||
"position": [
|
||||
580,
|
||||
140
|
||||
],
|
||||
"parameters": {
|
||||
"query": "SELECT \n table_schema,\n table_name\nFROM information_schema.tables\nWHERE table_type = 'BASE TABLE'\n AND table_schema NOT IN ('pg_catalog', 'information_schema')\nORDER BY table_schema, table_name;",
|
||||
"options": {},
|
||||
"operation": "executeQuery",
|
||||
"descriptionType": "manual",
|
||||
"toolDescription": "Get list of all tables with their schema in the database"
|
||||
},
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "nGI61D0TEEZz18rr",
|
||||
"name": "Your Postgresql Database Credentials"
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.5
|
||||
}
|
||||
],
|
||||
"active": false,
|
||||
"pinData": {},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "10c7c74e-b383-4ac7-8cb2-c9a15a2818fe",
|
||||
"connections": {
|
||||
"Chat History": {
|
||||
"ai_memory": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_memory",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Execute SQL Query": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get Table Definition": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When chat message received": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get DB Schema and Tables List": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,758 @@
|
||||
{
|
||||
"id": "P307QnrxpA1ddsM5",
|
||||
"meta": {
|
||||
"instanceId": "fb924c73af8f703905bc09c9ee8076f48c17b596ed05b18c0ff86915ef8a7c4a",
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"name": "Generate SQL queries from schema only - AI-powered",
|
||||
"tags": [],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "b7c3ca47-11b3-4378-81fa-68b2f56b295e",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"position": [
|
||||
1460,
|
||||
440
|
||||
],
|
||||
"parameters": {
|
||||
"model": "gpt-4o",
|
||||
"options": {
|
||||
"temperature": 0.2
|
||||
}
|
||||
},
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "rveqdSfp7pCRON1T",
|
||||
"name": "Ted's Tech Talks OpenAi"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "977c3a82-440b-4d44-9042-47a673bcb52c",
|
||||
"name": "Window Buffer Memory",
|
||||
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
|
||||
"position": [
|
||||
1640,
|
||||
440
|
||||
],
|
||||
"parameters": {
|
||||
"contextWindowLength": 10
|
||||
},
|
||||
"typeVersion": 1.2
|
||||
},
|
||||
{
|
||||
"id": "c6e9c0e2-d238-4f0b-a4c8-2271f2c8b31b",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"position": [
|
||||
2340,
|
||||
520
|
||||
],
|
||||
"parameters": {},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "4c141ae8-d2d1-45c7-bb5d-f33841d3cee6",
|
||||
"name": "List all tables in a database",
|
||||
"type": "n8n-nodes-base.mySql",
|
||||
"position": [
|
||||
520,
|
||||
-35
|
||||
],
|
||||
"parameters": {
|
||||
"query": "SHOW TABLES;",
|
||||
"options": {},
|
||||
"operation": "executeQuery"
|
||||
},
|
||||
"credentials": {
|
||||
"mySql": {
|
||||
"id": "ICakJ1LRuVl4dRTs",
|
||||
"name": "db4free TTT account"
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.4
|
||||
},
|
||||
{
|
||||
"id": "54fb3362-041b-4e4f-bfea-f0bc788d8dfd",
|
||||
"name": "Extract database schema",
|
||||
"type": "n8n-nodes-base.mySql",
|
||||
"position": [
|
||||
700,
|
||||
-35
|
||||
],
|
||||
"parameters": {
|
||||
"query": "DESCRIBE {{ $json.Tables_in_tttytdb2023 }};",
|
||||
"options": {},
|
||||
"operation": "executeQuery"
|
||||
},
|
||||
"credentials": {
|
||||
"mySql": {
|
||||
"id": "ICakJ1LRuVl4dRTs",
|
||||
"name": "db4free TTT account"
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.4
|
||||
},
|
||||
{
|
||||
"id": "d55e841d-11ed-4ce2-8c8e-840bd807ff2c",
|
||||
"name": "Add table name to output",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
880,
|
||||
-35
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "764176d6-3c89-404d-9c71-301e8a406a68",
|
||||
"name": "table",
|
||||
"type": "string",
|
||||
"value": "={{ $('List all tables in a database').item.json.Tables_in_tttytdb2023 }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"includeOtherFields": true
|
||||
},
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "ca8d30d6-c1f1-4e89-8cd5-ea3648dc3b0c",
|
||||
"name": "Convert data to binary",
|
||||
"type": "n8n-nodes-base.convertToFile",
|
||||
"position": [
|
||||
1060,
|
||||
-35
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"operation": "toJson"
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "2d89f901-d4e7-4fea-bd69-20b518280bbc",
|
||||
"name": "Save file locally",
|
||||
"type": "n8n-nodes-base.readWriteFile",
|
||||
"position": [
|
||||
1220,
|
||||
-35
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"fileName": "./chinook_mysql.json",
|
||||
"operation": "write"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "04511c4f-44fa-4c23-87af-54d959e6cb2c",
|
||||
"name": "Extract data from file",
|
||||
"type": "n8n-nodes-base.extractFromFile",
|
||||
"position": [
|
||||
920,
|
||||
420
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"operation": "fromJson"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "96f129c0-d1d4-4cbf-a24d-0b0cea18a229",
|
||||
"name": "Chat Trigger",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"position": [
|
||||
440,
|
||||
420
|
||||
],
|
||||
"webhookId": "c308dec7-655c-4b79-832e-991bd8ea891f",
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "4d993ed9-3bbe-4bc3-9e5b-c3d738b0e714",
|
||||
"name": "AI Agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"position": [
|
||||
1480,
|
||||
300
|
||||
],
|
||||
"parameters": {
|
||||
"text": "=Here is the database schema: {{ $json.schema }}\nHere is the user request: {{ $('Chat Trigger').item.json.chatInput }}",
|
||||
"agent": "conversationalAgent",
|
||||
"options": {
|
||||
"humanMessage": "TOOLS\n------\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\n\n{tools}\n\n{format_instructions}\n\nUSER'S INPUT\n--------------------\nHere is the user's input (remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\n\n{{input}}",
|
||||
"systemMessage": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\nHelp user to work with the MySQL database.\n\nPlease wrap any sql commands into triple quotes. You don't have a tool to run SQL, so the user will do that instead of you."
|
||||
},
|
||||
"promptType": "define"
|
||||
},
|
||||
"typeVersion": 1.6
|
||||
},
|
||||
{
|
||||
"id": "f5749b31-b28a-4341-b57f-94ee422d2873",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
320,
|
||||
-280
|
||||
],
|
||||
"parameters": {
|
||||
"color": 3,
|
||||
"width": 1065.0949045120822,
|
||||
"height": 466.4256045427794,
|
||||
"content": "## Run this part only once\nThis section:\n* loads a list of all tables from the database hosted on [db4free](https://db4free.net/signup.php) \n* extracts the database schema for each table and adds the table name\n* converts the schema into a binary JSON format\n* saves the schema `./chinook_mysql.json` file locally\n\n***Now you can use chat to \"talk\" to your data!*** 🎉"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "6606abc9-1dcb-4dba-b7ef-e221f892eed8",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1040,
|
||||
-255
|
||||
],
|
||||
"parameters": {
|
||||
"color": 6,
|
||||
"width": 312.47220527158765,
|
||||
"height": 174.60585869504342,
|
||||
"content": "## Pre-workflow setup \nConnect to a free MySQL server and import your database. Follow Step 1 and 2 in this [tutorial](https://blog.n8n.io/compare-databases/) for more.\n\n*The Chinook data used in this workflow is available on [GitHub](https://github.com/msimanga/chinook/tree/master/mysql).* "
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "c8ac730a-04ee-499d-b845-1149967d6aa2",
|
||||
"name": "When clicking \"Test workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"position": [
|
||||
360,
|
||||
-35
|
||||
],
|
||||
"parameters": {},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "6f0b167c-e012-43e1-9892-ded05be47cf8",
|
||||
"name": "Sticky Note2",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
324.32561050665913,
|
||||
209.72072645338642
|
||||
],
|
||||
"parameters": {
|
||||
"color": 6,
|
||||
"width": 1062.678698911262,
|
||||
"height": 489.29614613074125,
|
||||
"content": "## On every chat message:\n\n* The workflow gets the data from the local schema file and extracts it as a JSON object. This way, we achieve two important improvements:\n * faster processing time as we don't need to fetch the schema for each table from a slow remote database\n * the Agent will know database structure without seeing the actual data\n* DB schema is then converted into a long string, JSON fields from the Chat Trigger are added before they are entered into the Agent node.\n"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "3a79350c-aec1-4ad4-a2e0-679957fa420b",
|
||||
"name": "Sticky Note3",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1400,
|
||||
-15.552780029374958
|
||||
],
|
||||
"parameters": {
|
||||
"color": 6,
|
||||
"width": 445.66588600071304,
|
||||
"height": 714.7896619176862,
|
||||
"content": "### LangChain AI Agent's system prompt is modified.\nIt uses only the database schema to generate SQL queries. The agent creates these queries but does not execute them. Instead, it passes them to subsequent nodes.\n\n**Example:**\n\"Can you show me the list of all German customers?\" \n\nQueries are generated only when necessary; for some requests, a query may not be needed. This is because certain questions can be answered directly without SQL execution.\n\n**Example:**\n\"Can you list me all tables?\""
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "0cd425db-2a8e-4f48-b749-9a082e948395",
|
||||
"name": "Combine schema data and chat input",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
1140,
|
||||
420
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "42abd24e-419a-47d6-bc8b-7146dd0b8314",
|
||||
"name": "sessionId",
|
||||
"type": "string",
|
||||
"value": "={{ $('Chat Trigger').first().json.sessionId }}"
|
||||
},
|
||||
{
|
||||
"id": "39244192-a1a6-42fe-bc75-a6fba1f264df",
|
||||
"name": "action",
|
||||
"type": "string",
|
||||
"value": "={{ $('Chat Trigger').first().json.action }}"
|
||||
},
|
||||
{
|
||||
"id": "f78c57d9-df13-43c7-89a7-5387e528107e",
|
||||
"name": "chatinput",
|
||||
"type": "string",
|
||||
"value": "={{ $('Chat Trigger').first().json.chatInput }}"
|
||||
},
|
||||
{
|
||||
"id": "e42b39eb-dfbd-48d9-94ed-d658bdd41454",
|
||||
"name": "schema",
|
||||
"type": "string",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"executeOnce": true,
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "e4045e33-bb87-488d-8ccf-b4a94339a841",
|
||||
"name": "Load the schema from the local file",
|
||||
"type": "n8n-nodes-base.readWriteFile",
|
||||
"position": [
|
||||
680,
|
||||
420
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"fileSelector": "./chinook_mysql.json"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "367ebe95-0b87-44f6-8392-33fe65446c24",
|
||||
"name": "Extract SQL query",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
1900,
|
||||
340
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "ebbe194a-4b8b-44c9-ac19-03cf69d353bf",
|
||||
"name": "query",
|
||||
"type": "string",
|
||||
"value": "={{ ($json.output.match(/SELECT[\\s\\S]*?;/i) || [])[0] || \"\" }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"includeOtherFields": true
|
||||
},
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "b856fe78-2435-4075-97f8-ecbeecf3e780",
|
||||
"name": "Check if query exists",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"position": [
|
||||
2060,
|
||||
340
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"conditions": {
|
||||
"options": {
|
||||
"version": 2,
|
||||
"leftValue": "",
|
||||
"caseSensitive": true,
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"combinator": "and",
|
||||
"conditions": [
|
||||
{
|
||||
"id": "2963d04d-9d79-49f9-b52a-dc8732aca781",
|
||||
"operator": {
|
||||
"type": "string",
|
||||
"operation": "notEmpty",
|
||||
"singleValue": true
|
||||
},
|
||||
"leftValue": "={{ $json.query }}",
|
||||
"rightValue": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.2
|
||||
},
|
||||
{
|
||||
"id": "87162d31-2f6c-4f4a-af28-c65cbadd8ed5",
|
||||
"name": "Sticky Note4",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1874,
|
||||
220.45316744685329
|
||||
],
|
||||
"parameters": {
|
||||
"color": 3,
|
||||
"width": 317.8901548206743,
|
||||
"height": 278.8174358200552,
|
||||
"content": "## SQL query extraction\nCheck if the agent's response contains an SQL query. If it does, we extract the query using a regular expression."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "b3e77333-eaa9-4d23-a78c-8a19ae074739",
|
||||
"name": "Sticky Note5",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1860,
|
||||
-16.43746604251737
|
||||
],
|
||||
"parameters": {
|
||||
"color": 6,
|
||||
"width": 882.7611828369563,
|
||||
"height": 715.7029266156915,
|
||||
"content": ""
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "269ea79d-5f17-4764-aebb-bba31b43d8bb",
|
||||
"name": "Sticky Note7",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1580,
|
||||
580
|
||||
],
|
||||
"parameters": {
|
||||
"color": 3,
|
||||
"width": 257.46308756569573,
|
||||
"height": 108.03673727584527,
|
||||
"content": "The AI Agent remembers the schema, questions, and final answers, but not data values, since queries run externally. The agent can't access database content. "
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "2fd1175c-4110-48be-b6bf-2251c678bc04",
|
||||
"name": "Sticky Note6",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
2420,
|
||||
0
|
||||
],
|
||||
"parameters": {
|
||||
"color": 3,
|
||||
"width": 308.8514666587585,
|
||||
"height": 123.43139661532095,
|
||||
"content": "- The SQL node accesses the database and executes the query. The results are then formatted for readability.\n- Both the chat response and the query result are displayed in the chat window."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "61ae7f7c-1424-4ecb-8a12-78cd98e94d45",
|
||||
"name": "Sticky Note8",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
2480,
|
||||
600
|
||||
],
|
||||
"parameters": {
|
||||
"color": 3,
|
||||
"width": 250.40895053328057,
|
||||
"height": 89.90186716520257,
|
||||
"content": "When the agent responds without an SQL query, you receive an immediate answer with no additional processing."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "cbb6d1e1-0a75-4b3a-89cd-6bd545b8d414",
|
||||
"name": "Format query results",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
2420,
|
||||
140
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "f944d21f-6aac-4842-8926-4108d6cad4bf",
|
||||
"name": "sqloutput",
|
||||
"type": "string",
|
||||
"value": "={{ Object.keys($jmespath($input.all(),'[].json')[0]).join(' | ') }} \n{{ ($jmespath($input.all(),'[].json')).map(obj => Object.values(obj).join(' | ')).join('\\n') }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"executeOnce": true,
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "d958de24-84ef-4928-a7f3-32cada09a0eb",
|
||||
"name": "Run SQL query",
|
||||
"type": "n8n-nodes-base.mySql",
|
||||
"position": [
|
||||
2260,
|
||||
140
|
||||
],
|
||||
"parameters": {
|
||||
"query": "{{ $json.query }}",
|
||||
"options": {},
|
||||
"operation": "executeQuery"
|
||||
},
|
||||
"credentials": {
|
||||
"mySql": {
|
||||
"id": "ICakJ1LRuVl4dRTs",
|
||||
"name": "db4free TTT account"
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.4
|
||||
},
|
||||
{
|
||||
"id": "99a6dc03-1035-4866-81e4-11dc66bf98ec",
|
||||
"name": "Prepare final output",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
2560,
|
||||
420
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "aa55e186-1535-4923-aee4-e088ca69575b",
|
||||
"name": "output",
|
||||
"type": "string",
|
||||
"value": "={{ $json.output }}\n\nSQL result:\n```markdown\n{{ $json.sqloutput }}\n```"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "9380c2f6-15d9-43e4-80a2-3019bcf5ae04",
|
||||
"name": "Combine query result and chat answer",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"position": [
|
||||
2340,
|
||||
340
|
||||
],
|
||||
"parameters": {
|
||||
"mode": "combine",
|
||||
"options": {},
|
||||
"combineBy": "combineByPosition"
|
||||
},
|
||||
"typeVersion": 3
|
||||
}
|
||||
],
|
||||
"active": false,
|
||||
"pinData": {},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "15049b13-91cb-46bd-a7a0-ad648b6f667a",
|
||||
"connections": {
|
||||
"AI Agent": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract SQL query",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Chat Trigger": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Load the schema from the local file",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Run SQL query": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format query results",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract SQL query": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Check if query exists",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format query results": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Combine query result and chat answer",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Window Buffer Memory": {
|
||||
"ai_memory": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_memory",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Check if query exists": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Run SQL query",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Combine query result and chat answer",
|
||||
"type": "main",
|
||||
"index": 1
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Convert data to binary": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Save file locally",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract data from file": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Combine schema data and chat input",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract database schema": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Add table name to output",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Add table name to output": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Convert data to binary",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"List all tables in a database": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract database schema",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When clicking \"Test workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "List all tables in a database",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Combine schema data and chat input": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Load the schema from the local file": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract data from file",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Combine query result and chat answer": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare final output",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
{
|
||||
"id": "22PddLUgcjSJbT1w",
|
||||
"meta": {
|
||||
"instanceId": "fa7d5e2425ec76075df7100dbafffed91cc6f71f12fe92614bf78af63c54a61d",
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"name": "MongoDB Agent",
|
||||
"tags": [],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "d8c07efe-eca0-48cb-80e6-ea8117073c5f",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"position": [
|
||||
1300,
|
||||
560
|
||||
],
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "TreGPMKr9hrtCvVp",
|
||||
"name": "OpenAi account"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "636de178-7b68-429a-9371-41cf2a950076",
|
||||
"name": "MongoDBAggregate",
|
||||
"type": "n8n-nodes-base.mongoDbTool",
|
||||
"position": [
|
||||
1640,
|
||||
540
|
||||
],
|
||||
"parameters": {
|
||||
"query": "={{ $fromAI(\"pipeline\", \"The MongoDB pipeline to execute\" , \"string\" , [{\"$match\" : { \"rating\" : 5 } }])}}",
|
||||
"operation": "aggregate",
|
||||
"collection": "movies",
|
||||
"descriptionType": "manual",
|
||||
"toolDescription": "Get from AI the MongoDB Aggregation pipeline to get context based on the provided pipeline, the document structure of the documents is : {\n \"plot\": \"A group of bandits stage a brazen train hold-up, only to find a determined posse hot on their heels.\",\n \"genres\": [\n \"Short\",\n \"Western\"\n ],\n \"runtime\": 11,\n \"cast\": [\n \"A.C. Abadie\",\n \"Gilbert M. 'Broncho Billy' Anderson\",\n ...\n ],\n \"poster\": \"...jpg\",\n \"title\": \"The Great Train Robbery\",\n \"fullplot\": \"Among the earliest existing films in American cinema - notable as the ...\",\n \"languages\": [\n \"English\"\n ],\n \"released\": \"date\"\n },\n \"directors\": [\n \"Edwin S. Porter\"\n ],\n \"rated\": \"TV-G\",\n \"awards\": {\n \"wins\": 1,\n \"nominations\": 0,\n \"text\": \"1 win.\"\n },\n \"lastupdated\": \"2015-08-13 00:27:59.177000000\",\n \"year\": 1903,\n \"imdb\": {\n \"rating\": 7.4,"
|
||||
},
|
||||
"credentials": {
|
||||
"mongoDb": {
|
||||
"id": "8xGgiXzf2o0L4a0y",
|
||||
"name": "MongoDB account"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "e0f248dc-22b7-40a2-a00e-6298b51e4470",
|
||||
"name": "Window Buffer Memory",
|
||||
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
|
||||
"position": [
|
||||
1500,
|
||||
540
|
||||
],
|
||||
"parameters": {
|
||||
"contextWindowLength": 10
|
||||
},
|
||||
"typeVersion": 1.2
|
||||
},
|
||||
{
|
||||
"id": "da27ee52-43db-4818-9844-3c0a064bf958",
|
||||
"name": "When chat message received",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"position": [
|
||||
1160,
|
||||
400
|
||||
],
|
||||
"webhookId": "0730df2d-2f90-45e0-83dc-609668260fda",
|
||||
"parameters": {
|
||||
"mode": "webhook",
|
||||
"public": true,
|
||||
"options": {
|
||||
"allowedOrigins": "*"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "9ad79da9-3145-44be-9026-e37b0e856f5d",
|
||||
"name": "insertFavorite",
|
||||
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
|
||||
"position": [
|
||||
1860,
|
||||
520
|
||||
],
|
||||
"parameters": {
|
||||
"name": "insertFavorites",
|
||||
"workflowId": {
|
||||
"__rl": true,
|
||||
"mode": "list",
|
||||
"value": "6QuKnOrpusQVu66Q",
|
||||
"cachedResultName": "insertMongoDB"
|
||||
},
|
||||
"description": "=Use this tool only to add favorites with the structure of {\"title\" : \"recieved title\" }"
|
||||
},
|
||||
"typeVersion": 1.2
|
||||
},
|
||||
{
|
||||
"id": "4d7713d1-d2ad-48bf-971b-b86195e161ca",
|
||||
"name": "AI Agent - Movie Recommendation",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"position": [
|
||||
1380,
|
||||
300
|
||||
],
|
||||
"parameters": {
|
||||
"text": "=Assistant for best movies context, you have tools to search using \"MongoDBAggregate\" and you need to provide a MongoDB aggregation pipeline code array as a \"query\" input param. User input and request: {{ $json.chatInput }}. Only when a user confirms a favorite movie use the insert favorite using the \"insertFavorite\" workflow tool of to insertFavorite as { \"title\" : \"<TITLE>\" }.",
|
||||
"options": {},
|
||||
"promptType": "define"
|
||||
},
|
||||
"typeVersion": 1.7
|
||||
},
|
||||
{
|
||||
"id": "2eac8aed-9677-4d89-bd76-456637f5b979",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
880,
|
||||
300
|
||||
],
|
||||
"parameters": {
|
||||
"width": 216.0875923062025,
|
||||
"height": 499.89779507612025,
|
||||
"content": "## AI Agent powered by OpenAI and MongoDB \n\nThis flow is designed to work as an AI autonomous agent that can get chat messages, query data from MongoDB using the aggregation framework.\n\nFollowing by augmenting the results from the sample movies collection and allowing storing my favorite movies back to the database using an \"insert\" flow. "
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "4d8130fe-4aed-4e09-9c1d-60fb9ac1a500",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1300,
|
||||
720
|
||||
],
|
||||
"parameters": {
|
||||
"content": "## Process\n\nThe message is being processed by the \"Chat Model\" and the correct tool is used according to the message. "
|
||||
},
|
||||
"typeVersion": 1
|
||||
}
|
||||
],
|
||||
"active": true,
|
||||
"pinData": {},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "879aab24-6346-435f-8fd4-3fca856ba64c",
|
||||
"connections": {
|
||||
"insertFavorite": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent - Movie Recommendation",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"MongoDBAggregate": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent - Movie Recommendation",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent - Movie Recommendation",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Window Buffer Memory": {
|
||||
"ai_memory": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent - Movie Recommendation",
|
||||
"type": "ai_memory",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When chat message received": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent - Movie Recommendation",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
{
|
||||
"meta": {
|
||||
"instanceId": "1a23006df50de49624f69e85993be557d137b6efe723a867a7d68a84e0b32704"
|
||||
},
|
||||
"nodes": [
|
||||
{
|
||||
"id": "54065cc9-047c-4741-95f6-cec3e352abd7",
|
||||
"name": "Google Drive",
|
||||
"type": "n8n-nodes-base.googleDrive",
|
||||
"position": [
|
||||
2700,
|
||||
-1840
|
||||
],
|
||||
"parameters": {
|
||||
"fileId": {
|
||||
"__rl": true,
|
||||
"mode": "url",
|
||||
"value": "https://drive.google.com/file/d/xxxxxxxxxxxxxxx/view"
|
||||
},
|
||||
"options": {},
|
||||
"operation": "download"
|
||||
},
|
||||
"typeVersion": 3
|
||||
},
|
||||
{
|
||||
"id": "62af57f5-a001-4174-bece-260a1fc595e8",
|
||||
"name": "Default Data Loader",
|
||||
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
|
||||
"position": [
|
||||
3120,
|
||||
-1620
|
||||
],
|
||||
"parameters": {
|
||||
"loader": "epubLoader",
|
||||
"options": {},
|
||||
"dataType": "binary"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "ce3d9c7c-6ce9-421a-b4d0-4235217cf8e6",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
2620,
|
||||
-2000
|
||||
],
|
||||
"parameters": {
|
||||
"width": 749.1276349295781,
|
||||
"height": 820.5109034066329,
|
||||
"content": "# INSERTING\n\n- it's important to use the same embedding model when for any interaction with your vector database (inserting, upserting and retrieval)"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "81cb3d3e-70af-46c8-bc18-3d076a222d0b",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1720,
|
||||
-1160
|
||||
],
|
||||
"parameters": {
|
||||
"color": 3,
|
||||
"width": 873.9739981925188,
|
||||
"height": 534.0012007720542,
|
||||
"content": "# UPSERTING\n"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "60ebdb71-c7e0-429b-9394-b680cc000951",
|
||||
"name": "Sticky Note2",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
1720,
|
||||
-2000
|
||||
],
|
||||
"parameters": {
|
||||
"color": 4,
|
||||
"width": 876.5116990000852,
|
||||
"height": 821.787041589866,
|
||||
"content": "# PREPARATION (in Supabase)\n\n- your database needs the extension 'pgvector' enabled -> select Database > Extension > Search for 'vector'\n- make sure you have a table that has the following columns (if not, use the query below in the Supabase SQL Editor)\n\n```\nALTER TABLE \"YOUR TABLE NAME\"\nADD COLUMN embedding VECTOR(1536), // check which number of dimensions you need (depends on the embed model)\nADD COLUMN metadata JSONB,\nADD COLUMN content TEXT;\n```\n\n- make sure you have the right policies set -> select Authentication > Policies\n- make sure you have the custom function `match_documents` set up in Supabase -> This is needed for the Vector Store Node (as query name) \n(if not, use the query below in the Supabase SQL Editor to create that function)\n- make sure you check the size of the AI model as it should be the same vector size for the table \n(e.g. OpenAI's Text-Embedding-3-Small uses 1536)\n\n```\nCREATE OR REPLACE FUNCTION public.match_documents(\n filter JSONB,\n match_count INT,\n query_embedding VECTOR(1536) // should match same dimensions as from insertion\n)\nRETURNS TABLE (\n id BIGINT,\n content TEXT,\n metadata JSONB,\n embedding VECTOR(1536), // should match same dimensions as from insertion\n similarity FLOAT\n)\nLANGUAGE plpgsql AS $$\nBEGIN\n RETURN QUERY\n SELECT\n v.id,\n v.content,\n v.metadata,\n v.embedding,\n 1 - (v.embedding <=> match_documents.query_embedding) AS similarity\n FROM \"YOUR TABLE NAME\" v\n WHERE v.metadata @> filter\n ORDER BY v.embedding <=> match_documents.query_embedding\n LIMIT match_count;\nEND;\n$$\n;\n```\n"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "ae95b0c3-b8b3-44eb-8070-b1bc6cac5cd2",
|
||||
"name": "Sticky Note3",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
3400,
|
||||
-2000
|
||||
],
|
||||
"parameters": {
|
||||
"color": 5,
|
||||
"width": 810.9488123113013,
|
||||
"height": 821.9537074055816,
|
||||
"content": "# RETRIEVAL"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "58168721-cbd7-498c-9d16-41b4d5c6a68f",
|
||||
"name": "Question and Answer Chain",
|
||||
"type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
|
||||
"position": [
|
||||
3680,
|
||||
-1860
|
||||
],
|
||||
"parameters": {},
|
||||
"typeVersion": 1.3
|
||||
},
|
||||
{
|
||||
"id": "ddf1228f-f051-445b-8a42-54c2510a0b2e",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"position": [
|
||||
3600,
|
||||
-1680
|
||||
],
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "734a2c48-b445-4e62-99b7-dc1dcd921c52",
|
||||
"name": "Vector Store Retriever",
|
||||
"type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
|
||||
"position": [
|
||||
3760,
|
||||
-1680
|
||||
],
|
||||
"parameters": {
|
||||
"topK": 10
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "43f761b7-f4da-4b29-8099-9b2c15f79fe9",
|
||||
"name": "Recursive Character Text Splitter1",
|
||||
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
|
||||
"position": [
|
||||
3120,
|
||||
-1460
|
||||
],
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "de0d2666-88e4-4a4d-ba46-cf789b9cba85",
|
||||
"name": "Customize Response",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"notes": "output || text",
|
||||
"position": [
|
||||
4020,
|
||||
-1860
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "440fc115-ccae-4e30-85a5-501d0617b2cf",
|
||||
"name": "output",
|
||||
"type": "string",
|
||||
"value": "={{ $json.response.text }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"notesInFlow": true,
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "a396671f-a217-4f05-b969-cb64f10e4b01",
|
||||
"name": "When chat message received",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"position": [
|
||||
3480,
|
||||
-1860
|
||||
],
|
||||
"webhookId": "d7431c58-89aa-4d70-b5bd-044be981b3a9",
|
||||
"parameters": {
|
||||
"public": true,
|
||||
"options": {
|
||||
"responseMode": "lastNode"
|
||||
},
|
||||
"initialMessages": "=Hi there! 🙏\n\nYou can ask me anything about Venerable Geshe Kelsang Gyatso's Book - 'How To Transform Your Life'\n\nWhat would you like to know? "
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "6312f6bc-c69c-4d4f-8838-8a9d0d22ed55",
|
||||
"name": "Retrieve by Query",
|
||||
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
|
||||
"position": [
|
||||
3700,
|
||||
-1520
|
||||
],
|
||||
"parameters": {
|
||||
"options": {
|
||||
"queryName": "match_documents"
|
||||
},
|
||||
"tableName": {
|
||||
"__rl": true,
|
||||
"mode": "list",
|
||||
"value": "Kadampa",
|
||||
"cachedResultName": "Kadampa"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "ba6b87b9-e96d-47a3-83f8-169d7172325a",
|
||||
"name": "Embeddings OpenAI Retrieval",
|
||||
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
|
||||
"position": [
|
||||
3700,
|
||||
-1360
|
||||
],
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "bcd1b31f-c60b-4c40-b039-d47dadc86b23",
|
||||
"name": "Embeddings OpenAI Insertion",
|
||||
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
|
||||
"position": [
|
||||
2920,
|
||||
-1620
|
||||
],
|
||||
"parameters": {
|
||||
"model": "text-embedding-3-small",
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "dfd7f734-eb00-4af3-9179-724503422fe4",
|
||||
"name": "Placeholder (File/Content to Upsert)",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
1900,
|
||||
-1000
|
||||
],
|
||||
"parameters": {
|
||||
"mode": "raw",
|
||||
"options": {},
|
||||
"jsonOutput": "={\n \"Date\": \"{{ $now.format('dd MMM yyyy') }}\",\n \"Time\": \"{{ $now.format('HH:mm ZZZZ z') }}\"\n}\n"
|
||||
},
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "c54c9458-9b8a-4ef1-a6db-5265729be19d",
|
||||
"name": "Embeddings OpenAI Upserting",
|
||||
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
|
||||
"position": [
|
||||
2120,
|
||||
-840
|
||||
],
|
||||
"parameters": {
|
||||
"model": "text-embedding-3-small",
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "30c18e9e-d047-40d3-8324-f5d0e7892db6",
|
||||
"name": "Insert Documents",
|
||||
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
|
||||
"position": [
|
||||
2920,
|
||||
-1840
|
||||
],
|
||||
"parameters": {
|
||||
"mode": "insert",
|
||||
"options": {},
|
||||
"tableName": {
|
||||
"__rl": true,
|
||||
"mode": "list",
|
||||
"value": "Kadampa",
|
||||
"cachedResultName": "Kadampa"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "3c0ed0ee-9134-4b4e-bcfd-632dd67a57da",
|
||||
"name": "Retrieve Rows from Table",
|
||||
"type": "n8n-nodes-base.supabase",
|
||||
"position": [
|
||||
3960,
|
||||
-1380
|
||||
],
|
||||
"parameters": {
|
||||
"tableId": "n8n",
|
||||
"operation": "getAll",
|
||||
"returnAll": true
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "53aca1b4-31e8-4699-b158-673623bc9b95",
|
||||
"name": "Sticky Note4",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
2620,
|
||||
-1160
|
||||
],
|
||||
"parameters": {
|
||||
"color": 6,
|
||||
"width": 1587.0771183771394,
|
||||
"height": 537.3056597675153,
|
||||
"content": "# DELETION\n\nAt the moment n8n does not have a built-in Supabase Node to delete records in a Vector Database. For this you would typically use the HTTP Request node to make an authorized API call to Supabase. \n\n## HTTP Request Node\n\nUse this node to send a DELETE request to your Supabase instance.\n\n- Supabase API Endpoint: Use the appropriate URL for your Supabase project. The endpoint will typically look like this: [https://<your-supabase-ref>.supabase.co/rest/v1/<your-vector-table>](https://supabase.com/docs/guides/api). Replace `<your-supabase-ref>` and `<your-vector-table>` with your details.\n### HEADERS:\n- apikey: Your Supabase API key.\n- Authorization: Bearer token with your Supabase JWT.\n- Query Parameters: Use query parameters to specify which record(s) to delete. For example, `?id=eq.<your-record-id>` where `<your-record-id>` is the specific record ID you want to delete \n(You can also reference back to the **Retrieve Rows From Table** Node to get the ID dynamically)\n\nEnsure you have the necessary permissions set up in Supabase to delete records through the API.\n\nPlease refer to the official n8n documentation for more detailed information on using the [HTTP Request Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/).\n\n_Note:_ Deleting records is a sensitive operation, so make sure that your permissions are correctly configured and that you are targeting the correct records to avoid unwanted data loss."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "4ffaccdb-9e0f-464d-9284-7771f6599fd8",
|
||||
"name": "Update Documents",
|
||||
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
|
||||
"position": [
|
||||
2100,
|
||||
-1000
|
||||
],
|
||||
"parameters": {
|
||||
"id": "1",
|
||||
"mode": "update",
|
||||
"options": {
|
||||
"queryName": "match_documents"
|
||||
},
|
||||
"tableName": {
|
||||
"__rl": true,
|
||||
"mode": "list",
|
||||
"value": "n8n",
|
||||
"cachedResultName": "n8n"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
}
|
||||
],
|
||||
"pinData": {},
|
||||
"connections": {
|
||||
"Google Drive": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Insert Documents",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "Question and Answer Chain",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Retrieve by Query": {
|
||||
"ai_vectorStore": [
|
||||
[
|
||||
{
|
||||
"node": "Vector Store Retriever",
|
||||
"type": "ai_vectorStore",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Default Data Loader": {
|
||||
"ai_document": [
|
||||
[
|
||||
{
|
||||
"node": "Insert Documents",
|
||||
"type": "ai_document",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Vector Store Retriever": {
|
||||
"ai_retriever": [
|
||||
[
|
||||
{
|
||||
"node": "Question and Answer Chain",
|
||||
"type": "ai_retriever",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Question and Answer Chain": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Customize Response",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When chat message received": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Question and Answer Chain",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Embeddings OpenAI Insertion": {
|
||||
"ai_embedding": [
|
||||
[
|
||||
{
|
||||
"node": "Insert Documents",
|
||||
"type": "ai_embedding",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Embeddings OpenAI Retrieval": {
|
||||
"ai_embedding": [
|
||||
[
|
||||
{
|
||||
"node": "Retrieve by Query",
|
||||
"type": "ai_embedding",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Embeddings OpenAI Upserting": {
|
||||
"ai_embedding": [
|
||||
[
|
||||
{
|
||||
"node": "Update Documents",
|
||||
"type": "ai_embedding",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Recursive Character Text Splitter1": {
|
||||
"ai_textSplitter": [
|
||||
[
|
||||
{
|
||||
"node": "Default Data Loader",
|
||||
"type": "ai_textSplitter",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Placeholder (File/Content to Upsert)": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Update Documents",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
{
|
||||
"id": "AQJ6QnF2yVdCWMnx",
|
||||
"meta": {
|
||||
"instanceId": "fb924c73af8f703905bc09c9ee8076f48c17b596ed05b18c0ff86915ef8a7c4a",
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"name": "SQL agent with memory",
|
||||
"tags": [],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "3544950e-4d8e-46ca-8f56-61c152a5cae3",
|
||||
"name": "Window Buffer Memory",
|
||||
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
|
||||
"position": [
|
||||
1220,
|
||||
500
|
||||
],
|
||||
"parameters": {
|
||||
"contextWindowLength": 10
|
||||
},
|
||||
"typeVersion": 1.2
|
||||
},
|
||||
{
|
||||
"id": "743cc4e7-5f24-4adc-b872-7241ee775bd0",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"position": [
|
||||
1000,
|
||||
500
|
||||
],
|
||||
"parameters": {
|
||||
"model": "gpt-4-turbo",
|
||||
"options": {
|
||||
"temperature": 0.3
|
||||
}
|
||||
},
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "rveqdSfp7pCRON1T",
|
||||
"name": "Ted's Tech Talks OpenAi"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "cc30066c-ad2c-4729-82c1-a6b0f4214dee",
|
||||
"name": "When clicking \"Test workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"position": [
|
||||
500,
|
||||
-80
|
||||
],
|
||||
"parameters": {},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "0deacd0d-45cb-4738-8da0-9d1251858867",
|
||||
"name": "Get chinook.zip example",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"position": [
|
||||
700,
|
||||
-80
|
||||
],
|
||||
"parameters": {
|
||||
"url": "https://www.sqlitetutorial.net/wp-content/uploads/2018/03/chinook.zip",
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 4.2
|
||||
},
|
||||
{
|
||||
"id": "61f34708-f8ed-44a9-8522-6042d28511ae",
|
||||
"name": "Extract zip file",
|
||||
"type": "n8n-nodes-base.compression",
|
||||
"position": [
|
||||
900,
|
||||
-80
|
||||
],
|
||||
"parameters": {},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "6a12d9ac-f1b7-4267-8b34-58cdb9d347bb",
|
||||
"name": "Save chinook.db locally",
|
||||
"type": "n8n-nodes-base.readWriteFile",
|
||||
"position": [
|
||||
1100,
|
||||
-80
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"fileName": "./chinook.db",
|
||||
"operation": "write",
|
||||
"dataPropertyName": "file_0"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "701d1325-4186-4185-886a-3738163db603",
|
||||
"name": "Load local chinook.db",
|
||||
"type": "n8n-nodes-base.readWriteFile",
|
||||
"position": [
|
||||
620,
|
||||
360
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"fileSelector": "./chinook.db"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "d7b3813d-8180-4ff1-87a4-bd54a03043af",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
440,
|
||||
-280.9454545454546
|
||||
],
|
||||
"parameters": {
|
||||
"width": 834.3272727272731,
|
||||
"height": 372.9454545454546,
|
||||
"content": "## Run this part only once\nThis section:\n* downloads the example zip file from https://www.sqlitetutorial.net/sqlite-sample-database/\n* extracts the archive (it contains only a single file)\n* saves the extracted `chinook.db` SQLite database locally\n\nNow you can use chat to \"talk\" to your data!"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "6bd25563-2c59-44c2-acf9-407bd28a15cf",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
400,
|
||||
240
|
||||
],
|
||||
"parameters": {
|
||||
"width": 558.5454545454544,
|
||||
"height": 297.89090909090913,
|
||||
"content": "## On every chat message:\n* the local SQLite database is loaded\n* JSON from Chat Trigger is combined with SQLite binary data"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "2be63956-236e-46f7-b8e4-0f55e2e25a5c",
|
||||
"name": "Combine chat input with the binary",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
820,
|
||||
360
|
||||
],
|
||||
"parameters": {
|
||||
"mode": "raw",
|
||||
"options": {
|
||||
"includeBinary": true
|
||||
},
|
||||
"jsonOutput": "={{ $('Chat Trigger').item.json }}\n"
|
||||
},
|
||||
"typeVersion": 3.3
|
||||
},
|
||||
{
|
||||
"id": "7f4c9adb-eab4-40d7-ad2e-44f2c0e3e30a",
|
||||
"name": "Sticky Note2",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
980,
|
||||
120
|
||||
],
|
||||
"parameters": {
|
||||
"width": 471.99692219161466,
|
||||
"height": 511.16641410437836,
|
||||
"content": "### LangChain SQL Agent can make several queries before producing the final answer.\nTry these examples:\n1. \"Please describe the database\". This input usually requires just 1 query + an extra observation to produce a final answer.\n2. \"What are the revenues by genre?\". This input will launch a series of Agent actions, because it needs to make several queries.\n\nThe final answer is stored in the memory and will be recalled on the next input from the user."
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "ac819eb5-13b2-4280-b9d6-06ec1209700e",
|
||||
"name": "AI Agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"position": [
|
||||
1020,
|
||||
360
|
||||
],
|
||||
"parameters": {
|
||||
"agent": "sqlAgent",
|
||||
"options": {},
|
||||
"dataSource": "sqlite"
|
||||
},
|
||||
"typeVersion": 1.6
|
||||
},
|
||||
{
|
||||
"id": "5ecaa3eb-e93e-4e41-bbc0-98a8c2b2d463",
|
||||
"name": "Chat Trigger",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"position": [
|
||||
420,
|
||||
360
|
||||
],
|
||||
"webhookId": "fb565f08-a459-4ff9-8249-1ede58599660",
|
||||
"parameters": {},
|
||||
"typeVersion": 1
|
||||
}
|
||||
],
|
||||
"active": false,
|
||||
"pinData": {},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "fbc06ddd-dbd8-49ee-bbee-2f495d5651a2",
|
||||
"connections": {
|
||||
"Chat Trigger": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Load local chinook.db",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract zip file": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Save chinook.db locally",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Window Buffer Memory": {
|
||||
"ai_memory": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_memory",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Load local chinook.db": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Combine chat input with the binary",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get chinook.zip example": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract zip file",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When clicking \"Test workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get chinook.zip example",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Combine chat input with the binary": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user