-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Expand file tree
/
Copy pathBreakdown Documents into Study Notes using Templating MistralAI and Qdrant.json
More file actions
1260 lines (1260 loc) · 23.6 KB
/
Breakdown Documents into Study Notes using Templating MistralAI and Qdrant.json
File metadata and controls
1260 lines (1260 loc) · 23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"meta": {
"instanceId": "26ba763460b97c249b82942b23b6384876dfeb9327513332e743c5f6219c2b8e"
},
"nodes": [
{
"id": "a3af309b-d24c-42fe-8bcd-f330927c7a3c",
"name": "Local File Trigger",
"type": "n8n-nodes-base.localFileTrigger",
"position": [
140,
260
],
"parameters": {
"path": "/home/node/storynotes/context",
"events": [
"add"
],
"options": {
"usePolling": true,
"followSymlinks": true
},
"triggerOn": "folder"
},
"typeVersion": 1
},
{
"id": "048f9d67-6519-4dea-97df-aaddfefbfea2",
"name": "Default Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1300,
720
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "project",
"value": "={{ $('Settings').item.json.project }}"
},
{
"name": "filename",
"value": "={{ $('Settings').item.json.filename }}"
}
]
}
},
"jsonData": "={{ $json.data }}",
"jsonMode": "expressionData"
},
"typeVersion": 1
},
{
"id": "9e9047c9-4428-4afb-8c74-d6eb1075a65a",
"name": "Recursive Character Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
1300,
860
],
"parameters": {
"options": {},
"chunkSize": 2000
},
"typeVersion": 1
},
{
"id": "e42e3f82-6cd9-40c4-9da2-8f87ee5b3956",
"name": "Embeddings Mistral Cloud",
"type": "@n8n/n8n-nodes-langchain.embeddingsMistralCloud",
"position": [
1180,
720
],
"parameters": {
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "578c63db-4f6e-4341-ab0d-111debd519be",
"name": "Mistral Cloud Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
"position": [
2660,
840
],
"parameters": {
"model": "open-mixtral-8x7b",
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "c34adb3e-1fb9-4248-ae83-2bac34c8b0a4",
"name": "Mistral Cloud Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
"position": [
1200,
400
],
"parameters": {
"model": "open-mixtral-8x7b",
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "98e6dcc0-1e3a-4119-b657-0949f34ba525",
"name": "Prep Incoming Doc",
"type": "n8n-nodes-base.set",
"position": [
900,
420
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "da64ffde-1e8f-478d-baea-59fc05e6d3ce",
"name": "data",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "ab88cf9a-d310-4bef-9280-8b23729e7cc9",
"name": "Settings",
"type": "n8n-nodes-base.set",
"position": [
320,
260
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "df327b01-961c-4a49-8455-58c3fbff111a",
"name": "project",
"type": "string",
"value": "={{ $json.path.split('/').slice(0, 4)[3] }}"
},
{
"id": "6b7d26f9-3a38-417e-85d0-4e9d42476465",
"name": "path",
"type": "string",
"value": "={{ $json.path }}"
},
{
"id": "bb4471c7-d894-4739-99a6-4be247794ffa",
"name": "filename",
"type": "string",
"value": "={{ $json.path.split('/').last() }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "35c6b678-e6e9-4adf-a904-909fa2401d5e",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
1600,
420
],
"parameters": {
"mode": "chooseBranch"
},
"typeVersion": 2.1
},
{
"id": "0fa13be8-8500-486c-a1c6-cc1df00a4947",
"name": "Get Doc Types",
"type": "n8n-nodes-base.set",
"position": [
2000,
420
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "{\n \"docs\": [\n {\n \"filename\": \"study_guide.md\",\n \"title\": \"Study Guide\",\n \"description\": \"A Study Guide is a consolidated resource designed to aid learning. This guide includes three key elements: * A short answer quiz accompanied by an answer key to test comprehension. * A curated list of long-form essay questions to encourage deeper analysis and synthesis of the material. * A glossary of key terms to reinforce understanding of important concepts.\"\n },\n {\n \"filename\": \"timeline.md\",\n \"title\": \"Timeline\",\n \"description\": \"A Timeline organizes all significant events described in the sources you have uploaded in chronological order. This ordered list makes it easier to understand the sequence of events and their connection to the broader context of your sources. In addition to the list of events, the Timeline also provides a “cast of characters,” which comprises short biographical sketches of all the important people mentioned in your uploaded sources. These short biographies can help you quickly grasp the roles of various individuals involved in the events described by the Timeline.\"\n },\n {\n \"filename\": \"briefing_doc.md\",\n \"title\": \"Briefing Doc\",\n \"description\": \"A Briefing Doc identifies and presents the most important facts and insights from the sources in an easy-to-understand outline format. This format is designed to provide a concise overview of the key takeaways from the uploaded materials.\"\n }\n ]\n}\n"
},
"executeOnce": true,
"typeVersion": 3.3
},
{
"id": "e3469368-f214-4549-844e-7febfbbf0202",
"name": "Split Out Doc Types",
"type": "n8n-nodes-base.splitOut",
"position": [
2160,
420
],
"parameters": {
"options": {},
"fieldToSplitOut": "docs"
},
"typeVersion": 1
},
{
"id": "df401e9e-2f70-4079-969b-6b61142fca37",
"name": "For Each Doc Type...",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2340,
420
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "c334b546-8e11-424d-bdd5-006e7086f24b",
"name": "Item List Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserItemList",
"position": [
2840,
840
],
"parameters": {
"options": {}
},
"typeVersion": 1
},
{
"id": "4267c2b5-f1cd-4df7-84ee-be01a643a1c1",
"name": "Vector Store Retriever",
"type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
"position": [
3200,
840
],
"parameters": {},
"typeVersion": 1
},
{
"id": "abf833ec-8a6d-4e13-a526-0ea6b80d578f",
"name": "Embeddings Mistral Cloud1",
"type": "@n8n/n8n-nodes-langchain.embeddingsMistralCloud",
"position": [
3200,
1060
],
"parameters": {
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "a0e50185-6662-4b11-9922-59e8b06e4967",
"name": "Qdrant Vector Store1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
3200,
940
],
"parameters": {
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "storynotes",
"cachedResultName": "storynotes"
}
},
"credentials": {
"qdrantApi": {
"id": "NyinAS3Pgfik66w5",
"name": "QdrantApi account"
}
},
"typeVersion": 1
},
{
"id": "20c5766a-d3ce-4c01-a76b-facf1a00abc2",
"name": "Mistral Cloud Chat Model2",
"type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
"position": [
3100,
840
],
"parameters": {
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "f049b7af-07f3-47e5-9476-68d73a387978",
"name": "Split Out",
"type": "n8n-nodes-base.splitOut",
"position": [
2960,
680
],
"parameters": {
"options": {},
"fieldToSplitOut": "response"
},
"typeVersion": 1
},
{
"id": "39042ae0-e17f-46cd-84be-728868950d84",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"position": [
3400,
680
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "response.text"
}
]
}
},
"typeVersion": 1
},
{
"id": "e3b900c8-515d-4ac7-88fa-c364134ba9f9",
"name": "Mistral Cloud Chat Model3",
"type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
"position": [
3540,
840
],
"parameters": {
"model": "open-mixtral-8x7b",
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "efb26a5d-6a61-44b2-ad99-6d1f8b48998d",
"name": "Discover",
"type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
"position": [
3100,
680
],
"parameters": {
"text": "={{ $json.response }}",
"promptType": "define"
},
"typeVersion": 1.3
},
{
"id": "302b7523-898e-47af-8941-aa5f8a58fd9c",
"name": "2secs",
"type": "n8n-nodes-base.wait",
"position": [
3880,
1060
],
"webhookId": "ec58ab18-03c5-4b58-bc2e-24415a236c72",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "007857b0-c12c-4c57-b07f-db30526cd747",
"name": "Get Generated Documents",
"type": "n8n-nodes-base.set",
"position": [
2680,
240
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b38546b2-47c4-4967-a2d7-98aebd589e95",
"name": "data",
"type": "string",
"value": "={{ $json.text }}"
},
{
"id": "a263519a-aa05-410a-b4f0-f5e22cc5058c",
"name": "path",
"type": "string",
"value": "={{ $('Prep For AI').item.json.path }}"
},
{
"id": "ec1687d6-0ea9-460f-b9d4-ae4a7e229e12",
"name": "filename",
"type": "string",
"value": "={{ $('Prep For AI').item.json.name }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "36fac35f-df10-41ab-96a7-3a5e67f9d8df",
"name": "Generate",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
3540,
680
],
"parameters": {
"text": "=## Document\n{{ $json.text.join('\\n') }}",
"messages": {
"messageValues": [
{
"message": "=Your job is to create a {{ $('For Each Doc Type...').item.json.title }} for the given document. {{ $('For Each Doc Type...').item.json.description }}\n\nGenerate a {{ $('For Each Doc Type...').item.json.title }} for the given document. If questions are generated, generate the answers alongside them. Format your response in markdown; use \"#\" to format headings, use \"*\" to format lists."
}
]
},
"promptType": "define"
},
"typeVersion": 1.4
},
{
"id": "b9a79cb0-bcc1-4d73-af93-5f8d7e2258a9",
"name": "Prep For AI",
"type": "n8n-nodes-base.set",
"position": [
1760,
420
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5c864125-c884-4d33-b0ed-e3eecd354196",
"name": "id",
"type": "string",
"value": "={{ $('Settings').first().json.filename.hash() }}"
},
{
"id": "93ac14c1-ae97-4ef2-a66f-6c1110f3b0fc",
"name": "project",
"type": "string",
"value": "={{ $('Settings').first().json.project }}"
},
{
"id": "fafd16b9-0002-4f7c-89d0-29788f8ec472",
"name": "path",
"type": "string",
"value": "={{ $('Settings').first().json.path }}"
},
{
"id": "5a5860ba-918b-4fb8-b18c-96c1cd22091a",
"name": "name",
"type": "string",
"value": "={{ $('Settings').first().json.filename }}"
},
{
"id": "1a1caf65-85d8-4f74-a3be-503ccfc0b2c9",
"name": "summary",
"type": "string",
"value": "={{ $('Summarization Chain').first().json.response.text }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "e40c7e99-9813-4f06-92bb-dfb2839f1037",
"name": "To Binary",
"type": "n8n-nodes-base.convertToFile",
"position": [
2860,
240
],
"parameters": {
"options": {},
"operation": "toText",
"sourceProperty": "={{ $json.data }}"
},
"typeVersion": 1.1
},
{
"id": "b55df916-7a51-4114-91b8-18a3c6ba2c56",
"name": "Export to Folder",
"type": "n8n-nodes-base.readWriteFile",
"position": [
3020,
240
],
"parameters": {
"options": {},
"fileName": "={{\n $('Get Generated Documents').item.json.path.replace(\n $('Get Generated Documents').item.json.path.split('/').last(),\n $('Get Generated Documents').item.json.filename.substring(0,21) + '...' + $('Split Out Doc Types').item.json.title + '.md'\n )\n}}",
"operation": "write"
},
"typeVersion": 1
},
{
"id": "8490664e-0ca5-4839-ad03-d3f9706c99a3",
"name": "Get FileType",
"type": "n8n-nodes-base.switch",
"position": [
480,
420
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "pdf",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.fileType }}",
"rightValue": "pdf"
}
]
},
"renameOutput": true
},
{
"outputKey": "docx",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "3a5f509d-46fe-490c-95f0-35124873c63e",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.fileType }}",
"rightValue": "docx"
}
]
},
"renameOutput": true
},
{
"outputKey": "everything else",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "75188d2f-4bea-44ea-a579-9b9a1bd1ea93",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3
},
{
"id": "386f7aac-f3b9-4565-907f-687d48b00c52",
"name": "Import File",
"type": "n8n-nodes-base.readWriteFile",
"position": [
320,
420
],
"parameters": {
"options": {},
"fileSelector": "={{ $json.path }}"
},
"typeVersion": 1
},
{
"id": "6ade93d5-61c3-450a-b78c-e210c18c0e70",
"name": "Extract from PDF",
"type": "n8n-nodes-base.extractFromFile",
"position": [
680,
260
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "f413e139-3f9c-438f-8e82-824c38f09c6b",
"name": "Extract from DOCX",
"type": "n8n-nodes-base.extractFromFile",
"position": [
680,
420
],
"parameters": {
"options": {},
"operation": "ods"
},
"typeVersion": 1
},
{
"id": "455fadea-f5c7-4bea-983f-b06da4e57510",
"name": "Extract from TEXT",
"type": "n8n-nodes-base.extractFromFile",
"position": [
680,
580
],
"parameters": {
"options": {},
"operation": "text"
},
"typeVersion": 1
},
{
"id": "b2586011-4985-4075-b51c-90301b1a8cf9",
"name": "Summarization Chain",
"type": "@n8n/n8n-nodes-langchain.chainSummarization",
"position": [
1200,
260
],
"parameters": {
"options": {},
"chunkSize": 4000
},
"typeVersion": 2
},
{
"id": "1502e72c-e97e-4148-8138-01818ab5b104",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
60,
85.80882007954312
],
"parameters": {
"color": 7,
"width": 995.1475972814769,
"height": 694.0931000693263,
"content": "## Step 1. Watch Folder and Import New Documents\n[Read more about Local File Trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.localfiletrigger)\n\nWith n8n's local file trigger, we're able to trigger the workflow when files are created in our target folder. We still have to import them however as the trigger will only give the file's path. The \"Extract From\" node is used to get at the file's contents."
},
"typeVersion": 1
},
{
"id": "7b3afc2c-3fb8-4589-9475-78f5617009cc",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1080,
82.96464765818223
],
"parameters": {
"color": 7,
"width": 824.3300768713589,
"height": 949.8141899605673,
"content": "## Step 2. Summarise and Vectorise Document Contents\n[Learn more about using the Qdrant VectorStore](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreqdrant)\n\nCapturing the document into our vector store is intended for a technique we'll use later known as Retrieval Augumented Generation or \"RAG\" for short. For our scenario, this allows our LLM to retrieve context more efficiently which produces better respsonses."
},
"typeVersion": 1
},
{
"id": "74aabb02-ca5d-41ad-b84f-92d66428b774",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1940,
156.7963650826494
],
"parameters": {
"color": 7,
"width": 591.09953935829,
"height": 485.0226378812345,
"content": "## Step 3. Loop through Templates\n\nWe'll ask the LLM to help us generate 3 types of notes from the imported source document. These notes are intended to breakdown the content for faster study. Our templates for this demo are:\n(1) **Study guide**\n(2) **Briefing document**\n(3) **Timeline**"
},
"typeVersion": 1
},
{
"id": "b96f899d-4a44-491c-b164-a42feba129eb",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
2560,
480
],
"parameters": {
"color": 7,
"width": 1500.7886103732135,
"height": 806.6560661824452,
"content": "## Step 4. Use AI Agents to Query and Generate Template Documents\n[Read more about using the Question & Answer Retrieval Chain](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainretrievalqa)\n\nn8n allows us to easily use a chain of LLMs as agents which can work together to handle any task!\nHere the agents generate questions to explore the content of the source document and use the answers to generate the template. "
},
"typeVersion": 1
},
{
"id": "77fda269-6877-422f-b6e6-4346bde862db",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2560,
67.64523011966037
],
"parameters": {
"color": 7,
"width": 771.8710855215123,
"height": 384.22073222791266,
"content": "## Step 5. Export Generated Templates To Folder\n[Learn more about writing to the local filesystem](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.filesreadwrite)\n\nFinally, the AI generated documents can now be exported to disk. This workflow makes it easy to generate any kind of document from various source material and can be used for training and sales."
},
"typeVersion": 1
},
{
"id": "08839972-f0f4-4144-bf27-810664cbf828",
"name": "Qdrant Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
1200,
560
],
"parameters": {
"mode": "insert",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "storynotes",
"cachedResultName": "storynotes"
}
},
"credentials": {
"qdrantApi": {
"id": "NyinAS3Pgfik66w5",
"name": "QdrantApi account"
}
},
"typeVersion": 1
},
{
"id": "7e216411-83ee-4b82-9e00-285d4f2d3224",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
80
],
"parameters": {
"width": 390.63004227317265,
"height": 401.0080676370763,
"content": "## Try It Out! \n\n### This workflow automates generating notes from a source document.\n* It watches a target folder to pick up new files.\n* When a new file is detected, it saves the contents of the file in a vectorstore.\n* multiple AI agents guided by a templates list, generate the predetermined notes.\n* These notes are then export alongside the original source file for the user.\n\n\n### Need Help?\nJoin the [Discord](https://discord.com/invite/XPKeKXeB7d) or ask in the [Forum](https://community.n8n.io/)!\n\nHappy Hacking!"
},
"typeVersion": 1
},
{
"id": "f2c363d3-a2bf-4468-ad54-f26649ce6ab8",
"name": "Interview",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
2660,
680
],
"parameters": {
"text": "=## document summary\n {{ $('Prep For AI').item.json.summary }}",
"messages": {
"messageValues": [
{
"message": "=Given the following document summary, what questions would you ask to create a {{ $('For Each Doc Type...').item.json.title }} for the document? Generate 5 questions."
}
]
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.4
},
{
"id": "ce3da55d-8c22-40bb-8781-63c2e6bcb824",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1960,
380
],
"parameters": {
"width": 172.26820279743384,
"height": 295.46359440513226,
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### 💡Add your own templates here!\n"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"2secs": {
"main": [
[
{
"node": "For Each Doc Type...",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Prep For AI",
"type": "main",
"index": 0
}
]
]
},
"Discover": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Generate": {
"main": [
[
{
"node": "2secs",
"type": "main",
"index": 0
}
]
]
},
"Settings": {
"main": [
[
{
"node": "Import File",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Generate",
"type": "main",
"index": 0
}
]
]
},
"Interview": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Discover",
"type": "main",
"index": 0
}
]
]
},
"To Binary": {
"main": [
[
{
"node": "Export to Folder",
"type": "main",
"index": 0
}
]
]
},
"Import File": {
"main": [
[
{
"node": "Get FileType",
"type": "main",
"index": 0
}
]
]
},
"Prep For AI": {
"main": [
[
{
"node": "Get Doc Types",
"type": "main",
"index": 0
}
]
]
},
"Get FileType": {
"main": [
[
{
"node": "Extract from PDF",
"type": "main",
"index": 0
}
],
[
{
"node": "Extract from DOCX",
"type": "main",
"index": 0
}
],
[
{
"node": "Extract from TEXT",
"type": "main",
"index": 0