-
Notifications
You must be signed in to change notification settings - Fork 0
/
flows.json
3102 lines (3102 loc) · 195 KB
/
flows.json
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
{
"id": "0bb2954d-f5fa-4657-9626-984e07a72b92",
"data": {
"nodes": [
{
"data": {
"description": "Implementation of Vector Store using Astra DB with search capabilities",
"display_name": "Astra DB",
"edited": false,
"id": "AstraVectorStoreComponent-U5Qfw",
"node": {
"template": {
"_type": "Component",
"embedding": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "embedding",
"value": "",
"display_name": "Embedding or Astra Vectorize",
"advanced": false,
"input_types": [
"Embeddings",
"dict"
],
"dynamic": false,
"info": "Allows either an embedding model or an Astra Vectorize configuration.",
"title_case": false,
"type": "other",
"_input_type": "HandleInput"
},
"ingest_data": {
"trace_as_metadata": true,
"list": true,
"trace_as_input": true,
"required": false,
"placeholder": "",
"show": true,
"name": "ingest_data",
"value": "",
"display_name": "Ingest Data",
"advanced": false,
"input_types": [
"Data"
],
"dynamic": false,
"info": "",
"title_case": false,
"type": "other",
"_input_type": "DataInput"
},
"api_endpoint": {
"load_from_db": false,
"required": true,
"placeholder": "",
"show": true,
"name": "api_endpoint",
"value": "",
"display_name": "API Endpoint",
"advanced": false,
"input_types": [
"Message"
],
"dynamic": false,
"info": "API endpoint URL for the Astra DB service.",
"title_case": false,
"password": true,
"type": "str",
"_input_type": "SecretStrInput"
},
"batch_size": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "batch_size",
"value": "",
"display_name": "Batch Size",
"advanced": true,
"dynamic": false,
"info": "Optional number of data to process in a single batch.",
"title_case": false,
"type": "int",
"_input_type": "IntInput"
},
"bulk_delete_concurrency": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "bulk_delete_concurrency",
"value": "",
"display_name": "Bulk Delete Concurrency",
"advanced": true,
"dynamic": false,
"info": "Optional concurrency level for bulk delete operations.",
"title_case": false,
"type": "int",
"_input_type": "IntInput"
},
"bulk_insert_batch_concurrency": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "bulk_insert_batch_concurrency",
"value": "",
"display_name": "Bulk Insert Batch Concurrency",
"advanced": true,
"dynamic": false,
"info": "Optional concurrency level for bulk insert operations.",
"title_case": false,
"type": "int",
"_input_type": "IntInput"
},
"bulk_insert_overwrite_concurrency": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "bulk_insert_overwrite_concurrency",
"value": "",
"display_name": "Bulk Insert Overwrite Concurrency",
"advanced": true,
"dynamic": false,
"info": "Optional concurrency level for bulk insert operations that overwrite existing data.",
"title_case": false,
"type": "int",
"_input_type": "IntInput"
},
"code": {
"type": "code",
"required": true,
"placeholder": "",
"list": false,
"show": true,
"multiline": true,
"value": "from loguru import logger\n\nfrom langflow.base.vectorstores.model import LCVectorStoreComponent, check_cached_vector_store\nfrom langflow.helpers import docs_to_data\nfrom langflow.inputs import DictInput, FloatInput\nfrom langflow.io import (\n BoolInput,\n DataInput,\n DropdownInput,\n HandleInput,\n IntInput,\n MultilineInput,\n SecretStrInput,\n StrInput,\n)\nfrom langflow.schema import Data\n\n\nclass AstraVectorStoreComponent(LCVectorStoreComponent):\n display_name: str = \"Astra DB\"\n description: str = \"Implementation of Vector Store using Astra DB with search capabilities\"\n documentation: str = \"https://python.langchain.com/docs/integrations/vectorstores/astradb\"\n name = \"AstraDB\"\n icon: str = \"AstraDB\"\n\n inputs = [\n StrInput(\n name=\"collection_name\",\n display_name=\"Collection Name\",\n info=\"The name of the collection within Astra DB where the vectors will be stored.\",\n required=True,\n ),\n SecretStrInput(\n name=\"token\",\n display_name=\"Astra DB Application Token\",\n info=\"Authentication token for accessing Astra DB.\",\n value=\"ASTRA_DB_APPLICATION_TOKEN\",\n required=True,\n ),\n SecretStrInput(\n name=\"api_endpoint\",\n display_name=\"API Endpoint\",\n info=\"API endpoint URL for the Astra DB service.\",\n value=\"ASTRA_DB_API_ENDPOINT\",\n required=True,\n ),\n MultilineInput(\n name=\"search_input\",\n display_name=\"Search Input\",\n ),\n DataInput(\n name=\"ingest_data\",\n display_name=\"Ingest Data\",\n is_list=True,\n ),\n StrInput(\n name=\"namespace\",\n display_name=\"Namespace\",\n info=\"Optional namespace within Astra DB to use for the collection.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"metric\",\n display_name=\"Metric\",\n info=\"Optional distance metric for vector comparisons in the vector store.\",\n options=[\"cosine\", \"dot_product\", \"euclidean\"],\n advanced=True,\n ),\n IntInput(\n name=\"batch_size\",\n display_name=\"Batch Size\",\n info=\"Optional number of data to process in a single batch.\",\n advanced=True,\n ),\n IntInput(\n name=\"bulk_insert_batch_concurrency\",\n display_name=\"Bulk Insert Batch Concurrency\",\n info=\"Optional concurrency level for bulk insert operations.\",\n advanced=True,\n ),\n IntInput(\n name=\"bulk_insert_overwrite_concurrency\",\n display_name=\"Bulk Insert Overwrite Concurrency\",\n info=\"Optional concurrency level for bulk insert operations that overwrite existing data.\",\n advanced=True,\n ),\n IntInput(\n name=\"bulk_delete_concurrency\",\n display_name=\"Bulk Delete Concurrency\",\n info=\"Optional concurrency level for bulk delete operations.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"setup_mode\",\n display_name=\"Setup Mode\",\n info=\"Configuration mode for setting up the vector store, with options like 'Sync', 'Async', or 'Off'.\",\n options=[\"Sync\", \"Async\", \"Off\"],\n advanced=True,\n value=\"Sync\",\n ),\n BoolInput(\n name=\"pre_delete_collection\",\n display_name=\"Pre Delete Collection\",\n info=\"Boolean flag to determine whether to delete the collection before creating a new one.\",\n advanced=True,\n ),\n StrInput(\n name=\"metadata_indexing_include\",\n display_name=\"Metadata Indexing Include\",\n info=\"Optional list of metadata fields to include in the indexing.\",\n advanced=True,\n ),\n HandleInput(\n name=\"embedding\",\n display_name=\"Embedding or Astra Vectorize\",\n input_types=[\"Embeddings\", \"dict\"],\n info=\"Allows either an embedding model or an Astra Vectorize configuration.\", # TODO: This should be optional, but need to refactor langchain-astradb first.\n ),\n StrInput(\n name=\"metadata_indexing_exclude\",\n display_name=\"Metadata Indexing Exclude\",\n info=\"Optional list of metadata fields to exclude from the indexing.\",\n advanced=True,\n ),\n StrInput(\n name=\"collection_indexing_policy\",\n display_name=\"Collection Indexing Policy\",\n info=\"Optional dictionary defining the indexing policy for the collection.\",\n advanced=True,\n ),\n IntInput(\n name=\"number_of_results\",\n display_name=\"Number of Results\",\n info=\"Number of results to return.\",\n advanced=True,\n value=4,\n ),\n DropdownInput(\n name=\"search_type\",\n display_name=\"Search Type\",\n info=\"Search type to use\",\n options=[\"Similarity\", \"Similarity with score threshold\", \"MMR (Max Marginal Relevance)\"],\n value=\"Similarity\",\n advanced=True,\n ),\n FloatInput(\n name=\"search_score_threshold\",\n display_name=\"Search Score Threshold\",\n info=\"Minimum similarity score threshold for search results. (when using 'Similarity with score threshold')\",\n value=0,\n advanced=True,\n ),\n DictInput(\n name=\"search_filter\",\n display_name=\"Search Metadata Filter\",\n info=\"Optional dictionary of filters to apply to the search query.\",\n advanced=True,\n is_list=True,\n ),\n ]\n\n @check_cached_vector_store\n def build_vector_store(self):\n try:\n from langchain_astradb import AstraDBVectorStore\n from langchain_astradb.utils.astradb import SetupMode\n except ImportError:\n raise ImportError(\n \"Could not import langchain Astra DB integration package. \"\n \"Please install it with `pip install langchain-astradb`.\"\n )\n\n try:\n if not self.setup_mode:\n self.setup_mode = self._inputs[\"setup_mode\"].options[0]\n\n setup_mode_value = SetupMode[self.setup_mode.upper()]\n except KeyError:\n raise ValueError(f\"Invalid setup mode: {self.setup_mode}\")\n\n if not isinstance(self.embedding, dict):\n embedding_dict = {\"embedding\": self.embedding}\n else:\n from astrapy.info import CollectionVectorServiceOptions\n\n dict_options = self.embedding.get(\"collection_vector_service_options\", {})\n dict_options[\"authentication\"] = {\n k: v for k, v in dict_options.get(\"authentication\", {}).items() if k and v\n }\n dict_options[\"parameters\"] = {k: v for k, v in dict_options.get(\"parameters\", {}).items() if k and v}\n embedding_dict = {\n \"collection_vector_service_options\": CollectionVectorServiceOptions.from_dict(dict_options)\n }\n collection_embedding_api_key = self.embedding.get(\"collection_embedding_api_key\")\n if collection_embedding_api_key:\n embedding_dict[\"collection_embedding_api_key\"] = collection_embedding_api_key\n\n vector_store_kwargs = {\n **embedding_dict,\n \"collection_name\": self.collection_name,\n \"token\": self.token,\n \"api_endpoint\": self.api_endpoint,\n \"namespace\": self.namespace or None,\n \"metric\": self.metric or None,\n \"batch_size\": self.batch_size or None,\n \"bulk_insert_batch_concurrency\": self.bulk_insert_batch_concurrency or None,\n \"bulk_insert_overwrite_concurrency\": self.bulk_insert_overwrite_concurrency or None,\n \"bulk_delete_concurrency\": self.bulk_delete_concurrency or None,\n \"setup_mode\": setup_mode_value,\n \"pre_delete_collection\": self.pre_delete_collection or False,\n }\n\n if self.metadata_indexing_include:\n vector_store_kwargs[\"metadata_indexing_include\"] = self.metadata_indexing_include\n elif self.metadata_indexing_exclude:\n vector_store_kwargs[\"metadata_indexing_exclude\"] = self.metadata_indexing_exclude\n elif self.collection_indexing_policy:\n vector_store_kwargs[\"collection_indexing_policy\"] = self.collection_indexing_policy\n\n try:\n vector_store = AstraDBVectorStore(**vector_store_kwargs)\n except Exception as e:\n raise ValueError(f\"Error initializing AstraDBVectorStore: {str(e)}\") from e\n\n self._add_documents_to_vector_store(vector_store)\n return vector_store\n\n def _add_documents_to_vector_store(self, vector_store):\n documents = []\n for _input in self.ingest_data or []:\n if isinstance(_input, Data):\n documents.append(_input.to_lc_document())\n else:\n raise ValueError(\"Vector Store Inputs must be Data objects.\")\n\n if documents:\n logger.debug(f\"Adding {len(documents)} documents to the Vector Store.\")\n try:\n vector_store.add_documents(documents)\n except Exception as e:\n raise ValueError(f\"Error adding documents to AstraDBVectorStore: {str(e)}\") from e\n else:\n logger.debug(\"No documents to add to the Vector Store.\")\n\n def _map_search_type(self):\n if self.search_type == \"Similarity with score threshold\":\n return \"similarity_score_threshold\"\n elif self.search_type == \"MMR (Max Marginal Relevance)\":\n return \"mmr\"\n else:\n return \"similarity\"\n\n def _build_search_args(self):\n args = {\n \"k\": self.number_of_results,\n \"score_threshold\": self.search_score_threshold,\n }\n\n if self.search_filter:\n clean_filter = {k: v for k, v in self.search_filter.items() if k and v}\n if len(clean_filter) > 0:\n args[\"filter\"] = clean_filter\n return args\n\n def search_documents(self) -> list[Data]:\n vector_store = self.build_vector_store()\n\n logger.debug(f\"Search input: {self.search_input}\")\n logger.debug(f\"Search type: {self.search_type}\")\n logger.debug(f\"Number of results: {self.number_of_results}\")\n\n if self.search_input and isinstance(self.search_input, str) and self.search_input.strip():\n try:\n search_type = self._map_search_type()\n search_args = self._build_search_args()\n\n docs = vector_store.search(query=self.search_input, search_type=search_type, **search_args)\n except Exception as e:\n raise ValueError(f\"Error performing search in AstraDBVectorStore: {str(e)}\") from e\n\n logger.debug(f\"Retrieved documents: {len(docs)}\")\n\n data = docs_to_data(docs)\n logger.debug(f\"Converted documents to data: {len(data)}\")\n self.status = data\n return data\n else:\n logger.debug(\"No search input provided. Skipping search.\")\n return []\n\n def get_retriever_kwargs(self):\n search_args = self._build_search_args()\n return {\n \"search_type\": self._map_search_type(),\n \"search_kwargs\": search_args,\n }\n",
"fileTypes": [],
"file_path": "",
"password": false,
"name": "code",
"advanced": true,
"dynamic": true,
"info": "",
"load_from_db": false,
"title_case": false
},
"collection_indexing_policy": {
"trace_as_metadata": true,
"load_from_db": false,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "collection_indexing_policy",
"value": "",
"display_name": "Collection Indexing Policy",
"advanced": true,
"dynamic": false,
"info": "Optional dictionary defining the indexing policy for the collection.",
"title_case": false,
"type": "str",
"_input_type": "StrInput"
},
"collection_name": {
"trace_as_metadata": true,
"load_from_db": false,
"list": false,
"required": true,
"placeholder": "",
"show": true,
"name": "collection_name",
"value": "diagnoses",
"display_name": "Collection Name",
"advanced": false,
"dynamic": false,
"info": "The name of the collection within Astra DB where the vectors will be stored.",
"title_case": false,
"type": "str",
"_input_type": "StrInput"
},
"metadata_indexing_exclude": {
"trace_as_metadata": true,
"load_from_db": false,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "metadata_indexing_exclude",
"value": "",
"display_name": "Metadata Indexing Exclude",
"advanced": true,
"dynamic": false,
"info": "Optional list of metadata fields to exclude from the indexing.",
"title_case": false,
"type": "str",
"_input_type": "StrInput"
},
"metadata_indexing_include": {
"trace_as_metadata": true,
"load_from_db": false,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "metadata_indexing_include",
"value": "",
"display_name": "Metadata Indexing Include",
"advanced": true,
"dynamic": false,
"info": "Optional list of metadata fields to include in the indexing.",
"title_case": false,
"type": "str",
"_input_type": "StrInput"
},
"metric": {
"trace_as_metadata": true,
"options": [
"cosine",
"dot_product",
"euclidean"
],
"combobox": false,
"required": false,
"placeholder": "",
"show": true,
"name": "metric",
"value": "cosine",
"display_name": "Metric",
"advanced": true,
"dynamic": false,
"info": "Optional distance metric for vector comparisons in the vector store.",
"title_case": false,
"type": "str",
"_input_type": "DropdownInput",
"load_from_db": false
},
"namespace": {
"trace_as_metadata": true,
"load_from_db": false,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "namespace",
"value": "",
"display_name": "Namespace",
"advanced": true,
"dynamic": false,
"info": "Optional namespace within Astra DB to use for the collection.",
"title_case": false,
"type": "str",
"_input_type": "StrInput"
},
"number_of_results": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "number_of_results",
"value": 10,
"display_name": "Number of Results",
"advanced": false,
"dynamic": false,
"info": "Number of results to return.",
"title_case": false,
"type": "int",
"_input_type": "IntInput",
"load_from_db": false
},
"pre_delete_collection": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "pre_delete_collection",
"value": false,
"display_name": "Pre Delete Collection",
"advanced": true,
"dynamic": false,
"info": "Boolean flag to determine whether to delete the collection before creating a new one.",
"title_case": false,
"type": "bool",
"_input_type": "BoolInput"
},
"search_filter": {
"trace_as_input": true,
"list": true,
"required": false,
"placeholder": "",
"show": true,
"name": "search_filter",
"value": {},
"display_name": "Search Metadata Filter",
"advanced": true,
"dynamic": false,
"info": "Optional dictionary of filters to apply to the search query.",
"title_case": false,
"type": "dict",
"_input_type": "DictInput"
},
"search_input": {
"trace_as_input": true,
"multiline": true,
"trace_as_metadata": true,
"load_from_db": false,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "search_input",
"value": "",
"display_name": "Search Input",
"advanced": false,
"input_types": [
"Message"
],
"dynamic": false,
"info": "",
"title_case": false,
"type": "str",
"_input_type": "MultilineInput"
},
"search_score_threshold": {
"trace_as_metadata": true,
"list": false,
"required": false,
"placeholder": "",
"show": true,
"name": "search_score_threshold",
"value": 0,
"display_name": "Search Score Threshold",
"advanced": true,
"dynamic": false,
"info": "Minimum similarity score threshold for search results. (when using 'Similarity with score threshold')",
"title_case": false,
"type": "float",
"_input_type": "FloatInput"
},
"search_type": {
"trace_as_metadata": true,
"options": [
"Similarity",
"Similarity with score threshold",
"MMR (Max Marginal Relevance)"
],
"combobox": false,
"required": false,
"placeholder": "",
"show": true,
"name": "search_type",
"value": "Similarity",
"display_name": "Search Type",
"advanced": true,
"dynamic": false,
"info": "Search type to use",
"title_case": false,
"type": "str",
"_input_type": "DropdownInput"
},
"setup_mode": {
"trace_as_metadata": true,
"options": [
"Sync",
"Async",
"Off"
],
"combobox": false,
"required": false,
"placeholder": "",
"show": true,
"name": "setup_mode",
"value": "Sync",
"display_name": "Setup Mode",
"advanced": true,
"dynamic": false,
"info": "Configuration mode for setting up the vector store, with options like 'Sync', 'Async', or 'Off'.",
"title_case": false,
"type": "str",
"_input_type": "DropdownInput"
},
"token": {
"load_from_db": true,
"required": true,
"placeholder": "",
"show": true,
"name": "token",
"value": "",
"display_name": "Astra DB Application Token",
"advanced": false,
"input_types": [
"Message"
],
"dynamic": false,
"info": "Authentication token for accessing Astra DB.",
"title_case": false,
"password": true,
"type": "str",
"_input_type": "SecretStrInput"
}
},
"description": "Implementation of Vector Store using Astra DB with search capabilities",
"icon": "AstraDB",
"base_classes": [
"Data",
"Retriever",
"VectorStore"
],
"display_name": "Astra DB",
"documentation": "https://python.langchain.com/docs/integrations/vectorstores/astradb",
"custom_fields": {},
"output_types": [],
"pinned": false,
"conditional_paths": [],
"frozen": false,
"outputs": [
{
"types": [
"Retriever"
],
"selected": "Retriever",
"name": "base_retriever",
"display_name": "Retriever",
"method": "build_base_retriever",
"value": "__UNDEFINED__",
"cache": true
},
{
"types": [
"Data"
],
"selected": "Data",
"name": "search_results",
"display_name": "Search Results",
"method": "search_documents",
"value": "__UNDEFINED__",
"cache": true
},
{
"types": [
"VectorStore"
],
"selected": "VectorStore",
"name": "vector_store",
"display_name": "Vector Store",
"method": "cast_vector_store",
"value": "__UNDEFINED__",
"cache": true
}
],
"field_order": [
"collection_name",
"token",
"api_endpoint",
"search_input",
"ingest_data",
"namespace",
"metric",
"batch_size",
"bulk_insert_batch_concurrency",
"bulk_insert_overwrite_concurrency",
"bulk_delete_concurrency",
"setup_mode",
"pre_delete_collection",
"metadata_indexing_include",
"embedding",
"metadata_indexing_exclude",
"collection_indexing_policy",
"number_of_results",
"search_type",
"search_score_threshold",
"search_filter"
],
"beta": false,
"edited": false,
"lf_version": "1.0.18"
},
"type": "AstraDB"
},
"dragging": false,
"height": 837,
"id": "AstraVectorStoreComponent-U5Qfw",
"position": {
"x": 429.5270955049191,
"y": -81.68609441173811
},
"positionAbsolute": {
"x": 429.5270955049191,
"y": -81.68609441173811
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"description": "Convert Data into plain text following a specified template.",
"display_name": "Parse Data",
"id": "ParseData-omIuO",
"node": {
"base_classes": [
"Message"
],
"beta": false,
"conditional_paths": [],
"custom_fields": {},
"description": "Convert Data into plain text following a specified template.",
"display_name": "Parse Data",
"documentation": "",
"edited": false,
"field_order": [
"data",
"template",
"sep"
],
"frozen": false,
"icon": "braces",
"output_types": [],
"outputs": [
{
"cache": true,
"display_name": "Text",
"method": "parse_data",
"name": "text",
"selected": "Message",
"types": [
"Message"
],
"value": "__UNDEFINED__"
}
],
"pinned": false,
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DataInput, MultilineInput, Output, StrInput\nfrom langflow.schema.message import Message\n\n\nclass ParseDataComponent(Component):\n display_name = \"Parse Data\"\n description = \"Convert Data into plain text following a specified template.\"\n icon = \"braces\"\n name = \"ParseData\"\n\n inputs = [\n DataInput(name=\"data\", display_name=\"Data\", info=\"The data to convert to text.\"),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. It can contain the keys {text}, {data} or any other key in the Data.\",\n value=\"{text}\",\n ),\n StrInput(name=\"sep\", display_name=\"Separator\", advanced=True, value=\"\\n\"),\n ]\n\n outputs = [\n Output(display_name=\"Text\", name=\"text\", method=\"parse_data\"),\n ]\n\n def parse_data(self) -> Message:\n data = self.data if isinstance(self.data, list) else [self.data]\n template = self.template\n\n result_string = data_to_text(template, data, sep=self.sep)\n self.status = result_string\n return Message(text=result_string)\n"
},
"data": {
"advanced": false,
"display_name": "Data",
"dynamic": false,
"info": "The data to convert to text.",
"input_types": [
"Data"
],
"list": false,
"name": "data",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "other",
"value": ""
},
"sep": {
"advanced": true,
"display_name": "Separator",
"dynamic": false,
"info": "",
"list": false,
"load_from_db": false,
"name": "sep",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": "\n"
},
"template": {
"advanced": false,
"display_name": "Template",
"dynamic": false,
"info": "The template to use for formatting the data. It can contain the keys {text}, {data} or any other key in the Data.",
"input_types": [
"Message"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": "{text}"
}
},
"lf_version": "1.0.18"
},
"type": "ParseData"
},
"dragging": false,
"height": 369,
"id": "ParseData-omIuO",
"position": {
"x": 1381.9891337583683,
"y": 273.17215285963124
},
"positionAbsolute": {
"x": 1381.9891337583683,
"y": 273.17215285963124
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"id": "Prompt-BoCHG",
"node": {
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.inputs.inputs import DefaultPromptField\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n name = \"Prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n )\n return frontend_node\n\n def post_code_processing(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"\n This function is called after the code validation is done.\n \"\"\"\n frontend_node = super().post_code_processing(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n"
},
"context": {
"field_type": "str",
"required": false,
"placeholder": "",
"list": false,
"show": true,
"multiline": true,
"value": "",
"fileTypes": [],
"file_path": "",
"name": "context",
"display_name": "context",
"advanced": false,
"input_types": [
"Message",
"Text"
],
"dynamic": false,
"info": "",
"load_from_db": false,
"title_case": false,
"type": "str"
},
"question": {
"field_type": "str",
"required": false,
"placeholder": "",
"list": false,
"show": true,
"multiline": true,
"value": "",
"fileTypes": [],
"file_path": "",
"name": "question",
"display_name": "question",
"advanced": false,
"input_types": [
"Message",
"Text"
],
"dynamic": false,
"info": "",
"load_from_db": false,
"title_case": false,
"type": "str"
},
"template": {
"advanced": false,
"display_name": "Template",
"dynamic": false,
"info": "",
"list": false,
"load_from_db": false,
"name": "template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "prompt",
"value": "{context}\n\n---\nYou are a doctor's assistant and help to retrieve information about patients' diagnoses.\nGiven the patients' diagnoses above, answer the question as best as possible.\nThe retrieved diagnoses may belong to multiple patients.\n\nQuestion: {question}\n\nAnswer: "
}
},
"description": "Create a prompt template with dynamic variables.",
"icon": "prompts",
"is_input": null,
"is_output": null,
"is_composition": null,
"base_classes": [
"Message"
],
"name": "",
"display_name": "Prompt",
"documentation": "",
"custom_fields": {
"template": [
"context",
"question"
]
},
"output_types": [],
"full_path": null,
"pinned": false,
"conditional_paths": [],
"frozen": false,
"outputs": [
{
"types": [
"Message"
],
"selected": "Message",
"name": "prompt",
"hidden": null,
"display_name": "Prompt Message",
"method": "build_prompt",
"value": "__UNDEFINED__",
"cache": true
}
],
"field_order": [
"template"
],
"beta": false,
"error": null,
"edited": false,
"lf_version": "1.0.18"
},
"type": "Prompt"
},
"dragging": false,
"height": 497,
"id": "Prompt-BoCHG",
"position": {
"x": 1845.8962963195672,
"y": 369.98738985466616
},
"positionAbsolute": {
"x": 1845.8962963195672,
"y": 369.98738985466616
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"description": "Display a chat message in the Playground.",
"display_name": "Chat Output",
"id": "ChatOutput-KUugW",
"node": {
"base_classes": [
"Message"
],
"beta": false,
"conditional_paths": [],
"custom_fields": {},
"description": "Display a chat message in the Playground.",
"display_name": "Chat Output",
"documentation": "",
"edited": false,
"field_order": [
"input_value",
"should_store_message",
"sender",
"sender_name",
"session_id",
"data_template"
],
"frozen": false,
"icon": "ChatOutput",
"output_types": [],
"outputs": [
{
"cache": true,
"display_name": "Message",
"method": "message_response",
"name": "message",
"selected": "Message",
"types": [
"Message"
],
"value": "__UNDEFINED__"
}
],
"pinned": false,
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.io.chat import ChatComponent\nfrom langflow.inputs import BoolInput\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.memory import store_message\nfrom langflow.schema.message import Message\nfrom langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_AI, MESSAGE_SENDER_USER\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"ChatOutput\"\n name = \"ChatOutput\"\n\n inputs = [\n MessageTextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n BoolInput(\n name=\"should_store_message\",\n display_name=\"Store Messages\",\n info=\"Store the message in the history.\",\n value=True,\n advanced=True,\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[MESSAGE_SENDER_AI, MESSAGE_SENDER_USER],\n value=MESSAGE_SENDER_AI,\n advanced=True,\n info=\"Type of sender.\",\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n value=MESSAGE_SENDER_NAME_AI,\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n )\n if (\n self.session_id\n and isinstance(message, Message)\n and isinstance(message.text, str)\n and self.should_store_message\n ):\n store_message(\n message,\n flow_id=self.graph.flow_id,\n )\n self.message.value = message\n\n self.status = message\n return message\n"
},
"data_template": {
"advanced": true,
"display_name": "Data Template",
"dynamic": false,
"info": "Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.",
"input_types": [
"Message"
],
"list": false,
"load_from_db": false,
"name": "data_template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": "{text}"
},
"input_value": {
"advanced": false,
"display_name": "Text",
"dynamic": false,
"info": "Message to be passed as output.",
"input_types": [
"Message"
],
"list": false,
"load_from_db": false,
"name": "input_value",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
"sender": {
"advanced": true,
"display_name": "Sender Type",
"dynamic": false,
"info": "Type of sender.",
"name": "sender",
"options": [
"Machine",
"User"
],
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": "Machine"
},
"sender_name": {
"advanced": true,
"display_name": "Sender Name",
"dynamic": false,
"info": "Name of the sender.",
"input_types": [
"Message"
],
"list": false,
"load_from_db": false,
"name": "sender_name",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": "AI"
},
"session_id": {
"advanced": true,
"display_name": "Session ID",
"dynamic": false,
"info": "The session ID of the chat. If empty, the current session ID parameter will be used.",
"input_types": [
"Message"
],
"list": false,
"load_from_db": false,
"name": "session_id",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
"should_store_message": {
"advanced": true,
"display_name": "Store Messages",
"dynamic": false,
"info": "Store the message in the history.",
"list": false,
"name": "should_store_message",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "bool",
"value": true
}
},
"lf_version": "1.0.18"
},
"type": "ChatOutput"
},
"dragging": false,
"height": 297,
"id": "ChatOutput-KUugW",
"position": {
"x": 2813.9664931487337,
"y": 333.33423974713844
},
"positionAbsolute": {
"x": 2813.9664931487337,
"y": 333.33423974713844
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"id": "MistalAIEmbeddings-14nKI",
"type": "genericNode",
"position": {
"x": -166.27700968011868,
"y": 303.68994814944153
},
"data": {
"type": "MistalAIEmbeddings",
"node": {
"template": {
"_type": "Component",
"code": {
"type": "code",
"required": true,
"placeholder": "",
"list": false,
"show": true,
"multiline": true,