-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathRecipe Recommendations with Qdrant and Mistral.json
More file actions
973 lines (973 loc) · 21.7 KB
/
Copy pathRecipe Recommendations with Qdrant and Mistral.json
File metadata and controls
973 lines (973 loc) · 21.7 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
{
"meta": {
"instanceId": "26ba763460b97c249b82942b23b6384876dfeb9327513332e743c5f6219c2b8e"
},
"nodes": [
{
"id": "1eb82902-a1d6-4eff-82a2-26908a82cea2",
"name": "When clicking \"Test workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"position": [
720,
320
],
"parameters": {},
"typeVersion": 1
},
{
"id": "e0031fc3-27f1-45d9-910b-4c07dd322115",
"name": "Get This Week's Menu",
"type": "n8n-nodes-base.httpRequest",
"position": [
992,
370
],
"parameters": {
"url": "=https://www.hellofresh.co.uk/menus/{{ $now.year }}-W{{ $now.weekNumber }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "2c556cc7-7d4e-4d80-902f-9686e756ed8c",
"name": "Extract Available Courses",
"type": "n8n-nodes-base.code",
"position": [
992,
650
],
"parameters": {
"jsCode": "const pageData = JSON.parse($input.first().json.data)\nreturn pageData.props.pageProps.ssrPayload.courses.slice(0, 10);"
},
"typeVersion": 2
},
{
"id": "90c39db6-6116-4c37-8d48-a6d5e8f8c777",
"name": "Extract Server Data",
"type": "n8n-nodes-base.html",
"position": [
992,
510
],
"parameters": {
"options": {
"trimValues": false,
"cleanUpText": true
},
"operation": "extractHtmlContent",
"extractionValues": {
"values": [
{
"key": "data",
"cssSelector": "script#__NEXT_DATA__"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "fbd4ed97-0154-4991-bf16-d9c4cb3f4776",
"name": "Get Course Metadata",
"type": "n8n-nodes-base.set",
"position": [
1172,
370
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "3c90fd1e-e9ac-49c1-a459-7cff8c87fe8d",
"name": "name",
"type": "string",
"value": "={{ $json.recipe.name }}"
},
{
"id": "c4f3a5df-346c-4e8d-90ba-a49ed6afdedf",
"name": "cuisines",
"type": "array",
"value": "={{ $json.recipe.cuisines.map(item => item.name) }}"
},
{
"id": "97917928-0956-497b-bb68-507df1783240",
"name": "category",
"type": "string",
"value": "={{ $json.recipe.category.name }}"
},
{
"id": "1e84cf1e-7ad7-4888-9606-d3f7a310ce5f",
"name": "tags",
"type": "array",
"value": "={{ $json.recipe.tags.flatMap(tag => tag.preferences) }}"
},
{
"id": "cf6e2174-e8cb-4935-8303-2f8ed067f510",
"name": "nutrition",
"type": "object",
"value": "={{ $json.recipe.nutrition.reduce((acc,item) => ({ ...acc, [item.name]: item.amount + item.unit }), {}) }}"
},
{
"id": "25ba3fe6-c2fa-4315-a2cb-112ec7e3620f",
"name": "url",
"type": "string",
"value": "={{ $json.recipe.websiteUrl }}"
},
{
"id": "8f444fb3-c2ee-4254-b505-440cca3c7b8b",
"name": "id",
"type": "string",
"value": "={{ $json.recipe.id }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "5ab1a5fa-adc3-41e0-be6d-f680af301aca",
"name": "Get Recipe",
"type": "n8n-nodes-base.httpRequest",
"position": [
1172,
510
],
"parameters": {
"url": "={{ $json.recipe.websiteUrl }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "5014dc62-8320-4968-b9bd-396a517a2b5c",
"name": "Embeddings Mistral Cloud",
"type": "@n8n/n8n-nodes-langchain.embeddingsMistralCloud",
"position": [
1960,
420
],
"parameters": {
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "2a8fad89-f74b-4808-8cb6-97c6b46a53ee",
"name": "Default Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
2080,
420
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "week",
"value": "={{ $json.week }}"
},
{
"name": "cuisine",
"value": "={{ $json.cuisines }}"
},
{
"name": "category",
"value": "={{ $json.category }}"
},
{
"name": "tag",
"value": "={{ $json.tags }}"
},
{
"name": "recipe_id",
"value": "={{ $json.id }}"
}
]
}
},
"jsonData": "={{ $json.data }}",
"jsonMode": "expressionData"
},
"typeVersion": 1
},
{
"id": "44ceef5c-1d08-40d2-8ab4-227b551f72f5",
"name": "Merge Course & Recipe",
"type": "n8n-nodes-base.merge",
"position": [
1480,
500
],
"parameters": {
"mode": "combine",
"options": {},
"combinationMode": "mergeByPosition"
},
"typeVersion": 2.1
},
{
"id": "b56bd85e-f182-49d1-aeb1-062e905c316a",
"name": "Prepare Documents",
"type": "n8n-nodes-base.set",
"position": [
1660,
500
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "462567fe-02ec-4747-ae33-407d2bc6d776",
"name": "data",
"type": "string",
"value": "=# {{ $json.name }}\n{{ $json.description.replaceAll('\\n\\n','\\n') }}\n\n# Website\n{{ $json.url }}\n\n## Ingredients\n{{ $json.ingredients.replaceAll('\\n\\n','\\n') }}\n\n## Utensils\n{{ $json.utensils }}\n\n## Nutrition\n{{ Object.keys($json.nutrition).map(key => `* ${key}: ${$json.nutrition[key]}`).join('\\n') }}\n\n## Instructions\n{{ $json.instructions.replaceAll('\\n\\n','\\n') }}"
},
{
"id": "5738e420-abfe-4a85-b7ad-541cfc181563",
"name": "cuisine",
"type": "array",
"value": "={{ $json.cuisines }}"
},
{
"id": "349f46d4-e230-4da8-a118-50227ceb7233",
"name": "category",
"type": "string",
"value": "={{ $json.category }}"
},
{
"id": "9588b347-4469-4aa5-93a2-e7bf41b4c468",
"name": "tag",
"type": "array",
"value": "={{ $json.tags }}"
},
{
"id": "7ddab229-fa52-4d27-84e1-83ed47280d29",
"name": "week",
"type": "string",
"value": "={{ $now.year }}-W{{ $now.weekNumber }}"
},
{
"id": "13163e45-5699-4d25-af3d-4c7910dd2926",
"name": "id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "a0c5d599-ff2b-420d-9173-2baf9218abc5",
"name": "name",
"type": "string",
"value": "={{ $json.name }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "6b800632-f320-4fc3-bd2a-6a062834343d",
"name": "Recursive Character Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
2080,
560
],
"parameters": {
"options": {}
},
"typeVersion": 1
},
{
"id": "df7f17a2-8b27-4203-a2ff-091aaf6609b8",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
2440,
360
],
"webhookId": "745056ec-2d36-4ac3-9c70-6ff0b1055d0a",
"parameters": {},
"typeVersion": 1
},
{
"id": "ee38effe-5929-421e-a3c5-b1055a755242",
"name": "Extract Recipe Details",
"type": "n8n-nodes-base.html",
"position": [
1172,
650
],
"parameters": {
"options": {},
"operation": "extractHtmlContent",
"extractionValues": {
"values": [
{
"key": "description",
"cssSelector": "[data-test-id=\"recipe-description\"]"
},
{
"key": "ingredients",
"cssSelector": "[data-test-id=\"ingredients-list\"]"
},
{
"key": "utensils",
"cssSelector": "[data-test-id=\"utensils\"]"
},
{
"key": "instructions",
"cssSelector": "[data-test-id=\"instructions\"]",
"skipSelectors": "img,a"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "dede108f-2fde-49cb-8a0e-fa5786c59d4b",
"name": "Qdrant Recommend API",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
2840,
540
],
"parameters": {
"name": "get_recipe_recommendation",
"fields": {
"values": [
{
"name": "week",
"stringValue": "={{ $now.year }}-W{{ $now.weekNumber }}"
}
]
},
"schemaType": "manual",
"workflowId": "={{ $workflow.id }}",
"description": "Call this tool to get a recipe recommendation. Pass in the following params as a json object:\n* positives - a description of what the user wants to cook. This could be ingredients, flavours, utensils available, number of diners, type of meal etc.\n* negatives - a description of what the user wants to avoid in the recipe. This could be flavours to avoid, allergen considerations, conflicts with theme of meal etc.",
"inputSchema": "{\n\"type\": \"object\",\n\"properties\": {\n\t\"positive\": {\n\t\t\"type\": \"string\",\n\t\t\"description\": \"a description of what the user wants to cook. This could be ingredients, flavours, utensils available, number of diners, type of meal etc.\"\n\t},\n \"negative\": {\n \"type\": \"string\",\n \"description\": \"a description of what the user wants to avoid in the recipe. This could be flavours to avoid, allergen considerations, conflicts with theme of meal etc.\"\n }\n}\n}",
"specifyInputSchema": true
},
"typeVersion": 1.1
},
{
"id": "5e703134-4dd9-464b-9ec9-dc6103907a1e",
"name": "Execute Workflow Trigger",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
2420,
940
],
"parameters": {},
"typeVersion": 1
},
{
"id": "9fb5f4fd-3b38-4a35-8986-d3955754c8d1",
"name": "Mistral Cloud Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
"position": [
2660,
540
],
"parameters": {
"model": "mistral-large-2402",
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 1
},
{
"id": "d38275e6-aede-4f1c-9b05-018f3cf4faab",
"name": "Get Tool Response",
"type": "n8n-nodes-base.set",
"position": [
3160,
940
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "10b55200-4610-4e9b-8be7-d487c6b56a78",
"name": "response",
"type": "string",
"value": "={{ JSON.stringify($json.result) }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "dc3ceb2f-3c64-4b42-aeca-ddcdb84abf12",
"name": "Wait for Rate Limits",
"type": "n8n-nodes-base.wait",
"position": [
2420,
1080
],
"webhookId": "e86d8ae4-3b0d-4c40-9d12-a11d6501a043",
"parameters": {
"amount": 1.1
},
"typeVersion": 1.1
},
{
"id": "ec36d6f8-c3da-4732-8d56-a092a3358864",
"name": "Get Mistral Embeddings",
"type": "n8n-nodes-base.httpRequest",
"position": [
2620,
940
],
"parameters": {
"url": "https://api.mistral.ai/v1/embeddings",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "mistral-embed"
},
{
"name": "encoding_format",
"value": "float"
},
{
"name": "input",
"value": "={{ [$json.query.positive, $json.query.negative].compact() }}"
}
]
},
"nodeCredentialType": "mistralCloudApi"
},
"credentials": {
"mistralCloudApi": {
"id": "EIl2QxhXAS9Hkg37",
"name": "Mistral Cloud account"
}
},
"typeVersion": 4.2
},
{
"id": "aebcb860-d25c-4833-9e9d-0297101259c7",
"name": "Use Qdrant Recommend API",
"type": "n8n-nodes-base.httpRequest",
"position": [
2800,
940
],
"parameters": {
"url": "=http://qdrant:6333/collections/hello_fresh/points/recommend/groups",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "strategy",
"value": "average_vector"
},
{
"name": "limit",
"value": "={{ 3 }}"
},
{
"name": "positive",
"value": "={{ [$json.data[0].embedding] }}"
},
{
"name": "negative",
"value": "={{ [$json.data[1].embedding] }}"
},
{
"name": "filter",
"value": "={{ { \"must\": {\"key\": \"metadata.week\", \"match\": { \"value\": $('Execute Workflow Trigger').item.json.week } } } }}"
},
{
"name": "with_payload",
"value": "={{ true }}"
},
{
"name": "group_by",
"value": "metadata.recipe_id"
},
{
"name": "group_size",
"value": "={{ 3 }}"
}
]
},
"nodeCredentialType": "qdrantApi"
},
"credentials": {
"qdrantApi": {
"id": "NyinAS3Pgfik66w5",
"name": "QdrantApi account"
}
},
"typeVersion": 4.2
},
{
"id": "2474c97d-0d85-4acc-a95e-2eb6494786dc",
"name": "Get Recipes From DB",
"type": "n8n-nodes-base.code",
"position": [
2980,
940
],
"parameters": {
"language": "python",
"pythonCode": "import sqlite3\ncon = sqlite3.connect(\"hello_fresh_1.db\")\n\nrecipe_ids = list(set([group.id for group in _input.all()[0].json.result.groups if group.hits[0].score > 0.5]))\nplaceholders = ','.join(['?' for i in range(0,len(recipe_ids))])\n\ncur = con.cursor()\nres = cur.execute(f'SELECT * FROM recipes WHERE id IN ({placeholders})', recipe_ids)\nrows = res.fetchall()\n\ncon.close()\n\nreturn [{ \"result\": [row[2] for row in rows] }]"
},
"typeVersion": 2
},
{
"id": "54229c2a-6e26-4350-8a94-57f415ef2340",
"name": "Save Recipes to DB",
"type": "n8n-nodes-base.code",
"position": [
1960,
940
],
"parameters": {
"language": "python",
"pythonCode": "import sqlite3\ncon = sqlite3.connect(\"hello_fresh_1.db\")\n\ncur = con.cursor()\ncur.execute(\"CREATE TABLE IF NOT EXISTS recipes (id TEXT PRIMARY KEY, name TEXT, data TEXT, cuisine TEXT, category TEXT, tag TEXT, week TEXT);\")\n\nfor item in _input.all():\n cur.execute('INSERT OR REPLACE INTO recipes VALUES(?,?,?,?,?,?,?)', (\n item.json.id,\n item.json.name,\n item.json.data,\n ','.join(item.json.cuisine),\n item.json.category,\n ','.join(item.json.tag),\n item.json.week\n ))\n\ncon.commit()\ncon.close()\n\nreturn [{ \"affected_rows\": len(_input.all()) }]"
},
"typeVersion": 2
},
{
"id": "725c1f56-5373-4891-92b9-3f32dd28892b",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
901.1666225087287,
180.99920515712074
],
"parameters": {
"color": 7,
"width": 484.12381677448207,
"height": 674.1153489831718,
"content": "## Step 1. Fetch Available Courses For the Current Week\n\nTo populate our vectorstore, we'll scrape the weekly menu off the HelloFresh Website. The pages are quite large so may take a while so please be patient."
},
"typeVersion": 1
},
{
"id": "f4e882b8-3762-4e6b-9e95-b0d708d0c284",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1420,
300
],
"parameters": {
"color": 7,
"width": 409.1756468632768,
"height": 398.81415970574335,
"content": "## Step 2. Create Recipe Documents For VectorStore\n\nTo populate our vectorstore, we'll scrape the weekly menu off the HelloFresh Website. The pages are quite large so may take a while so please be patient."
},
"typeVersion": 1
},
{
"id": "fc3c2221-b67c-451c-9096-d6acd2a297fa",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1860,
19.326425127730317
],
"parameters": {
"color": 7,
"width": 486.02284096214964,
"height": 690.7816167755491,
"content": "## Step 3. Vectorise Recipes For Recommendation Engine\n[Read more about Qdrant node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreqdrant)\n\nWe'll store our documents in our Qdrant vectorstore by converting to vectors using Mistral Embed. Our goal is to a build a recommendation engine for meals of the week which Qdrant is a perfect solution."
},
"typeVersion": 1
},
{
"id": "43296173-b929-46cc-b6ea-58007837b8df",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1740,
740
],
"parameters": {
"color": 7,
"width": 547.0098868353456,
"height": 347.6002738958705,
"content": "## Step 4. Save Original Document to Database\n[Read more about Code Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code)\n\nFinally, let's have the original document stored in a more traditional datastore. USually our vectorsearch will return partial docs and those are enough for many use-cases, however in this instance we'll pull the full docs for the Agent get the info required to make the recommendation. "
},
"typeVersion": 1
},
{
"id": "6e2e58d2-e0ad-4503-8ed6-891124c8035b",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2380,
160
],
"parameters": {
"color": 7,
"width": 673.6008766895472,
"height": 552.9202706743265,
"content": "## 5. Chat with Our HelloFresh Recommendation AI Agent\n[Read more about AI Agents](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent)\n\nThis agent is designed to recommend HelloFresh recipes based on your current taste preferences. Need something hot and spicy, warm and comforting or fast and chilled? This agent will capture what you would like and not like and queries our Recipe Recommendation engine powered by Qdrant Vectorstore."
},
"typeVersion": 1
},
{
"id": "ba692c21-38bc-48a1-8b40-bad298be8b9e",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
2660,
360
],
"parameters": {
"options": {
"systemMessage": "=You are a recipe bot for the company, \"Hello fresh\". You will help the user choose which Hello Fresh recipe to choose from this week's menu. The current week is {{ $now.year }}-W{{ $now.weekNumber }}.\nDo not recommend any recipes other from the current week's menu. If there are no recipes to recommend, please ask the user to visit the website instead https://hellofresh.com."
}
},
"typeVersion": 1.6
},
{
"id": "d7ca0f97-72dc-4f4c-8b46-3ff57b9068a4",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2320,
740
],
"parameters": {
"color": 7,
"width": 987.4785537889618,
"height": 531.9173034334732,
"content": "## 5. Using Qdrant's Recommend API & Grouping Functionality\n[Read more about Qdrant's Recommend API](https://qdrant.tech/documentation/concepts/explore/?q=recommend)\n\nUnlike basic similarity search, Qdrant's Recommend API takes a positive query to match against (eg. Roast Dinner) and a negative query to avoid (eg. Roast Chicken). This feature significantly improves results for a recommendation engine. Additionally, by utilising Qdrant's Grouping feature, we're able to group similar matches from the same recipe - meaning we can ensure unique recipes everytime."
},
"typeVersion": 1
},
{
"id": "96a294e2-1437-4ded-9973-0999b444c999",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
440,
-40
],
"parameters": {
"width": 432.916474478624,
"height": 542.9295980774649,
"content": "## Try it out!\n### This workflow does the following:\n* Fetches and stores this week's HelloFresh's menu\n* Builds the foundation of a recommendation engine by storing the recipes in a Qdrant Vectorstore and SQLite database.\n* Builds an AI Agent that allows for a chat interface to query for a the week's recipe recommendations.\n* AI agent uses the Qdrant Recommend API, providing what the user likes/dislikes as the query.\n* Qdrant returns the results which enable the AI Agent to make the recommendation to the user.\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": "72c98600-f21a-42d4-97be-836b8ef6dc77",
"name": "Qdrant Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
1960,
240
],
"parameters": {
"mode": "insert",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "hello_fresh",
"cachedResultName": "hello_fresh"
}
},
"credentials": {
"qdrantApi": {
"id": "NyinAS3Pgfik66w5",
"name": "QdrantApi account"
}
},
"typeVersion": 1
},
{
"id": "b7c4b597-ac2b-41d7-8f0f-1cbba25085de",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
1860,
-195.8987124522777
],
"parameters": {
"width": 382.47301504497716,
"height": 195.8987124522777,
"content": "### 🚨Ensure Qdrant collection exists!\nYou'll need to run the following command in Qdrant:\n```\nPUT collections/hello_fresh\n{\n \"vectors\": {\n \"distance\": \"Cosine\",\n \"size\": 1024\n }\n}\n```"
},
"typeVersion": 1
},
{
"id": "39191834-ecc2-46f0-a31a-0a7e9c47ac5d",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
2740,
920
],
"parameters": {
"width": 213.30551928619226,
"height": 332.38559808882246,
"content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### 🚨Configure Your Qdrant Connection\n* Be sure to enter your endpoint address"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Get Recipe": {
"main": [
[
{
"node": "Extract Recipe Details",
"type": "main",
"index": 0
}
]
]
},
"Chat Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Prepare Documents": {
"main": [
[
{
"node": "Qdrant Vector Store",
"type": "main",
"index": 0
},
{
"node": "Save Recipes to DB",
"type": "main",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Extract Server Data": {
"main": [
[
{
"node": "Extract Available Courses",
"type": "main",
"index": 0
}
]
]
},
"Get Course Metadata": {
"main": [
[
{
"node": "Merge Course & Recipe",
"type": "main",
"index": 0
}
]
]
},
"Get Recipes From DB": {
"main": [
[
{
"node": "Get Tool Response",
"type": "main",
"index": 0
}
]
]
},
"Get This Week's Menu": {
"main": [
[
{
"node": "Extract Server Data",
"type": "main",
"index": 0
}
]
]
},
"Qdrant Recommend API": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Wait for Rate Limits": {
"main": [
[
{
"node": "Get Mistral Embeddings",
"type": "main",
"index": 0
}
]
]
},
"Merge Course & Recipe": {
"main": [
[
{
"node": "Prepare Documents",
"type": "main",
"index": 0
}
]
]
},
"Extract Recipe Details": {
"main": [
[
{
"node": "Merge Course & Recipe",
"type": "main",
"index": 1
}
]
]
},
"Get Mistral Embeddings": {
"main": [
[
{
"node": "Use Qdrant Recommend API",
"type": "main",
"index": 0
}
]
]
},
"Embeddings Mistral Cloud": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Execute Workflow Trigger": {
"main": [
[
{
"node": "Wait for Rate Limits",
"type": "main",
"index": 0
}
]
]
},
"Mistral Cloud Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Use Qdrant Recommend API": {
"main": [
[
{
"node": "Get Recipes From DB",
"type": "main",
"index": 0
}
]
]
},
"Extract Available Courses": {
"main": [
[
{
"node": "Get Course Metadata",
"type": "main",
"index": 0
},
{
"node": "Get Recipe",
"type": "main",
"index": 0
}
]
]
},
"When clicking \"Test workflow\"": {
"main": [
[
{
"node": "Get This Week's Menu",
"type": "main",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
}
}
}sRecipe Recommendations with Qdrant and Mistral