langflow-base-nightly 1.7.0.dev55__py3-none-any.whl → 1.7.0.dev56__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- langflow/initial_setup/starter_projects/Basic Prompt Chaining.json +31 -1088
- langflow/initial_setup/starter_projects/Basic Prompting.json +196 -135
- langflow/initial_setup/starter_projects/Blog Writer.json +141 -84
- langflow/initial_setup/starter_projects/Custom Component Generator.json +133 -73
- langflow/initial_setup/starter_projects/Document Q&A.json +136 -81
- langflow/initial_setup/starter_projects/Financial Report Parser.json +12 -365
- langflow/initial_setup/starter_projects/Hybrid Search RAG.json +19 -729
- langflow/initial_setup/starter_projects/Image Sentiment Analysis.json +688 -733
- langflow/initial_setup/starter_projects/Instagram Copywriter.json +322 -203
- langflow/initial_setup/starter_projects/Invoice Summarizer.json +47 -21
- langflow/initial_setup/starter_projects/Market Research.json +63 -394
- langflow/initial_setup/starter_projects/Meeting Summary.json +266 -168
- langflow/initial_setup/starter_projects/Memory Chatbot.json +136 -81
- langflow/initial_setup/starter_projects/News Aggregator.json +49 -24
- langflow/initial_setup/starter_projects/Nvidia Remix.json +48 -23
- langflow/initial_setup/starter_projects/Pok/303/251dex Agent.json" +49 -23
- langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json +113 -418
- langflow/initial_setup/starter_projects/Price Deal Finder.json +48 -22
- langflow/initial_setup/starter_projects/Research Agent.json +319 -181
- langflow/initial_setup/starter_projects/Research Translation Loop.json +636 -615
- langflow/initial_setup/starter_projects/SEO Keyword Generator.json +145 -89
- langflow/initial_setup/starter_projects/SaaS Pricing.json +48 -22
- langflow/initial_setup/starter_projects/Search agent.json +47 -21
- langflow/initial_setup/starter_projects/Sequential Tasks Agents.json +147 -54
- langflow/initial_setup/starter_projects/Simple Agent.json +47 -16
- langflow/initial_setup/starter_projects/Social Media Agent.json +47 -16
- langflow/initial_setup/starter_projects/Text Sentiment Analysis.json +398 -251
- langflow/initial_setup/starter_projects/Travel Planning Agents.json +146 -53
- langflow/initial_setup/starter_projects/Twitter Thread Generator.json +137 -81
- langflow/initial_setup/starter_projects/Vector Store RAG.json +133 -82
- langflow/initial_setup/starter_projects/Youtube Analysis.json +182 -106
- langflow/services/storage/local.py +13 -8
- langflow/services/storage/s3.py +0 -6
- {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev56.dist-info}/METADATA +2 -2
- {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev56.dist-info}/RECORD +37 -37
- {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev56.dist-info}/WHEEL +0 -0
- {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev56.dist-info}/entry_points.txt +0 -0
|
@@ -22,40 +22,12 @@
|
|
|
22
22
|
"type": "str"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"id": "xy-edge__ChatInput-AT9yi{
|
|
25
|
+
"id": "xy-edge__ChatInput-AT9yi{\u0153dataType\u0153:\u0153ChatInput\u0153,\u0153id\u0153:\u0153ChatInput-AT9yi\u0153,\u0153name\u0153:\u0153message\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-StructuredOutput-il3eU{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153StructuredOutput-il3eU\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
|
|
26
26
|
"selected": false,
|
|
27
27
|
"source": "ChatInput-AT9yi",
|
|
28
|
-
"sourceHandle": "{
|
|
28
|
+
"sourceHandle": "{\u0153dataType\u0153: \u0153ChatInput\u0153, \u0153id\u0153: \u0153ChatInput-AT9yi\u0153, \u0153name\u0153: \u0153message\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
|
|
29
29
|
"target": "StructuredOutput-il3eU",
|
|
30
|
-
"targetHandle": "{
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"animated": false,
|
|
34
|
-
"className": "",
|
|
35
|
-
"data": {
|
|
36
|
-
"sourceHandle": {
|
|
37
|
-
"dataType": "LanguageModelComponent",
|
|
38
|
-
"id": "LanguageModelComponent-iAML1",
|
|
39
|
-
"name": "model_output",
|
|
40
|
-
"output_types": [
|
|
41
|
-
"LanguageModel"
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
"targetHandle": {
|
|
45
|
-
"fieldName": "llm",
|
|
46
|
-
"id": "StructuredOutput-il3eU",
|
|
47
|
-
"inputTypes": [
|
|
48
|
-
"LanguageModel"
|
|
49
|
-
],
|
|
50
|
-
"type": "other"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"id": "xy-edge__LanguageModelComponent-iAML1{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-iAML1œ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutput-il3eU{œfieldNameœ:œllmœ,œidœ:œStructuredOutput-il3eUœ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}",
|
|
54
|
-
"selected": false,
|
|
55
|
-
"source": "LanguageModelComponent-iAML1",
|
|
56
|
-
"sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-iAML1œ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}",
|
|
57
|
-
"target": "StructuredOutput-il3eU",
|
|
58
|
-
"targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutput-il3eUœ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}"
|
|
30
|
+
"targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153StructuredOutput-il3eU\u0153, \u0153inputTypes\u0153: [\u0153Message\u0153], \u0153type\u0153: \u0153str\u0153}"
|
|
59
31
|
},
|
|
60
32
|
{
|
|
61
33
|
"animated": false,
|
|
@@ -79,12 +51,12 @@
|
|
|
79
51
|
"type": "other"
|
|
80
52
|
}
|
|
81
53
|
},
|
|
82
|
-
"id": "xy-edge__StructuredOutput-il3eU{
|
|
54
|
+
"id": "xy-edge__StructuredOutput-il3eU{\u0153dataType\u0153:\u0153StructuredOutput\u0153,\u0153id\u0153:\u0153StructuredOutput-il3eU\u0153,\u0153name\u0153:\u0153dataframe_output\u0153,\u0153output_types\u0153:[\u0153DataFrame\u0153]}-ParserComponent-FWDxd{\u0153fieldName\u0153:\u0153input_data\u0153,\u0153id\u0153:\u0153ParserComponent-FWDxd\u0153,\u0153inputTypes\u0153:[\u0153DataFrame\u0153,\u0153Data\u0153],\u0153type\u0153:\u0153other\u0153}",
|
|
83
55
|
"selected": false,
|
|
84
56
|
"source": "StructuredOutput-il3eU",
|
|
85
|
-
"sourceHandle": "{
|
|
57
|
+
"sourceHandle": "{\u0153dataType\u0153: \u0153StructuredOutput\u0153, \u0153id\u0153: \u0153StructuredOutput-il3eU\u0153, \u0153name\u0153: \u0153dataframe_output\u0153, \u0153output_types\u0153: [\u0153DataFrame\u0153]}",
|
|
86
58
|
"target": "ParserComponent-FWDxd",
|
|
87
|
-
"targetHandle": "{
|
|
59
|
+
"targetHandle": "{\u0153fieldName\u0153: \u0153input_data\u0153, \u0153id\u0153: \u0153ParserComponent-FWDxd\u0153, \u0153inputTypes\u0153: [\u0153DataFrame\u0153, \u0153Data\u0153], \u0153type\u0153: \u0153other\u0153}"
|
|
88
60
|
},
|
|
89
61
|
{
|
|
90
62
|
"animated": false,
|
|
@@ -109,12 +81,12 @@
|
|
|
109
81
|
"type": "str"
|
|
110
82
|
}
|
|
111
83
|
},
|
|
112
|
-
"id": "xy-edge__ParserComponent-FWDxd{
|
|
84
|
+
"id": "xy-edge__ParserComponent-FWDxd{\u0153dataType\u0153:\u0153ParserComponent\u0153,\u0153id\u0153:\u0153ParserComponent-FWDxd\u0153,\u0153name\u0153:\u0153parsed_text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-ChatOutput-XvCBo{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153ChatOutput-XvCBo\u0153,\u0153inputTypes\u0153:[\u0153Data\u0153,\u0153DataFrame\u0153,\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
|
|
113
85
|
"selected": false,
|
|
114
86
|
"source": "ParserComponent-FWDxd",
|
|
115
|
-
"sourceHandle": "{
|
|
87
|
+
"sourceHandle": "{\u0153dataType\u0153: \u0153ParserComponent\u0153, \u0153id\u0153: \u0153ParserComponent-FWDxd\u0153, \u0153name\u0153: \u0153parsed_text\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
|
|
116
88
|
"target": "ChatOutput-XvCBo",
|
|
117
|
-
"targetHandle": "{
|
|
89
|
+
"targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153ChatOutput-XvCBo\u0153, \u0153inputTypes\u0153: [\u0153Data\u0153, \u0153DataFrame\u0153, \u0153Message\u0153], \u0153type\u0153: \u0153str\u0153}"
|
|
118
90
|
}
|
|
119
91
|
],
|
|
120
92
|
"nodes": [
|
|
@@ -575,7 +547,7 @@
|
|
|
575
547
|
"trace_as_input": true,
|
|
576
548
|
"trace_as_metadata": true,
|
|
577
549
|
"type": "str",
|
|
578
|
-
"value": "In 2022, the company demonstrated strong financial performance, reporting a gross profit of $1.2 billion, reflecting stable revenue generation and effective cost management. The EBITDA stood at $900 million, highlighting the company
|
|
550
|
+
"value": "In 2022, the company demonstrated strong financial performance, reporting a gross profit of $1.2 billion, reflecting stable revenue generation and effective cost management. The EBITDA stood at $900 million, highlighting the company\u2019s solid operational efficiency and profitability before interest, taxes, depreciation, and amortization. Despite a slight increase in operating expenses compared to 2021, the company maintained a healthy bottom line, achieving a net income of $500 million. This growth underscores the company\u2019s ability to navigate economic challenges while sustaining profitability, reinforcing its financial stability and competitive position in the market."
|
|
579
551
|
},
|
|
580
552
|
"sender": {
|
|
581
553
|
"_input_type": "DropdownInput",
|
|
@@ -688,7 +660,7 @@
|
|
|
688
660
|
"data": {
|
|
689
661
|
"id": "note-khpnk",
|
|
690
662
|
"node": {
|
|
691
|
-
"description": "###
|
|
663
|
+
"description": "### \ud83d\udca1 Add your OpenAI API key here",
|
|
692
664
|
"display_name": "",
|
|
693
665
|
"documentation": "",
|
|
694
666
|
"template": {
|
|
@@ -737,331 +709,6 @@
|
|
|
737
709
|
"type": "noteNode",
|
|
738
710
|
"width": 619
|
|
739
711
|
},
|
|
740
|
-
{
|
|
741
|
-
"data": {
|
|
742
|
-
"id": "LanguageModelComponent-iAML1",
|
|
743
|
-
"node": {
|
|
744
|
-
"base_classes": [
|
|
745
|
-
"LanguageModel",
|
|
746
|
-
"Message"
|
|
747
|
-
],
|
|
748
|
-
"beta": false,
|
|
749
|
-
"conditional_paths": [],
|
|
750
|
-
"custom_fields": {},
|
|
751
|
-
"description": "Runs a language model given a specified provider.",
|
|
752
|
-
"display_name": "Language Model",
|
|
753
|
-
"documentation": "",
|
|
754
|
-
"edited": false,
|
|
755
|
-
"field_order": [
|
|
756
|
-
"provider",
|
|
757
|
-
"model_name",
|
|
758
|
-
"api_key",
|
|
759
|
-
"input_value",
|
|
760
|
-
"system_message",
|
|
761
|
-
"stream",
|
|
762
|
-
"temperature"
|
|
763
|
-
],
|
|
764
|
-
"frozen": false,
|
|
765
|
-
"icon": "brain-circuit",
|
|
766
|
-
"last_updated": "2025-09-29T15:43:28.263Z",
|
|
767
|
-
"legacy": false,
|
|
768
|
-
"lf_version": "1.6.0",
|
|
769
|
-
"metadata": {
|
|
770
|
-
"code_hash": "bb5f8714781b",
|
|
771
|
-
"dependencies": {
|
|
772
|
-
"dependencies": [
|
|
773
|
-
{
|
|
774
|
-
"name": "langchain_anthropic",
|
|
775
|
-
"version": "0.3.14"
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
"name": "langchain_google_genai",
|
|
779
|
-
"version": "2.0.6"
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
"name": "langchain_openai",
|
|
783
|
-
"version": "0.3.23"
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
"name": "lfx",
|
|
787
|
-
"version": null
|
|
788
|
-
}
|
|
789
|
-
],
|
|
790
|
-
"total_dependencies": 4
|
|
791
|
-
},
|
|
792
|
-
"keywords": [
|
|
793
|
-
"model",
|
|
794
|
-
"llm",
|
|
795
|
-
"language model",
|
|
796
|
-
"large language model"
|
|
797
|
-
],
|
|
798
|
-
"module": "lfx.components.models.language_model.LanguageModelComponent"
|
|
799
|
-
},
|
|
800
|
-
"minimized": false,
|
|
801
|
-
"output_types": [],
|
|
802
|
-
"outputs": [
|
|
803
|
-
{
|
|
804
|
-
"allows_loop": false,
|
|
805
|
-
"cache": true,
|
|
806
|
-
"display_name": "Model Response",
|
|
807
|
-
"group_outputs": false,
|
|
808
|
-
"method": "text_response",
|
|
809
|
-
"name": "text_output",
|
|
810
|
-
"options": null,
|
|
811
|
-
"required_inputs": null,
|
|
812
|
-
"selected": "Message",
|
|
813
|
-
"tool_mode": true,
|
|
814
|
-
"types": [
|
|
815
|
-
"Message"
|
|
816
|
-
],
|
|
817
|
-
"value": "__UNDEFINED__"
|
|
818
|
-
},
|
|
819
|
-
{
|
|
820
|
-
"allows_loop": false,
|
|
821
|
-
"cache": true,
|
|
822
|
-
"display_name": "Language Model",
|
|
823
|
-
"group_outputs": false,
|
|
824
|
-
"method": "build_model",
|
|
825
|
-
"name": "model_output",
|
|
826
|
-
"options": null,
|
|
827
|
-
"required_inputs": null,
|
|
828
|
-
"selected": "LanguageModel",
|
|
829
|
-
"tool_mode": true,
|
|
830
|
-
"types": [
|
|
831
|
-
"LanguageModel"
|
|
832
|
-
],
|
|
833
|
-
"value": "__UNDEFINED__"
|
|
834
|
-
}
|
|
835
|
-
],
|
|
836
|
-
"pinned": false,
|
|
837
|
-
"priority": 0,
|
|
838
|
-
"template": {
|
|
839
|
-
"_type": "Component",
|
|
840
|
-
"api_key": {
|
|
841
|
-
"_input_type": "SecretStrInput",
|
|
842
|
-
"advanced": false,
|
|
843
|
-
"display_name": "OpenAI API Key",
|
|
844
|
-
"dynamic": false,
|
|
845
|
-
"info": "Model Provider API key",
|
|
846
|
-
"input_types": [],
|
|
847
|
-
"load_from_db": true,
|
|
848
|
-
"name": "api_key",
|
|
849
|
-
"password": true,
|
|
850
|
-
"placeholder": "",
|
|
851
|
-
"real_time_refresh": true,
|
|
852
|
-
"required": false,
|
|
853
|
-
"show": true,
|
|
854
|
-
"title_case": false,
|
|
855
|
-
"type": "str",
|
|
856
|
-
"value": "OPENAI_API_KEY"
|
|
857
|
-
},
|
|
858
|
-
"code": {
|
|
859
|
-
"advanced": true,
|
|
860
|
-
"dynamic": true,
|
|
861
|
-
"fileTypes": [],
|
|
862
|
-
"file_path": "",
|
|
863
|
-
"info": "",
|
|
864
|
-
"list": false,
|
|
865
|
-
"load_from_db": false,
|
|
866
|
-
"multiline": true,
|
|
867
|
-
"name": "code",
|
|
868
|
-
"password": false,
|
|
869
|
-
"placeholder": "",
|
|
870
|
-
"required": true,
|
|
871
|
-
"show": true,
|
|
872
|
-
"title_case": false,
|
|
873
|
-
"type": "code",
|
|
874
|
-
"value": "from lfx.base.models.model import LCModelComponent\nfrom lfx.base.models.unified_models import (\n get_language_model_options,\n get_llm,\n update_model_options_in_build_config,\n)\nfrom lfx.base.models.watsonx_constants import IBM_WATSONX_URLS\nfrom lfx.field_typing import LanguageModel\nfrom lfx.field_typing.range_spec import RangeSpec\nfrom lfx.inputs.inputs import BoolInput, DropdownInput, StrInput\nfrom lfx.io import MessageInput, ModelInput, MultilineInput, SecretStrInput, SliderInput\n\nDEFAULT_OLLAMA_URL = \"http://localhost:11434\"\n\n\nclass LanguageModelComponent(LCModelComponent):\n display_name = \"Language Model\"\n description = \"Runs a language model given a specified provider.\"\n documentation: str = \"https://docs.langflow.org/components-models\"\n icon = \"brain-circuit\"\n category = \"models\"\n priority = 0 # Set priority to 0 to make it appear first\n\n inputs = [\n ModelInput(\n name=\"model\",\n display_name=\"Language Model\",\n info=\"Select your model provider\",\n real_time_refresh=True,\n required=True,\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n info=\"Model Provider API key\",\n required=False,\n show=True,\n real_time_refresh=True,\n advanced=True,\n ),\n DropdownInput(\n name=\"base_url_ibm_watsonx\",\n display_name=\"watsonx API Endpoint\",\n info=\"The base URL of the API (IBM watsonx.ai only)\",\n options=IBM_WATSONX_URLS,\n value=IBM_WATSONX_URLS[0],\n show=False,\n real_time_refresh=True,\n ),\n StrInput(\n name=\"project_id\",\n display_name=\"watsonx Project ID\",\n info=\"The project ID associated with the foundation model (IBM watsonx.ai only)\",\n show=False,\n required=False,\n ),\n MessageInput(\n name=\"ollama_base_url\",\n display_name=\"Ollama API URL\",\n info=f\"Endpoint of the Ollama API (Ollama only). Defaults to {DEFAULT_OLLAMA_URL}\",\n value=DEFAULT_OLLAMA_URL,\n show=False,\n real_time_refresh=True,\n load_from_db=True,\n ),\n MessageInput(\n name=\"input_value\",\n display_name=\"Input\",\n info=\"The input text to send to the model\",\n ),\n MultilineInput(\n name=\"system_message\",\n display_name=\"System Message\",\n info=\"A system message that helps set the behavior of the assistant\",\n advanced=False,\n ),\n BoolInput(\n name=\"stream\",\n display_name=\"Stream\",\n info=\"Whether to stream the response\",\n value=False,\n advanced=True,\n ),\n SliderInput(\n name=\"temperature\",\n display_name=\"Temperature\",\n value=0.1,\n info=\"Controls randomness in responses\",\n range_spec=RangeSpec(min=0, max=1, step=0.01),\n advanced=True,\n ),\n ]\n\n def build_model(self) -> LanguageModel:\n return get_llm(\n model=self.model,\n user_id=self.user_id,\n api_key=self.api_key,\n temperature=self.temperature,\n stream=self.stream,\n )\n\n def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):\n \"\"\"Dynamically update build config with user-filtered model options.\"\"\"\n return update_model_options_in_build_config(\n component=self,\n build_config=build_config,\n cache_key_prefix=\"language_model_options\",\n get_options_func=get_language_model_options,\n field_name=field_name,\n field_value=field_value,\n )\n"
|
|
875
|
-
},
|
|
876
|
-
"input_value": {
|
|
877
|
-
"_input_type": "MessageTextInput",
|
|
878
|
-
"advanced": false,
|
|
879
|
-
"display_name": "Input",
|
|
880
|
-
"dynamic": false,
|
|
881
|
-
"info": "The input text to send to the model",
|
|
882
|
-
"input_types": [
|
|
883
|
-
"Message"
|
|
884
|
-
],
|
|
885
|
-
"list": false,
|
|
886
|
-
"list_add_label": "Add More",
|
|
887
|
-
"load_from_db": false,
|
|
888
|
-
"name": "input_value",
|
|
889
|
-
"placeholder": "",
|
|
890
|
-
"required": false,
|
|
891
|
-
"show": true,
|
|
892
|
-
"title_case": false,
|
|
893
|
-
"tool_mode": false,
|
|
894
|
-
"trace_as_input": true,
|
|
895
|
-
"trace_as_metadata": true,
|
|
896
|
-
"type": "str",
|
|
897
|
-
"value": ""
|
|
898
|
-
},
|
|
899
|
-
"model_name": {
|
|
900
|
-
"_input_type": "DropdownInput",
|
|
901
|
-
"advanced": false,
|
|
902
|
-
"combobox": false,
|
|
903
|
-
"dialog_inputs": {},
|
|
904
|
-
"display_name": "Model Name",
|
|
905
|
-
"dynamic": false,
|
|
906
|
-
"info": "Select the model to use",
|
|
907
|
-
"name": "model_name",
|
|
908
|
-
"options": [
|
|
909
|
-
"gpt-4o-mini",
|
|
910
|
-
"gpt-4o",
|
|
911
|
-
"gpt-4.1",
|
|
912
|
-
"gpt-4.1-mini",
|
|
913
|
-
"gpt-4.1-nano",
|
|
914
|
-
"gpt-4-turbo",
|
|
915
|
-
"gpt-4-turbo-preview",
|
|
916
|
-
"gpt-4",
|
|
917
|
-
"gpt-3.5-turbo",
|
|
918
|
-
"gpt-5",
|
|
919
|
-
"gpt-5-mini",
|
|
920
|
-
"gpt-5-nano",
|
|
921
|
-
"gpt-5-chat-latest",
|
|
922
|
-
"o1",
|
|
923
|
-
"o3-mini",
|
|
924
|
-
"o3",
|
|
925
|
-
"o3-pro",
|
|
926
|
-
"o4-mini",
|
|
927
|
-
"o4-mini-high"
|
|
928
|
-
],
|
|
929
|
-
"options_metadata": [],
|
|
930
|
-
"placeholder": "",
|
|
931
|
-
"required": false,
|
|
932
|
-
"show": true,
|
|
933
|
-
"title_case": false,
|
|
934
|
-
"toggle": false,
|
|
935
|
-
"tool_mode": false,
|
|
936
|
-
"trace_as_metadata": true,
|
|
937
|
-
"type": "str",
|
|
938
|
-
"value": "gpt-4o-mini"
|
|
939
|
-
},
|
|
940
|
-
"provider": {
|
|
941
|
-
"_input_type": "DropdownInput",
|
|
942
|
-
"advanced": false,
|
|
943
|
-
"combobox": false,
|
|
944
|
-
"dialog_inputs": {},
|
|
945
|
-
"display_name": "Model Provider",
|
|
946
|
-
"dynamic": false,
|
|
947
|
-
"info": "Select the model provider",
|
|
948
|
-
"name": "provider",
|
|
949
|
-
"options": [
|
|
950
|
-
"OpenAI",
|
|
951
|
-
"Anthropic",
|
|
952
|
-
"Google"
|
|
953
|
-
],
|
|
954
|
-
"options_metadata": [
|
|
955
|
-
{
|
|
956
|
-
"icon": "OpenAI"
|
|
957
|
-
},
|
|
958
|
-
{
|
|
959
|
-
"icon": "Anthropic"
|
|
960
|
-
},
|
|
961
|
-
{
|
|
962
|
-
"icon": "Google"
|
|
963
|
-
}
|
|
964
|
-
],
|
|
965
|
-
"placeholder": "",
|
|
966
|
-
"real_time_refresh": true,
|
|
967
|
-
"required": false,
|
|
968
|
-
"show": true,
|
|
969
|
-
"title_case": false,
|
|
970
|
-
"toggle": false,
|
|
971
|
-
"tool_mode": false,
|
|
972
|
-
"trace_as_metadata": true,
|
|
973
|
-
"type": "str",
|
|
974
|
-
"value": "OpenAI"
|
|
975
|
-
},
|
|
976
|
-
"stream": {
|
|
977
|
-
"_input_type": "BoolInput",
|
|
978
|
-
"advanced": true,
|
|
979
|
-
"display_name": "Stream",
|
|
980
|
-
"dynamic": false,
|
|
981
|
-
"info": "Whether to stream the response",
|
|
982
|
-
"list": false,
|
|
983
|
-
"list_add_label": "Add More",
|
|
984
|
-
"name": "stream",
|
|
985
|
-
"placeholder": "",
|
|
986
|
-
"required": false,
|
|
987
|
-
"show": true,
|
|
988
|
-
"title_case": false,
|
|
989
|
-
"tool_mode": false,
|
|
990
|
-
"trace_as_metadata": true,
|
|
991
|
-
"type": "bool",
|
|
992
|
-
"value": false
|
|
993
|
-
},
|
|
994
|
-
"system_message": {
|
|
995
|
-
"_input_type": "MessageTextInput",
|
|
996
|
-
"advanced": true,
|
|
997
|
-
"display_name": "System Message",
|
|
998
|
-
"dynamic": false,
|
|
999
|
-
"info": "A system message that helps set the behavior of the assistant",
|
|
1000
|
-
"input_types": [
|
|
1001
|
-
"Message"
|
|
1002
|
-
],
|
|
1003
|
-
"list": false,
|
|
1004
|
-
"list_add_label": "Add More",
|
|
1005
|
-
"load_from_db": false,
|
|
1006
|
-
"name": "system_message",
|
|
1007
|
-
"placeholder": "",
|
|
1008
|
-
"required": false,
|
|
1009
|
-
"show": true,
|
|
1010
|
-
"title_case": false,
|
|
1011
|
-
"tool_mode": false,
|
|
1012
|
-
"trace_as_input": true,
|
|
1013
|
-
"trace_as_metadata": true,
|
|
1014
|
-
"type": "str",
|
|
1015
|
-
"value": ""
|
|
1016
|
-
},
|
|
1017
|
-
"temperature": {
|
|
1018
|
-
"_input_type": "SliderInput",
|
|
1019
|
-
"advanced": true,
|
|
1020
|
-
"display_name": "Temperature",
|
|
1021
|
-
"dynamic": false,
|
|
1022
|
-
"info": "Controls randomness in responses",
|
|
1023
|
-
"max_label": "",
|
|
1024
|
-
"max_label_icon": "",
|
|
1025
|
-
"min_label": "",
|
|
1026
|
-
"min_label_icon": "",
|
|
1027
|
-
"name": "temperature",
|
|
1028
|
-
"placeholder": "",
|
|
1029
|
-
"range_spec": {
|
|
1030
|
-
"max": 1,
|
|
1031
|
-
"min": 0,
|
|
1032
|
-
"step": 0.01,
|
|
1033
|
-
"step_type": "float"
|
|
1034
|
-
},
|
|
1035
|
-
"required": false,
|
|
1036
|
-
"show": true,
|
|
1037
|
-
"slider_buttons": false,
|
|
1038
|
-
"slider_buttons_options": [],
|
|
1039
|
-
"slider_input": false,
|
|
1040
|
-
"title_case": false,
|
|
1041
|
-
"tool_mode": false,
|
|
1042
|
-
"type": "slider",
|
|
1043
|
-
"value": 0.1
|
|
1044
|
-
}
|
|
1045
|
-
},
|
|
1046
|
-
"tool_mode": false
|
|
1047
|
-
},
|
|
1048
|
-
"selected_output": "model_output",
|
|
1049
|
-
"showNode": true,
|
|
1050
|
-
"type": "LanguageModelComponent"
|
|
1051
|
-
},
|
|
1052
|
-
"dragging": false,
|
|
1053
|
-
"id": "LanguageModelComponent-iAML1",
|
|
1054
|
-
"measured": {
|
|
1055
|
-
"height": 451,
|
|
1056
|
-
"width": 320
|
|
1057
|
-
},
|
|
1058
|
-
"position": {
|
|
1059
|
-
"x": 912.2321256553546,
|
|
1060
|
-
"y": -350.4215686841271
|
|
1061
|
-
},
|
|
1062
|
-
"selected": false,
|
|
1063
|
-
"type": "genericNode"
|
|
1064
|
-
},
|
|
1065
712
|
{
|
|
1066
713
|
"data": {
|
|
1067
714
|
"id": "StructuredOutput-il3eU",
|
|
@@ -1180,7 +827,7 @@
|
|
|
1180
827
|
"show": true,
|
|
1181
828
|
"title_case": false,
|
|
1182
829
|
"type": "code",
|
|
1183
|
-
"value": "from pydantic import BaseModel, Field, create_model\nfrom trustcall import create_extractor\n\nfrom lfx.base.models.chat_result import get_chat_result\nfrom lfx.base.models.unified_models import (\n get_language_model_options,\n get_llm,\n update_model_options_in_build_config,\n)\nfrom lfx.custom.custom_component.component import Component\nfrom lfx.helpers.base_model import build_model_from_schema\nfrom lfx.io import (\n MessageTextInput,\n ModelInput,\n MultilineInput,\n Output,\n SecretStrInput,\n TableInput,\n)\nfrom lfx.log.logger import logger\nfrom lfx.schema.data import Data\nfrom lfx.schema.dataframe import DataFrame\nfrom lfx.schema.table import EditMode\n\n\nclass StructuredOutputComponent(Component):\n display_name = \"Structured Output\"\n description = \"Uses an LLM to generate structured data. Ideal for extraction and consistency.\"\n documentation: str = \"https://docs.langflow.org/structured-output\"\n name = \"StructuredOutput\"\n icon = \"braces\"\n\n inputs = [\n ModelInput(\n name=\"model\",\n display_name=\"Language Model\",\n info=\"Select your model provider\",\n real_time_refresh=True,\n required=True,\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n info=\"Model Provider API key\",\n real_time_refresh=True,\n advanced=True,\n ),\n MultilineInput(\n name=\"input_value\",\n display_name=\"Input Message\",\n info=\"The input message to the language model.\",\n tool_mode=True,\n required=True,\n ),\n MultilineInput(\n name=\"system_prompt\",\n display_name=\"Format Instructions\",\n info=\"The instructions to the language model for formatting the output.\",\n value=(\n \"You are an AI that extracts structured JSON objects from unstructured text. \"\n \"Use a predefined schema with expected types (str, int, float, bool, dict). \"\n \"Extract ALL relevant instances that match the schema - if multiple patterns exist, capture them all. \"\n \"Fill missing or ambiguous values with defaults: null for missing values. \"\n \"Remove exact duplicates but keep variations that have different field values. \"\n \"Always return valid JSON in the expected format, never throw errors. \"\n \"If multiple objects can be extracted, return them all in the structured format.\"\n ),\n required=True,\n advanced=True,\n ),\n MessageTextInput(\n name=\"schema_name\",\n display_name=\"Schema Name\",\n info=\"Provide a name for the output data schema.\",\n advanced=True,\n ),\n TableInput(\n name=\"output_schema\",\n display_name=\"Output Schema\",\n info=\"Define the structure and data types for the model's output.\",\n required=True,\n # TODO: remove deault value\n table_schema=[\n {\n \"name\": \"name\",\n \"display_name\": \"Name\",\n \"type\": \"str\",\n \"description\": \"Specify the name of the output field.\",\n \"default\": \"field\",\n \"edit_mode\": EditMode.INLINE,\n },\n {\n \"name\": \"description\",\n \"display_name\": \"Description\",\n \"type\": \"str\",\n \"description\": \"Describe the purpose of the output field.\",\n \"default\": \"description of field\",\n \"edit_mode\": EditMode.POPOVER,\n },\n {\n \"name\": \"type\",\n \"display_name\": \"Type\",\n \"type\": \"str\",\n \"edit_mode\": EditMode.INLINE,\n \"description\": (\"Indicate the data type of the output field (e.g., str, int, float, bool, dict).\"),\n \"options\": [\"str\", \"int\", \"float\", \"bool\", \"dict\"],\n \"default\": \"str\",\n },\n {\n \"name\": \"multiple\",\n \"display_name\": \"As List\",\n \"type\": \"boolean\",\n \"description\": \"Set to True if this output field should be a list of the specified type.\",\n \"default\": \"False\",\n \"edit_mode\": EditMode.INLINE,\n },\n ],\n value=[\n {\n \"name\": \"field\",\n \"description\": \"description of field\",\n \"type\": \"str\",\n \"multiple\": \"False\",\n }\n ],\n ),\n ]\n\n outputs = [\n Output(\n name=\"structured_output\",\n display_name=\"Structured Output\",\n method=\"build_structured_output\",\n ),\n Output(\n name=\"dataframe_output\",\n display_name=\"Structured Output\",\n method=\"build_structured_dataframe\",\n ),\n ]\n\n def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):\n \"\"\"Dynamically update build config with user-filtered model options.\"\"\"\n return update_model_options_in_build_config(\n component=self,\n build_config=build_config,\n cache_key_prefix=\"language_model_options\",\n get_options_func=get_language_model_options,\n field_name=field_name,\n field_value=field_value,\n )\n\n def build_structured_output_base(self):\n schema_name = self.schema_name or \"OutputModel\"\n\n llm = get_llm(model=self.model, user_id=self.user_id, api_key=self.api_key)\n\n if not hasattr(llm, \"with_structured_output\"):\n msg = \"Language model does not support structured output.\"\n raise TypeError(msg)\n if not self.output_schema:\n msg = \"Output schema cannot be empty\"\n raise ValueError(msg)\n\n output_model_ = build_model_from_schema(self.output_schema)\n output_model = create_model(\n schema_name,\n __doc__=f\"A list of {schema_name}.\",\n objects=(\n list[output_model_],\n Field(\n description=f\"A list of {schema_name}.\", # type: ignore[valid-type]\n min_length=1, # help ensure non-empty output\n ),\n ),\n )\n # Tracing config\n config_dict = {\n \"run_name\": self.display_name,\n \"project_name\": self.get_project_name(),\n \"callbacks\": self.get_langchain_callbacks(),\n }\n # Generate structured output using Trustcall first, then fallback to Langchain if it fails\n result = self._extract_output_with_trustcall(llm, output_model, config_dict)\n if result is None:\n result = self._extract_output_with_langchain(llm, output_model, config_dict)\n\n # OPTIMIZATION NOTE: Simplified processing based on trustcall response structure\n # Handle non-dict responses (shouldn't happen with trustcall, but defensive)\n if not isinstance(result, dict):\n return result\n\n # Extract first response and convert BaseModel to dict\n responses = result.get(\"responses\", [])\n if not responses:\n return result\n\n # Convert BaseModel to dict (creates the \"objects\" key)\n first_response = responses[0]\n structured_data = first_response\n if isinstance(first_response, BaseModel):\n structured_data = first_response.model_dump()\n # Extract the objects array (guaranteed to exist due to our Pydantic model structure)\n return structured_data.get(\"objects\", structured_data)\n\n def build_structured_output(self) -> Data:\n output = self.build_structured_output_base()\n if not isinstance(output, list) or not output:\n # handle empty or unexpected type case\n msg = \"No structured output returned\"\n raise ValueError(msg)\n if len(output) == 1:\n return Data(data=output[0])\n if len(output) > 1:\n # Multiple outputs - wrap them in a results container\n return Data(data={\"results\": output})\n return Data()\n\n def build_structured_dataframe(self) -> DataFrame:\n output = self.build_structured_output_base()\n if not isinstance(output, list) or not output:\n # handle empty or unexpected type case\n msg = \"No structured output returned\"\n raise ValueError(msg)\n if len(output) == 1:\n # For single dictionary, wrap in a list to create DataFrame with one row\n return DataFrame([output[0]])\n if len(output) > 1:\n # Multiple outputs - convert to DataFrame directly\n return DataFrame(output)\n return DataFrame()\n\n def _extract_output_with_trustcall(self, llm, schema: BaseModel, config_dict: dict) -> list[BaseModel] | None:\n try:\n llm_with_structured_output = create_extractor(llm, tools=[schema], tool_choice=schema.__name__)\n result = get_chat_result(\n runnable=llm_with_structured_output,\n system_message=self.system_prompt,\n input_value=self.input_value,\n config=config_dict,\n )\n except Exception as e: # noqa: BLE001\n logger.warning(\n f\"Trustcall extraction failed, falling back to Langchain: {e} \"\n \"(Note: This may not be an error—some models or configurations do not support tool calling. \"\n \"Falling back is normal in such cases.)\"\n )\n return None\n return result or None # langchain fallback is used if error occurs or the result is empty\n\n def _extract_output_with_langchain(self, llm, schema: BaseModel, config_dict: dict) -> list[BaseModel] | None:\n try:\n llm_with_structured_output = llm.with_structured_output(schema)\n result = get_chat_result(\n runnable=llm_with_structured_output,\n system_message=self.system_prompt,\n input_value=self.input_value,\n config=config_dict,\n )\n if isinstance(result, BaseModel):\n result = result.model_dump()\n result = result.get(\"objects\", result)\n except Exception as fallback_error:\n msg = (\n f\"Model does not support tool calling (trustcall failed) \"\n f\"and fallback with_structured_output also failed: {fallback_error}\"\n )\n raise ValueError(msg) from fallback_error\n\n return result or None\n"
|
|
830
|
+
"value": "from pydantic import BaseModel, Field, create_model\nfrom trustcall import create_extractor\n\nfrom lfx.base.models.chat_result import get_chat_result\nfrom lfx.base.models.unified_models import (\n get_language_model_options,\n get_llm,\n update_model_options_in_build_config,\n)\nfrom lfx.custom.custom_component.component import Component\nfrom lfx.helpers.base_model import build_model_from_schema\nfrom lfx.io import (\n MessageTextInput,\n ModelInput,\n MultilineInput,\n Output,\n SecretStrInput,\n TableInput,\n)\nfrom lfx.log.logger import logger\nfrom lfx.schema.data import Data\nfrom lfx.schema.dataframe import DataFrame\nfrom lfx.schema.table import EditMode\n\n\nclass StructuredOutputComponent(Component):\n display_name = \"Structured Output\"\n description = \"Uses an LLM to generate structured data. Ideal for extraction and consistency.\"\n documentation: str = \"https://docs.langflow.org/structured-output\"\n name = \"StructuredOutput\"\n icon = \"braces\"\n\n inputs = [\n ModelInput(\n name=\"model\",\n display_name=\"Language Model\",\n info=\"Select your model provider\",\n real_time_refresh=True,\n required=True,\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n info=\"Model Provider API key\",\n real_time_refresh=True,\n advanced=True,\n ),\n MultilineInput(\n name=\"input_value\",\n display_name=\"Input Message\",\n info=\"The input message to the language model.\",\n tool_mode=True,\n required=True,\n ),\n MultilineInput(\n name=\"system_prompt\",\n display_name=\"Format Instructions\",\n info=\"The instructions to the language model for formatting the output.\",\n value=(\n \"You are an AI that extracts structured JSON objects from unstructured text. \"\n \"Use a predefined schema with expected types (str, int, float, bool, dict). \"\n \"Extract ALL relevant instances that match the schema - if multiple patterns exist, capture them all. \"\n \"Fill missing or ambiguous values with defaults: null for missing values. \"\n \"Remove exact duplicates but keep variations that have different field values. \"\n \"Always return valid JSON in the expected format, never throw errors. \"\n \"If multiple objects can be extracted, return them all in the structured format.\"\n ),\n required=True,\n advanced=True,\n ),\n MessageTextInput(\n name=\"schema_name\",\n display_name=\"Schema Name\",\n info=\"Provide a name for the output data schema.\",\n advanced=True,\n ),\n TableInput(\n name=\"output_schema\",\n display_name=\"Output Schema\",\n info=\"Define the structure and data types for the model's output.\",\n required=True,\n # TODO: remove deault value\n table_schema=[\n {\n \"name\": \"name\",\n \"display_name\": \"Name\",\n \"type\": \"str\",\n \"description\": \"Specify the name of the output field.\",\n \"default\": \"field\",\n \"edit_mode\": EditMode.INLINE,\n },\n {\n \"name\": \"description\",\n \"display_name\": \"Description\",\n \"type\": \"str\",\n \"description\": \"Describe the purpose of the output field.\",\n \"default\": \"description of field\",\n \"edit_mode\": EditMode.POPOVER,\n },\n {\n \"name\": \"type\",\n \"display_name\": \"Type\",\n \"type\": \"str\",\n \"edit_mode\": EditMode.INLINE,\n \"description\": (\"Indicate the data type of the output field (e.g., str, int, float, bool, dict).\"),\n \"options\": [\"str\", \"int\", \"float\", \"bool\", \"dict\"],\n \"default\": \"str\",\n },\n {\n \"name\": \"multiple\",\n \"display_name\": \"As List\",\n \"type\": \"boolean\",\n \"description\": \"Set to True if this output field should be a list of the specified type.\",\n \"default\": \"False\",\n \"edit_mode\": EditMode.INLINE,\n },\n ],\n value=[\n {\n \"name\": \"field\",\n \"description\": \"description of field\",\n \"type\": \"str\",\n \"multiple\": \"False\",\n }\n ],\n ),\n ]\n\n outputs = [\n Output(\n name=\"structured_output\",\n display_name=\"Structured Output\",\n method=\"build_structured_output\",\n ),\n Output(\n name=\"dataframe_output\",\n display_name=\"Structured Output\",\n method=\"build_structured_dataframe\",\n ),\n ]\n\n def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):\n \"\"\"Dynamically update build config with user-filtered model options.\"\"\"\n return update_model_options_in_build_config(\n component=self,\n build_config=build_config,\n cache_key_prefix=\"language_model_options\",\n get_options_func=get_language_model_options,\n field_name=field_name,\n field_value=field_value,\n )\n\n def build_structured_output_base(self):\n schema_name = self.schema_name or \"OutputModel\"\n\n llm = get_llm(model=self.model, user_id=self.user_id, api_key=self.api_key)\n\n if not hasattr(llm, \"with_structured_output\"):\n msg = \"Language model does not support structured output.\"\n raise TypeError(msg)\n if not self.output_schema:\n msg = \"Output schema cannot be empty\"\n raise ValueError(msg)\n\n output_model_ = build_model_from_schema(self.output_schema)\n output_model = create_model(\n schema_name,\n __doc__=f\"A list of {schema_name}.\",\n objects=(\n list[output_model_],\n Field(\n description=f\"A list of {schema_name}.\", # type: ignore[valid-type]\n min_length=1, # help ensure non-empty output\n ),\n ),\n )\n # Tracing config\n config_dict = {\n \"run_name\": self.display_name,\n \"project_name\": self.get_project_name(),\n \"callbacks\": self.get_langchain_callbacks(),\n }\n # Generate structured output using Trustcall first, then fallback to Langchain if it fails\n result = self._extract_output_with_trustcall(llm, output_model, config_dict)\n if result is None:\n result = self._extract_output_with_langchain(llm, output_model, config_dict)\n\n # OPTIMIZATION NOTE: Simplified processing based on trustcall response structure\n # Handle non-dict responses (shouldn't happen with trustcall, but defensive)\n if not isinstance(result, dict):\n return result\n\n # Extract first response and convert BaseModel to dict\n responses = result.get(\"responses\", [])\n if not responses:\n return result\n\n # Convert BaseModel to dict (creates the \"objects\" key)\n first_response = responses[0]\n structured_data = first_response\n if isinstance(first_response, BaseModel):\n structured_data = first_response.model_dump()\n # Extract the objects array (guaranteed to exist due to our Pydantic model structure)\n return structured_data.get(\"objects\", structured_data)\n\n def build_structured_output(self) -> Data:\n output = self.build_structured_output_base()\n if not isinstance(output, list) or not output:\n # handle empty or unexpected type case\n msg = \"No structured output returned\"\n raise ValueError(msg)\n if len(output) == 1:\n return Data(data=output[0])\n if len(output) > 1:\n # Multiple outputs - wrap them in a results container\n return Data(data={\"results\": output})\n return Data()\n\n def build_structured_dataframe(self) -> DataFrame:\n output = self.build_structured_output_base()\n if not isinstance(output, list) or not output:\n # handle empty or unexpected type case\n msg = \"No structured output returned\"\n raise ValueError(msg)\n if len(output) == 1:\n # For single dictionary, wrap in a list to create DataFrame with one row\n return DataFrame([output[0]])\n if len(output) > 1:\n # Multiple outputs - convert to DataFrame directly\n return DataFrame(output)\n return DataFrame()\n\n def _extract_output_with_trustcall(self, llm, schema: BaseModel, config_dict: dict) -> list[BaseModel] | None:\n try:\n llm_with_structured_output = create_extractor(llm, tools=[schema], tool_choice=schema.__name__)\n result = get_chat_result(\n runnable=llm_with_structured_output,\n system_message=self.system_prompt,\n input_value=self.input_value,\n config=config_dict,\n )\n except Exception as e: # noqa: BLE001\n logger.warning(\n f\"Trustcall extraction failed, falling back to Langchain: {e} \"\n \"(Note: This may not be an error\u2014some models or configurations do not support tool calling. \"\n \"Falling back is normal in such cases.)\"\n )\n return None\n return result or None # langchain fallback is used if error occurs or the result is empty\n\n def _extract_output_with_langchain(self, llm, schema: BaseModel, config_dict: dict) -> list[BaseModel] | None:\n try:\n llm_with_structured_output = llm.with_structured_output(schema)\n result = get_chat_result(\n runnable=llm_with_structured_output,\n system_message=self.system_prompt,\n input_value=self.input_value,\n config=config_dict,\n )\n if isinstance(result, BaseModel):\n result = result.model_dump()\n result = result.get(\"objects\", result)\n except Exception as fallback_error:\n msg = (\n f\"Model does not support tool calling (trustcall failed) \"\n f\"and fallback with_structured_output also failed: {fallback_error}\"\n )\n raise ValueError(msg) from fallback_error\n\n return result or None\n"
|
|
1184
831
|
},
|
|
1185
832
|
"input_value": {
|
|
1186
833
|
"_input_type": "MultilineInput",
|