Guest User

Untitled

a guest
Dec 2nd, 2024
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.77 KB | None | 0 0
  1. {
  2. "nodes": [
  3. {
  4. "parameters": {
  5. "public": true,
  6. "initialMessages": "upload file",
  7. "options": {
  8. "allowFileUploads": true,
  9. "responseMode": "lastNode",
  10. "showWelcomeScreen": false
  11. }
  12. },
  13. "id": "36f1f675-82f2-443f-8124-7bcbc0167397",
  14. "name": "When chat message received",
  15. "type": "@n8n/n8n-nodes-langchain.chatTrigger",
  16. "typeVersion": 1.1,
  17. "position": [
  18. -240,
  19. 60
  20. ],
  21. "webhookId": "1c1f408c-25b5-4776-a3cf-da267611b299"
  22. },
  23. {
  24. "parameters": {
  25. "jsCode": "let results = [];\n\nfor (item of items) {\n for (key of Object.keys(item.binary)) {\n results.push({\n json: item.json.files.find(file => file.fileName === item.binary[key].fileName),\n binary: {\n data: item.binary[key],\n }\n });\n }\n}\n\nreturn results;"
  26. },
  27. "id": "8a4c896e-ced2-4794-8678-0b856467f29a",
  28. "name": "Files To List",
  29. "type": "n8n-nodes-base.code",
  30. "typeVersion": 2,
  31. "position": [
  32. 100,
  33. 260
  34. ]
  35. },
  36. {
  37. "parameters": {
  38. "assignments": {
  39. "assignments": [
  40. {
  41. "id": "11a4b1e5-2065-4bfd-ba7c-12def5c65116",
  42. "name": "sessionId",
  43. "value": "={{ $('When chat message received').first().json.sessionId }}",
  44. "type": "string"
  45. },
  46. {
  47. "id": "43953933-fc55-46c0-8376-cfc357789dbb",
  48. "name": "action",
  49. "value": "={{ $('When chat message received').first().json.action }}",
  50. "type": "string"
  51. },
  52. {
  53. "id": "9869788e-1743-41dc-ad6d-b48a80fa86af",
  54. "name": "chatInput",
  55. "value": "={{ $('When chat message received').first().json.chatInput }}",
  56. "type": "string"
  57. },
  58. {
  59. "id": "d2834c08-396e-4735-a919-05a46109c311",
  60. "name": "files",
  61. "value": "={{ $json.files }}",
  62. "type": "array"
  63. }
  64. ]
  65. },
  66. "options": {}
  67. },
  68. "id": "0b045f22-504d-4fc5-81ca-52a12693bc39",
  69. "name": "Set Fields",
  70. "type": "n8n-nodes-base.set",
  71. "typeVersion": 3.4,
  72. "position": [
  73. 600,
  74. 80
  75. ]
  76. },
  77. {
  78. "parameters": {
  79. "options": {}
  80. },
  81. "id": "70ca844a-641b-4791-801e-96909e9abe8d",
  82. "name": "OpenAI Chat Model",
  83. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  84. "typeVersion": 1,
  85. "position": [
  86. 840,
  87. 260
  88. ],
  89. "credentials": {
  90. "openAiApi": {
  91. "id": "iuBjR0mRLNV8iloe",
  92. "name": "OpenAi account"
  93. }
  94. }
  95. },
  96. {
  97. "parameters": {},
  98. "id": "45e8a59b-a5c4-40dd-92a2-cb0c80e74548",
  99. "name": "Execute Workflow Trigger",
  100. "type": "n8n-nodes-base.executeWorkflowTrigger",
  101. "typeVersion": 1,
  102. "position": [
  103. 520,
  104. 820
  105. ]
  106. },
  107. {
  108. "parameters": {
  109. "assignments": {
  110. "assignments": [
  111. {
  112. "id": "5771fb42-e4a9-44d7-8946-6bca673480c3",
  113. "name": "response",
  114. "value": "Unknown command. Try a different route.",
  115. "type": "string"
  116. }
  117. ]
  118. },
  119. "options": {}
  120. },
  121. "id": "e399a472-632e-47e4-8f8b-d9456d59e9ad",
  122. "name": "Unknown Route",
  123. "type": "n8n-nodes-base.set",
  124. "typeVersion": 3.4,
  125. "position": [
  126. 1080,
  127. 1320
  128. ]
  129. },
  130. {
  131. "parameters": {
  132. "options": {}
  133. },
  134. "id": "e0399fb2-1412-4cad-9ea1-e1101548ef25",
  135. "name": "OpenAI Chat Model1",
  136. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  137. "typeVersion": 1,
  138. "position": [
  139. 1620,
  140. 480
  141. ],
  142. "credentials": {
  143. "openAiApi": {
  144. "id": "iuBjR0mRLNV8iloe",
  145. "name": "OpenAi account"
  146. }
  147. }
  148. },
  149. {
  150. "parameters": {
  151. "operation": "pdf",
  152. "options": {}
  153. },
  154. "id": "03d2c8fe-e24a-418e-95b7-babee8b5cb28",
  155. "name": "Extract from File",
  156. "type": "n8n-nodes-base.extractFromFile",
  157. "typeVersion": 1,
  158. "position": [
  159. 1460,
  160. 360
  161. ]
  162. },
  163. {
  164. "parameters": {
  165. "rules": {
  166. "values": [
  167. {
  168. "conditions": {
  169. "options": {
  170. "caseSensitive": true,
  171. "leftValue": "",
  172. "typeValidation": "strict",
  173. "version": 2
  174. },
  175. "conditions": [
  176. {
  177. "leftValue": "={{ $json.fileType }}",
  178. "rightValue": "pdf",
  179. "operator": {
  180. "type": "string",
  181. "operation": "equals"
  182. }
  183. }
  184. ],
  185. "combinator": "and"
  186. },
  187. "renameOutput": true,
  188. "outputKey": "pdf"
  189. },
  190. {
  191. "conditions": {
  192. "options": {
  193. "caseSensitive": true,
  194. "leftValue": "",
  195. "typeValidation": "strict",
  196. "version": 2
  197. },
  198. "conditions": [
  199. {
  200. "id": "c0432ab1-1b11-4b47-a135-099be7fde656",
  201. "leftValue": "={{ [\"jpg\",\"jpeg\",\"png\",\"gif\"] }}",
  202. "rightValue": "={{ $json.fileType.toLowerCase() }}",
  203. "operator": {
  204. "type": "array",
  205. "operation": "contains",
  206. "rightType": "any"
  207. }
  208. }
  209. ],
  210. "combinator": "and"
  211. },
  212. "renameOutput": true,
  213. "outputKey": "image"
  214. }
  215. ]
  216. },
  217. "options": {}
  218. },
  219. "id": "6d6f3374-0b08-4de1-b2b5-8dc876e01b98",
  220. "name": "Handle FileType",
  221. "type": "n8n-nodes-base.switch",
  222. "typeVersion": 3.2,
  223. "position": [
  224. 1240,
  225. 500
  226. ]
  227. },
  228. {
  229. "parameters": {
  230. "options": {}
  231. },
  232. "id": "38c3fe12-eba2-4f08-bc52-d512ff5aea22",
  233. "name": "OpenAI Chat Model2",
  234. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  235. "typeVersion": 1,
  236. "position": [
  237. 1480,
  238. 780
  239. ],
  240. "credentials": {
  241. "openAiApi": {
  242. "id": "iuBjR0mRLNV8iloe",
  243. "name": "OpenAi account"
  244. }
  245. }
  246. },
  247. {
  248. "parameters": {
  249. "assignments": {
  250. "assignments": [
  251. {
  252. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  253. "name": "response",
  254. "value": "={{ $json.text }}",
  255. "type": "string"
  256. }
  257. ]
  258. },
  259. "options": {}
  260. },
  261. "id": "a4ed6434-9a79-4de9-a894-acfb7c494d4d",
  262. "name": "Send Response",
  263. "type": "n8n-nodes-base.set",
  264. "typeVersion": 3.4,
  265. "position": [
  266. 1780,
  267. 640
  268. ]
  269. },
  270. {
  271. "parameters": {
  272. "promptType": "define",
  273. "text": "={{ $('Execute Workflow Trigger').first().json.query.question }}",
  274. "messages": {
  275. "messageValues": [
  276. {
  277. "message": "Answer the user's question using the contents of the pdf provided."
  278. },
  279. {
  280. "type": "HumanMessagePromptTemplate",
  281. "message": "=This is the content of the pdf:\n{{ $json.text }}"
  282. }
  283. ]
  284. }
  285. },
  286. "id": "655d3dfa-d2b4-4bf5-bedb-be3a03f3ac75",
  287. "name": "Answer from PDF Contents",
  288. "type": "@n8n/n8n-nodes-langchain.chainLlm",
  289. "typeVersion": 1.5,
  290. "position": [
  291. 1620,
  292. 360
  293. ]
  294. },
  295. {
  296. "parameters": {
  297. "assignments": {
  298. "assignments": [
  299. {
  300. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  301. "name": "response",
  302. "value": "={{ $json.text }}",
  303. "type": "string"
  304. }
  305. ]
  306. },
  307. "options": {}
  308. },
  309. "id": "1e93c421-9206-4079-90ea-92e6a2812198",
  310. "name": "Send Response1",
  311. "type": "n8n-nodes-base.set",
  312. "typeVersion": 3.4,
  313. "position": [
  314. 1940,
  315. 360
  316. ]
  317. },
  318. {
  319. "parameters": {
  320. "promptType": "define",
  321. "text": "={{ $json.chatInput }}\n{{\n$json.files\n ? `Here are the file locations:\n ${$json.files.map(file => file.fileName).join('\\n')}\n `\n : ''\n}}",
  322. "options": {
  323. "systemMessage": "Answer the user's question.\n\nAll files given by the user are stored in a directory. Use the tool to query the files where relevant."
  324. }
  325. },
  326. "id": "e946d19c-b3fe-4f4b-8f9d-bbee9cb7a15c",
  327. "name": "AI Agent",
  328. "type": "@n8n/n8n-nodes-langchain.agent",
  329. "typeVersion": 1.7,
  330. "position": [
  331. 840,
  332. 80
  333. ]
  334. },
  335. {
  336. "parameters": {
  337. "assignments": {
  338. "assignments": [
  339. {
  340. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  341. "name": "response",
  342. "value": "={{ $json.stdout }}",
  343. "type": "string"
  344. }
  345. ]
  346. },
  347. "options": {}
  348. },
  349. "id": "9465f0e6-f2c5-468b-aa9a-946fc03f77f9",
  350. "name": "Send Response2",
  351. "type": "n8n-nodes-base.set",
  352. "typeVersion": 3.4,
  353. "position": [
  354. 1240,
  355. 920
  356. ]
  357. },
  358. {
  359. "parameters": {
  360. "name": "read_file_from_directory",
  361. "description": "Call this tool to query the contents of a file saved in the directory. Please note that only the answer will be returned and not the file.",
  362. "workflowId": {
  363. "__rl": true,
  364. "value": "={{ $workflow.id }}",
  365. "mode": "id"
  366. },
  367. "fields": {
  368. "values": [
  369. {
  370. "name": "route",
  371. "stringValue": "read_file"
  372. }
  373. ]
  374. },
  375. "specifyInputSchema": true,
  376. "schemaType": "manual",
  377. "inputSchema": "{\n\"type\": \"object\",\n\"properties\": {\n \"question\": {\n \"type\": \"string\",\n \"description\": \"ensure this is a fully formed question\"\n },\n\t\"filepath\": { \"type\": \"string\" }\n }\n}"
  378. },
  379. "id": "b38901b9-97d2-4070-b28c-2f39b7af4639",
  380. "name": "Read File Tool",
  381. "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
  382. "typeVersion": 1.2,
  383. "position": [
  384. 1080,
  385. 260
  386. ]
  387. },
  388. {
  389. "parameters": {
  390. "name": "search_directory",
  391. "description": "Call this tool to search over the directory listing.",
  392. "workflowId": {
  393. "__rl": true,
  394. "value": "={{ $workflow.id }}",
  395. "mode": "id"
  396. },
  397. "fields": {
  398. "values": [
  399. {
  400. "name": "route",
  401. "stringValue": "search_file"
  402. }
  403. ]
  404. },
  405. "specifyInputSchema": true,
  406. "jsonSchemaExample": "{\n\t\"search_terms\": \"some_value\"\n}"
  407. },
  408. "id": "3c5a2c48-62ce-4b31-b7ee-4f32cd1add22",
  409. "name": "Search File Tool",
  410. "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
  411. "typeVersion": 1.2,
  412. "position": [
  413. 1200,
  414. 260
  415. ]
  416. },
  417. {
  418. "parameters": {
  419. "rules": {
  420. "values": [
  421. {
  422. "conditions": {
  423. "options": {
  424. "caseSensitive": true,
  425. "leftValue": "",
  426. "typeValidation": "strict",
  427. "version": 2
  428. },
  429. "conditions": [
  430. {
  431. "leftValue": "={{ $json.files }}",
  432. "rightValue": "",
  433. "operator": {
  434. "type": "array",
  435. "operation": "notExists",
  436. "singleValue": true
  437. }
  438. }
  439. ],
  440. "combinator": "and"
  441. },
  442. "renameOutput": true,
  443. "outputKey": "without files"
  444. },
  445. {
  446. "conditions": {
  447. "options": {
  448. "caseSensitive": true,
  449. "leftValue": "",
  450. "typeValidation": "strict",
  451. "version": 2
  452. },
  453. "conditions": [
  454. {
  455. "id": "0d67ec0a-1d61-4f6a-97e5-965b0d340ae4",
  456. "leftValue": "={{ $json.files }}",
  457. "rightValue": "",
  458. "operator": {
  459. "type": "array",
  460. "operation": "exists",
  461. "singleValue": true
  462. }
  463. }
  464. ],
  465. "combinator": "and"
  466. },
  467. "renameOutput": true,
  468. "outputKey": "with files"
  469. }
  470. ]
  471. },
  472. "options": {}
  473. },
  474. "id": "ae3aea1e-f5a8-4365-b1ac-56496404d071",
  475. "name": "Has Files?",
  476. "type": "n8n-nodes-base.switch",
  477. "typeVersion": 3.2,
  478. "position": [
  479. -80,
  480. 60
  481. ]
  482. },
  483. {
  484. "parameters": {
  485. "rules": {
  486. "values": [
  487. {
  488. "conditions": {
  489. "options": {
  490. "caseSensitive": true,
  491. "leftValue": "",
  492. "typeValidation": "strict",
  493. "version": 2
  494. },
  495. "conditions": [
  496. {
  497. "leftValue": "={{ $json.route }}",
  498. "rightValue": "read_file",
  499. "operator": {
  500. "type": "string",
  501. "operation": "equals"
  502. }
  503. }
  504. ],
  505. "combinator": "and"
  506. },
  507. "renameOutput": true,
  508. "outputKey": "Read File from Directory"
  509. },
  510. {
  511. "conditions": {
  512. "options": {
  513. "caseSensitive": true,
  514. "leftValue": "",
  515. "typeValidation": "strict",
  516. "version": 2
  517. },
  518. "conditions": [
  519. {
  520. "id": "2d2b7d5d-ac9b-492c-b85f-db423dce1545",
  521. "leftValue": "={{ $json.route }}",
  522. "rightValue": "search_file",
  523. "operator": {
  524. "type": "string",
  525. "operation": "equals",
  526. "name": "filter.operator.equals"
  527. }
  528. }
  529. ],
  530. "combinator": "and"
  531. },
  532. "renameOutput": true,
  533. "outputKey": "search_file"
  534. },
  535. {
  536. "conditions": {
  537. "options": {
  538. "caseSensitive": true,
  539. "leftValue": "",
  540. "typeValidation": "strict",
  541. "version": 2
  542. },
  543. "conditions": [
  544. {
  545. "id": "804cb293-28f0-4525-9c68-2de5b279b7d3",
  546. "leftValue": "={{ $json.route }}",
  547. "rightValue": "print_file",
  548. "operator": {
  549. "type": "string",
  550. "operation": "equals",
  551. "name": "filter.operator.equals"
  552. }
  553. }
  554. ],
  555. "combinator": "and"
  556. },
  557. "renameOutput": true,
  558. "outputKey": "print_file"
  559. }
  560. ]
  561. },
  562. "options": {
  563. "fallbackOutput": "extra"
  564. }
  565. },
  566. "id": "21a9081c-d56a-44dc-a924-ac83c4ef2e9e",
  567. "name": "Handle Route",
  568. "type": "n8n-nodes-base.switch",
  569. "typeVersion": 3.2,
  570. "position": [
  571. 700,
  572. 820
  573. ]
  574. },
  575. {
  576. "parameters": {
  577. "content": "### 2. Split Files Array into Separate Items\nOnly way to split is to use the code node. This allows us to action each file separately.",
  578. "height": 97.49999999999994,
  579. "width": 333.74999999999994,
  580. "color": 7
  581. },
  582. "id": "5570607b-12b9-4802-9097-ab120a166649",
  583. "name": "Sticky Note",
  584. "type": "n8n-nodes-base.stickyNote",
  585. "typeVersion": 1,
  586. "position": [
  587. -140,
  588. 420
  589. ]
  590. },
  591. {
  592. "parameters": {
  593. "aggregate": "aggregateAllItemData",
  594. "destinationFieldName": "files",
  595. "options": {}
  596. },
  597. "id": "e6d6dbbc-ab04-4c87-bec1-eff8eea01f80",
  598. "name": "Combine",
  599. "type": "n8n-nodes-base.aggregate",
  600. "typeVersion": 1,
  601. "position": [
  602. 420,
  603. 260
  604. ]
  605. },
  606. {
  607. "parameters": {
  608. "content": "### 3. Combine file paths using Aggregate node\nWhen returning the filepaths to the agent, we don't want them as separate items but rather just a single list to inject into the prompt.",
  609. "height": 106.24999999999991,
  610. "width": 363.74999999999994,
  611. "color": 7
  612. },
  613. "id": "bfda9dc8-39fd-4627-b8a1-d75713dede9a",
  614. "name": "Sticky Note1",
  615. "type": "n8n-nodes-base.stickyNote",
  616. "typeVersion": 1,
  617. "position": [
  618. 420,
  619. 420
  620. ]
  621. },
  622. {
  623. "parameters": {
  624. "content": "### 1. Detect if files are included\nJust check the message before it hits the agent. You can put any number of other nodes in-between the chat trigger and AI agent.",
  625. "height": 113.74999999999994,
  626. "width": 333.74999999999994,
  627. "color": 7
  628. },
  629. "id": "75e5f1a5-85cb-4b36-b22d-b5a0d2d698d9",
  630. "name": "Sticky Note2",
  631. "type": "n8n-nodes-base.stickyNote",
  632. "typeVersion": 1,
  633. "position": [
  634. -160,
  635. -100
  636. ]
  637. },
  638. {
  639. "parameters": {
  640. "content": "### 4. Use tools to interact with the files saved to disk\nCustom workflow tools are preferred method here.",
  641. "height": 107.99999999999997,
  642. "width": 234.00000000000006,
  643. "color": 7
  644. },
  645. "id": "6fb1ca32-3403-43df-8f99-0c70d94aa9af",
  646. "name": "Sticky Note3",
  647. "type": "n8n-nodes-base.stickyNote",
  648. "typeVersion": 1,
  649. "position": [
  650. 900,
  651. -80
  652. ]
  653. },
  654. {
  655. "parameters": {
  656. "content": "### 5. This is an example of the subworkflow router pattern\nIt lets you have multiple subworkflow tools in one template.",
  657. "height": 115,
  658. "width": 277.00000000000006,
  659. "color": 7
  660. },
  661. "id": "13e5d922-b699-4698-aaa5-712c1de67699",
  662. "name": "Sticky Note4",
  663. "type": "n8n-nodes-base.stickyNote",
  664. "typeVersion": 1,
  665. "position": [
  666. 520,
  667. 660
  668. ]
  669. },
  670. {
  671. "parameters": {
  672. "content": "### 6. Extract contents from PDF\nTo read PDFs, you'll need to use the \"Extract from File\" node to get the text. Once extracted, provide it to the prompt as context.",
  673. "height": 115,
  674. "width": 338.00000000000006,
  675. "color": 7
  676. },
  677. "id": "4061eae9-743e-4aa7-8226-72aed67f3f4d",
  678. "name": "Sticky Note5",
  679. "type": "n8n-nodes-base.stickyNote",
  680. "typeVersion": 1,
  681. "position": [
  682. 1460,
  683. 220
  684. ]
  685. },
  686. {
  687. "parameters": {
  688. "fileSelector": "={{ $json.query.filepath }}",
  689. "options": {}
  690. },
  691. "id": "2094caf7-39aa-42c3-9c73-f768682592c9",
  692. "name": "Read File",
  693. "type": "n8n-nodes-base.readWriteFile",
  694. "typeVersion": 1,
  695. "position": [
  696. 1080,
  697. 640
  698. ],
  699. "onError": "continueErrorOutput"
  700. },
  701. {
  702. "parameters": {
  703. "content": "### 7. Extract contents from Images\nTo read images, typically the AI can read this for you without prior conversion steps. Use the binary message type for user to achieve this with n8n.",
  704. "height": 112,
  705. "width": 356.0000000000001,
  706. "color": 7
  707. },
  708. "id": "0e531344-0474-4a7a-a745-6e80c8c49ba2",
  709. "name": "Sticky Note6",
  710. "type": "n8n-nodes-base.stickyNote",
  711. "typeVersion": 1,
  712. "position": [
  713. 1600,
  714. 820
  715. ]
  716. },
  717. {
  718. "parameters": {
  719. "content": "### A note on Tool Design\nIdeally, you want the tool to return only the data you're looking for. Here the read file tool passes in a question alongside the filepath - this avoids the need to return the full file contents.",
  720. "height": 134,
  721. "width": 349
  722. },
  723. "id": "082a4383-7442-4806-b450-6e9768870e80",
  724. "name": "Sticky Note7",
  725. "type": "n8n-nodes-base.stickyNote",
  726. "typeVersion": 1,
  727. "position": [
  728. 1140,
  729. -80
  730. ]
  731. },
  732. {
  733. "parameters": {},
  734. "id": "f56cc014-d950-412f-9f0e-758b2cc1f896",
  735. "name": "Window Buffer Memory",
  736. "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
  737. "typeVersion": 1.3,
  738. "position": [
  739. 960,
  740. 260
  741. ]
  742. },
  743. {
  744. "parameters": {
  745. "promptType": "define",
  746. "text": "={{ $('Execute Workflow Trigger').first().json.query.question }}",
  747. "messages": {
  748. "messageValues": [
  749. {
  750. "message": "Answer the user's question using the contents of the image provided."
  751. },
  752. {
  753. "type": "HumanMessagePromptTemplate",
  754. "messageType": "imageBinary"
  755. }
  756. ]
  757. }
  758. },
  759. "id": "64ea6945-f986-4589-b68d-e1a05fc1a038",
  760. "name": "Answer from Image Contents",
  761. "type": "@n8n/n8n-nodes-langchain.chainLlm",
  762. "typeVersion": 1.5,
  763. "position": [
  764. 1460,
  765. 640
  766. ]
  767. },
  768. {
  769. "parameters": {
  770. "assignments": {
  771. "assignments": [
  772. {
  773. "id": "5f95ad92-2eab-44ec-9bd9-d5170e6607bc",
  774. "name": "response",
  775. "value": "File not found. Be sure to prepend the full path `/home/node/temp/...`",
  776. "type": "string"
  777. }
  778. ]
  779. },
  780. "options": {}
  781. },
  782. "id": "0be6b373-13e2-4de8-913d-efc7f1a6af22",
  783. "name": "Not Found Response",
  784. "type": "n8n-nodes-base.set",
  785. "typeVersion": 3.4,
  786. "position": [
  787. 1240,
  788. 740
  789. ]
  790. },
  791. {
  792. "parameters": {
  793. "command": "=ls /home/node/temp | grep '{{ $json.query.search_terms.split(' ').join('\\\\|') }}'"
  794. },
  795. "id": "6577da76-bf5b-45e1-afe1-0d9d2d84f8ff",
  796. "name": "Search Directory",
  797. "type": "n8n-nodes-base.executeCommand",
  798. "typeVersion": 1,
  799. "position": [
  800. 1080,
  801. 920
  802. ]
  803. },
  804. {
  805. "parameters": {
  806. "operation": "write",
  807. "fileName": "={{ `/home/node/temp/${$json.fileName}` }}",
  808. "options": {}
  809. },
  810. "id": "f631b21f-007f-4de5-a863-f380df3fa834",
  811. "name": "Read/Write Files from Disk",
  812. "type": "n8n-nodes-base.readWriteFile",
  813. "typeVersion": 1,
  814. "position": [
  815. 260,
  816. 260
  817. ]
  818. },
  819. {
  820. "parameters": {
  821. "name": "print_File",
  822. "description": "Call this tool to print the file at the full path saved in the directory. Please note that if no error is returned, it indicates that the printing was successful.",
  823. "workflowId": {
  824. "__rl": true,
  825. "value": "={{ $workflow.id }}",
  826. "mode": "id"
  827. },
  828. "fields": {
  829. "values": [
  830. {
  831. "name": "route",
  832. "stringValue": "print_file"
  833. }
  834. ]
  835. },
  836. "specifyInputSchema": true,
  837. "schemaType": "manual",
  838. "inputSchema": "{\n\"type\": \"object\",\n\"properties\": {\n \"question\": {\n \"type\": \"string\",\n \"description\": \"ensure this is a fully formed question\"\n },\n\t\"filepath\": { \"type\": \"string\" }\n }\n}"
  839. },
  840. "id": "5dc00612-7855-42f7-9c6d-7ab396753187",
  841. "name": "Print File",
  842. "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
  843. "typeVersion": 1.2,
  844. "position": [
  845. 1340,
  846. 260
  847. ]
  848. },
  849. {
  850. "parameters": {
  851. "command": "start winword.exe /p \"C:\\Users\\Administrator\\Desktop\\aaa.pdf\""
  852. },
  853. "type": "n8n-nodes-base.executeCommand",
  854. "typeVersion": 1,
  855. "position": [
  856. 1080,
  857. 1120
  858. ],
  859. "id": "3a8bbd05-44f8-422b-8cb4-61e05161fd1b",
  860. "name": "Execute Command"
  861. },
  862. {
  863. "parameters": {
  864. "assignments": {
  865. "assignments": [
  866. {
  867. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  868. "name": "response",
  869. "value": "={{ $json.stdout }}",
  870. "type": "string"
  871. }
  872. ]
  873. },
  874. "options": {}
  875. },
  876. "id": "f1e7a702-042f-4b23-a6a4-041183328ccb",
  877. "name": "Send Response3",
  878. "type": "n8n-nodes-base.set",
  879. "typeVersion": 3.4,
  880. "position": [
  881. 1420,
  882. 1120
  883. ]
  884. },
  885. {
  886. "parameters": {},
  887. "type": "n8n-nodes-base.wait",
  888. "typeVersion": 1.1,
  889. "position": [
  890. 1240,
  891. 1120
  892. ],
  893. "id": "2a11a875-e933-4ad8-95b6-d87649180dc4",
  894. "name": "Wait",
  895. "webhookId": "165734d4-0433-48c0-b9ce-50c5bfd3004a"
  896. },
  897. {
  898. "parameters": {
  899. "operation": "write",
  900. "fileName": "={{ `C:\\\\home\\\\node\\\\temp\\\\${$json.fileName}` }}",
  901. "options": {}
  902. },
  903. "id": "33fbcf3d-5868-4f39-a96d-5403fef1b819",
  904. "name": "Read/Write Files from Disk1",
  905. "type": "n8n-nodes-base.readWriteFile",
  906. "typeVersion": 1,
  907. "position": [
  908. 260,
  909. 500
  910. ]
  911. }
  912. ],
  913. "connections": {
  914. "When chat message received": {
  915. "main": [
  916. [
  917. {
  918. "node": "Has Files?",
  919. "type": "main",
  920. "index": 0
  921. }
  922. ]
  923. ]
  924. },
  925. "Files To List": {
  926. "main": [
  927. [
  928. {
  929. "node": "Read/Write Files from Disk",
  930. "type": "main",
  931. "index": 0
  932. }
  933. ]
  934. ]
  935. },
  936. "Set Fields": {
  937. "main": [
  938. [
  939. {
  940. "node": "AI Agent",
  941. "type": "main",
  942. "index": 0
  943. }
  944. ]
  945. ]
  946. },
  947. "OpenAI Chat Model": {
  948. "ai_languageModel": [
  949. [
  950. {
  951. "node": "AI Agent",
  952. "type": "ai_languageModel",
  953. "index": 0
  954. }
  955. ]
  956. ]
  957. },
  958. "Execute Workflow Trigger": {
  959. "main": [
  960. [
  961. {
  962. "node": "Handle Route",
  963. "type": "main",
  964. "index": 0
  965. }
  966. ]
  967. ]
  968. },
  969. "OpenAI Chat Model1": {
  970. "ai_languageModel": [
  971. [
  972. {
  973. "node": "Answer from PDF Contents",
  974. "type": "ai_languageModel",
  975. "index": 0
  976. }
  977. ]
  978. ]
  979. },
  980. "Extract from File": {
  981. "main": [
  982. [
  983. {
  984. "node": "Answer from PDF Contents",
  985. "type": "main",
  986. "index": 0
  987. }
  988. ]
  989. ]
  990. },
  991. "Handle FileType": {
  992. "main": [
  993. [
  994. {
  995. "node": "Extract from File",
  996. "type": "main",
  997. "index": 0
  998. }
  999. ],
  1000. [
  1001. {
  1002. "node": "Answer from Image Contents",
  1003. "type": "main",
  1004. "index": 0
  1005. }
  1006. ]
  1007. ]
  1008. },
  1009. "OpenAI Chat Model2": {
  1010. "ai_languageModel": [
  1011. [
  1012. {
  1013. "node": "Answer from Image Contents",
  1014. "type": "ai_languageModel",
  1015. "index": 0
  1016. }
  1017. ]
  1018. ]
  1019. },
  1020. "Answer from PDF Contents": {
  1021. "main": [
  1022. [
  1023. {
  1024. "node": "Send Response1",
  1025. "type": "main",
  1026. "index": 0
  1027. }
  1028. ]
  1029. ]
  1030. },
  1031. "Read File Tool": {
  1032. "ai_tool": [
  1033. [
  1034. {
  1035. "node": "AI Agent",
  1036. "type": "ai_tool",
  1037. "index": 0
  1038. }
  1039. ]
  1040. ]
  1041. },
  1042. "Search File Tool": {
  1043. "ai_tool": [
  1044. [
  1045. {
  1046. "node": "AI Agent",
  1047. "type": "ai_tool",
  1048. "index": 0
  1049. }
  1050. ]
  1051. ]
  1052. },
  1053. "Has Files?": {
  1054. "main": [
  1055. [
  1056. {
  1057. "node": "Set Fields",
  1058. "type": "main",
  1059. "index": 0
  1060. }
  1061. ],
  1062. [
  1063. {
  1064. "node": "Files To List",
  1065. "type": "main",
  1066. "index": 0
  1067. }
  1068. ]
  1069. ]
  1070. },
  1071. "Handle Route": {
  1072. "main": [
  1073. [
  1074. {
  1075. "node": "Read File",
  1076. "type": "main",
  1077. "index": 0
  1078. }
  1079. ],
  1080. [
  1081. {
  1082. "node": "Search Directory",
  1083. "type": "main",
  1084. "index": 0
  1085. }
  1086. ],
  1087. [
  1088. {
  1089. "node": "Execute Command",
  1090. "type": "main",
  1091. "index": 0
  1092. }
  1093. ],
  1094. [
  1095. {
  1096. "node": "Unknown Route",
  1097. "type": "main",
  1098. "index": 0
  1099. }
  1100. ]
  1101. ]
  1102. },
  1103. "Combine": {
  1104. "main": [
  1105. [
  1106. {
  1107. "node": "Set Fields",
  1108. "type": "main",
  1109. "index": 0
  1110. }
  1111. ]
  1112. ]
  1113. },
  1114. "Read File": {
  1115. "main": [
  1116. [
  1117. {
  1118. "node": "Handle FileType",
  1119. "type": "main",
  1120. "index": 0
  1121. }
  1122. ],
  1123. [
  1124. {
  1125. "node": "Not Found Response",
  1126. "type": "main",
  1127. "index": 0
  1128. }
  1129. ]
  1130. ]
  1131. },
  1132. "Window Buffer Memory": {
  1133. "ai_memory": [
  1134. [
  1135. {
  1136. "node": "AI Agent",
  1137. "type": "ai_memory",
  1138. "index": 0
  1139. }
  1140. ]
  1141. ]
  1142. },
  1143. "Answer from Image Contents": {
  1144. "main": [
  1145. [
  1146. {
  1147. "node": "Send Response",
  1148. "type": "main",
  1149. "index": 0
  1150. }
  1151. ]
  1152. ]
  1153. },
  1154. "Search Directory": {
  1155. "main": [
  1156. [
  1157. {
  1158. "node": "Send Response2",
  1159. "type": "main",
  1160. "index": 0
  1161. }
  1162. ]
  1163. ]
  1164. },
  1165. "Read/Write Files from Disk": {
  1166. "main": [
  1167. [
  1168. {
  1169. "node": "Combine",
  1170. "type": "main",
  1171. "index": 0
  1172. }
  1173. ]
  1174. ]
  1175. },
  1176. "Print File": {
  1177. "ai_tool": [
  1178. [
  1179. {
  1180. "node": "AI Agent",
  1181. "type": "ai_tool",
  1182. "index": 0
  1183. }
  1184. ]
  1185. ]
  1186. },
  1187. "Execute Command": {
  1188. "main": [
  1189. [
  1190. {
  1191. "node": "Wait",
  1192. "type": "main",
  1193. "index": 0
  1194. }
  1195. ]
  1196. ]
  1197. },
  1198. "Wait": {
  1199. "main": [
  1200. [
  1201. {
  1202. "node": "Send Response3",
  1203. "type": "main",
  1204. "index": 0
  1205. }
  1206. ]
  1207. ]
  1208. }
  1209. },
  1210. "pinData": {}
  1211. }
Advertisement
Add Comment
Please, Sign In to add comment