feat: add folder support for workflows (fixes #70)
This commit is contained in:
@@ -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,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! \ud83d\ude4f\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,447 @@
|
||||
{
|
||||
"id": "TEA7K9MSVQGCWKe6",
|
||||
"meta": {
|
||||
"instanceId": "ac63467607103d9c95dd644384984672b90b1cb03e07edbaf18fe72b2a6c45bb",
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"name": "A/B Split Testing",
|
||||
"tags": [],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "e8404493-4297-4169-a72f-89e668ae5fbc",
|
||||
"name": "When chat message received",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"position": [
|
||||
-1460,
|
||||
-140
|
||||
],
|
||||
"webhookId": "334e3a8d-73d2-4d3c-9927-158c1169ef5e",
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"typeVersion": 1.1
|
||||
},
|
||||
{
|
||||
"id": "582e1c1b-12ff-42ff-8130-48f94eebd706",
|
||||
"name": "AI Agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"position": [
|
||||
220,
|
||||
-160
|
||||
],
|
||||
"parameters": {
|
||||
"text": "={{ $('When chat message received').item.json.chatInput }}",
|
||||
"options": {
|
||||
"systemMessage": "={{ $json.prompt }}"
|
||||
},
|
||||
"promptType": "define"
|
||||
},
|
||||
"typeVersion": 1.7
|
||||
},
|
||||
{
|
||||
"id": "39ca5c70-11d4-4f86-bde5-0f9827297be9",
|
||||
"name": "Check If Session Exists",
|
||||
"type": "n8n-nodes-base.supabase",
|
||||
"position": [
|
||||
-960,
|
||||
-140
|
||||
],
|
||||
"parameters": {
|
||||
"filters": {
|
||||
"conditions": [
|
||||
{
|
||||
"keyName": "session_id",
|
||||
"keyValue": "={{ $('When chat message received').item.json.sessionId }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"tableId": "split_test_sessions",
|
||||
"operation": "get"
|
||||
},
|
||||
"credentials": {
|
||||
"supabaseApi": {
|
||||
"id": "1iEg1EzFrF29iqp2",
|
||||
"name": "Supabase (bsde.ai)"
|
||||
}
|
||||
},
|
||||
"executeOnce": false,
|
||||
"typeVersion": 1,
|
||||
"alwaysOutputData": true
|
||||
},
|
||||
{
|
||||
"id": "35f2c270-9571-41ba-ab7c-47a6742d7d90",
|
||||
"name": "If Session Does Exist",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"position": [
|
||||
-720,
|
||||
-140
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"conditions": {
|
||||
"options": {
|
||||
"version": 2,
|
||||
"leftValue": "",
|
||||
"caseSensitive": true,
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"combinator": "and",
|
||||
"conditions": [
|
||||
{
|
||||
"id": "4270c464-6874-45d2-aa3b-606f45544c3d",
|
||||
"operator": {
|
||||
"type": "number",
|
||||
"operation": "exists",
|
||||
"singleValue": true
|
||||
},
|
||||
"leftValue": "={{ $json.id }}",
|
||||
"rightValue": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"typeVersion": 2.2
|
||||
},
|
||||
{
|
||||
"id": "ec00ad92-96e9-4936-a547-2a2715ff5c32",
|
||||
"name": "Assign Path To Session",
|
||||
"type": "n8n-nodes-base.supabase",
|
||||
"position": [
|
||||
-400,
|
||||
-20
|
||||
],
|
||||
"parameters": {
|
||||
"tableId": "split_test_sessions",
|
||||
"fieldsUi": {
|
||||
"fieldValues": [
|
||||
{
|
||||
"fieldId": "show_alternative",
|
||||
"fieldValue": "={{ Math.random() < 0.5 }}"
|
||||
},
|
||||
{
|
||||
"fieldId": "session_id",
|
||||
"fieldValue": "={{ $('When chat message received').item.json.sessionId }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"credentials": {
|
||||
"supabaseApi": {
|
||||
"id": "1iEg1EzFrF29iqp2",
|
||||
"name": "Supabase (bsde.ai)"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "92ee7145-30ae-41e9-bc04-eef03b84485e",
|
||||
"name": "Define Path Values",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
-1200,
|
||||
-140
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "9581a184-a120-4b1f-8408-cfe97520d107",
|
||||
"name": "baseline_value",
|
||||
"type": "string",
|
||||
"value": "The dog's name is Ben"
|
||||
},
|
||||
{
|
||||
"id": "1752f2c4-4ce4-4893-b8db-1c59131c298a",
|
||||
"name": "alternative_value",
|
||||
"type": "string",
|
||||
"value": "The dog's name is Tom"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "23c1b4e2-2ba2-4237-bb4b-b92da127d201",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"position": [
|
||||
300,
|
||||
60
|
||||
],
|
||||
"parameters": {
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"mode": "list",
|
||||
"value": "gpt-4o-mini"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "1OMpAMAKR9l3eUDI",
|
||||
"name": "OpenAi account"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1.2
|
||||
},
|
||||
{
|
||||
"id": "be3f14b9-68c7-457d-b5bf-a6abbadf5b67",
|
||||
"name": "Postgres Chat Memory",
|
||||
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
|
||||
"position": [
|
||||
480,
|
||||
60
|
||||
],
|
||||
"parameters": {
|
||||
"tableName": "n8n_split_test_chat_histories",
|
||||
"sessionKey": "={{ $('When chat message received').item.json.sessionId }}",
|
||||
"sessionIdType": "customKey"
|
||||
},
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "tzLXHvhykxvYghPC",
|
||||
"name": "bsde.ai Supabase (Session Pooler)"
|
||||
}
|
||||
},
|
||||
"typeVersion": 1.3
|
||||
},
|
||||
{
|
||||
"id": "1c20d274-2482-4551-a4ea-64860eb35276",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-1520,
|
||||
-260
|
||||
],
|
||||
"parameters": {
|
||||
"color": 7,
|
||||
"width": 220,
|
||||
"height": 300,
|
||||
"content": "## 1. Receive Message\n\n"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "ee22d3b1-d447-4e35-8ac4-d093edf6deee",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-1280,
|
||||
-340
|
||||
],
|
||||
"parameters": {
|
||||
"color": 7,
|
||||
"width": 1340,
|
||||
"height": 500,
|
||||
"content": "## 2. Determine Prompt for LLM\n"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "7d90ec00-5fca-4b0d-bc1f-e8b8c179b960",
|
||||
"name": "Sticky Note2",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
80,
|
||||
-240
|
||||
],
|
||||
"parameters": {
|
||||
"color": 7,
|
||||
"width": 520,
|
||||
"height": 440,
|
||||
"content": "## 3. AI Agent"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "b9b9e0e8-53c1-4d6a-bbdc-c2a13d740dfb",
|
||||
"name": "Get Correct Prompt",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"position": [
|
||||
-80,
|
||||
-160
|
||||
],
|
||||
"parameters": {
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "08de68ec-0f12-43ee-98ab-59d8a414f114",
|
||||
"name": "prompt",
|
||||
"type": "string",
|
||||
"value": "={{ $json.show_alternative ? $('Define Path Values').item.json.alternative_value : $('Define Path Values').item.json.baseline_value }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"typeVersion": 3.4
|
||||
},
|
||||
{
|
||||
"id": "2b78ce9b-e6b4-4744-8ddf-00f8ae990fc8",
|
||||
"name": "Sticky Note6",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-1260,
|
||||
-240
|
||||
],
|
||||
"parameters": {
|
||||
"color": 5,
|
||||
"width": 220,
|
||||
"height": 260,
|
||||
"content": "### Modification\nSet the values of the baseline and alternative prompts"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "0646f176-407a-41ee-b602-34bd681fc421",
|
||||
"name": "Sticky Note8",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
100,
|
||||
40
|
||||
],
|
||||
"parameters": {
|
||||
"color": 5,
|
||||
"width": 340,
|
||||
"height": 140,
|
||||
"content": "### Modification\nReplace this sub-node \nto use a different language\n model"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "a391018c-5d28-4384-89e1-0435758a6945",
|
||||
"name": "Sticky Note5",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-1480,
|
||||
-600
|
||||
],
|
||||
"parameters": {
|
||||
"width": 520,
|
||||
"height": 240,
|
||||
"content": "### Setup\n1. Create a table in Supabase called **split_test_sessions**. It needs to have the following columns: **session_id** (`text`) and **show_alternative** (`bool`)\n2. Add your **Supabase**, **OpenAI**, and **PostgreSQL** credentials\n3. Modify the **Define Path Values** node to set the baseline and alternative prompt values.\n4. Activate the workflow and test by sending messages through n8n's inbuilt chat\n5. Experiment with different chat sessions to test see both prompts in action"
|
||||
},
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"id": "2382d146-f0c1-4de6-9e90-b17c304df692",
|
||||
"name": "Sticky Note3",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"position": [
|
||||
-2120,
|
||||
-360
|
||||
],
|
||||
"parameters": {
|
||||
"width": 560,
|
||||
"height": 480,
|
||||
"content": "\n## Split Test Different Agent Prompts with Supabase and OpenAI\n### Use Case\nOftentimes, it's useful to test different settings for a large language model in production against various metrics. Split testing is a good method for doing this.\n### What it Does\nThis workflow randomly assigns chat sessions to one of two prompts, the baseline and the alternative. The agent will use the same prompt for all interactions in that chat session.\n### How it Works\n1. When messages arrive, a table containing information regarding session ID and which prompt to use is checked to see if the chat already exists\n2. If it does not, the session ID is added to the table and a prompt is randomly assigned\n3. These values are then used to generate a response\n### Next Steps\n- Modify the workflow to test different LLM settings such as temperature\n- Add a method to measure the efficacy of the two alternative prompts"
|
||||
},
|
||||
"typeVersion": 1
|
||||
}
|
||||
],
|
||||
"active": false,
|
||||
"pinData": {},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "339c6f2f-e4d1-4922-9442-2c1a78e96067",
|
||||
"connections": {
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Define Path Values": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Check If Session Exists",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get Correct Prompt": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Postgres Chat Memory": {
|
||||
"ai_memory": [
|
||||
[
|
||||
{
|
||||
"node": "AI Agent",
|
||||
"type": "ai_memory",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"If Session Does Exist": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get Correct Prompt",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "Assign Path To Session",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Assign Path To Session": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get Correct Prompt",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Check If Session Exists": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "If Session Does Exist",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When chat message received": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Define Path Values",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user