workflows/TundraServiceAgent.json

280 lines
8.9 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"createdAt": "2025-11-02T05:02:19.123Z",
"updatedAt": "2025-11-04T23:41:57.000Z",
"id": "6ud3axN5YpUjXnHV",
"name": "TundraServiceAgent",
"active": false,
"isArchived": true,
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
0,
0
],
"id": "344ae01f-abf2-4ce0-a523-f27835729876",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/embeddings",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer 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"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "input",
"value": "={{ $json.chunk }}"
},
{
"name": "model",
"value": "text-embedding-3-small"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
832,
128
],
"id": "f02b8980-20f5-45b2-8cce-50d15c721b83",
"name": "HTTP Request"
},
{
"parameters": {
"jsCode": "// Split full text into 1000-character chunks with 100-char overlap\nconst text = $json.text;\nconst chunkSize = 1000;\nconst overlap = 100;\nlet chunks = [];\n\nfor (let i = 0; i < text.length; i += (chunkSize - overlap)) {\n chunks.push(text.substring(i, i + chunkSize));\n}\n\nreturn chunks.map((chunk, index) => ({\n json: {\n chunk,\n chunk_id: index,\n source: \"Tundra Service Manual\"\n }\n}));\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
624,
0
],
"id": "1acbf666-01a1-4bdc-a29f-9d474526aaa9",
"name": "Chunk Test"
},
{
"parameters": {
"operation": "pdf",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
416,
0
],
"id": "2f67125b-a8be-4ba1-b77c-326da0e3764b",
"name": "Extract Text"
},
{
"parameters": {
"fileSelector": "/data/bill/T-ADG-0120-D.pdf",
"options": {}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
208,
0
],
"id": "fba2ff1a-86eb-4378-874e-80d1b2154785",
"name": "Read PDF"
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const embedding = $json.data?.[0]?.embedding;\nconst chunk = $json.chunk;\nconst chunkId = $json.chunk_id ?? 0;\n\nif (!embedding || !Array.isArray(embedding)) {\n throw new Error(\"Invalid or missing embedding vector\");\n}\n\nif (!chunk) {\n throw new Error(\"Missing chunk text — likely merge issue\");\n}\n\nreturn {\n points: [\n {\n id: chunkId,\n vector: embedding,\n payload: {\n text: chunk,\n source: \"Tundra Service Manual\",\n chunk_id: chunkId\n }\n }\n ]\n};\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1248,
0
],
"id": "2ff03d0a-5bdb-4d90-bc6d-61f785e00885",
"name": "Format for Qdrant"
},
{
"parameters": {
"method": "PUT",
"url": "http://10.20.22.1:6333/collections/tundra_manual/points?wait=true",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"contentType": "raw",
"body": "={{ JSON.stringify($data) }}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1440,
0
],
"id": "6ed671cd-e0f6-41eb-b704-2990c2c1e43c",
"name": "Upsert into Qdrant"
},
{
"parameters": {
"method": "PUT",
"url": "http://10.20.22.1:6333/collections/tundra_manual",
"sendBody": true,
"contentType": "raw",
"body": "{ \"vectors\": { \"size\": 1536, \"distance\": \"Cosine\" } }",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
208,
-192
],
"id": "834271d2-22fc-4d78-a4f6-41ed1219cfb8",
"name": "Collection Setup"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
1040,
0
],
"id": "4ce0eb5f-21ac-46bc-8e5e-0ff9a86f804e",
"name": "Merge"
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "Read PDF",
"type": "main",
"index": 0
}
]
]
},
"Chunk Test": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Extract Text": {
"main": [
[
{
"node": "Chunk Test",
"type": "main",
"index": 0
}
]
]
},
"Read PDF": {
"main": [
[
{
"node": "Extract Text",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Format for Qdrant": {
"main": [
[
{
"node": "Upsert into Qdrant",
"type": "main",
"index": 0
}
]
]
},
"Collection Setup": {
"main": [
[]
]
},
"Merge": {
"main": [
[
{
"node": "Format for Qdrant",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": null,
"pinData": {},
"versionId": "8cdeb3b2-9167-4a5f-83e5-030d410a1784",
"triggerCount": 0,
"shared": [
{
"createdAt": "2025-11-02T05:02:19.132Z",
"updatedAt": "2025-11-02T05:02:19.132Z",
"role": "workflow:owner",
"workflowId": "6ud3axN5YpUjXnHV",
"projectId": "oI3LZpkceKxAFXfg"
}
],
"tags": []
}