langflow-base-nightly 1.7.0.dev55__py3-none-any.whl → 1.7.0.dev57__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.
Files changed (38) hide show
  1. langflow/api/v2/files.py +6 -6
  2. langflow/initial_setup/starter_projects/Basic Prompt Chaining.json +31 -1088
  3. langflow/initial_setup/starter_projects/Basic Prompting.json +196 -135
  4. langflow/initial_setup/starter_projects/Blog Writer.json +141 -84
  5. langflow/initial_setup/starter_projects/Custom Component Generator.json +133 -73
  6. langflow/initial_setup/starter_projects/Document Q&A.json +136 -81
  7. langflow/initial_setup/starter_projects/Financial Report Parser.json +12 -365
  8. langflow/initial_setup/starter_projects/Hybrid Search RAG.json +19 -729
  9. langflow/initial_setup/starter_projects/Image Sentiment Analysis.json +688 -733
  10. langflow/initial_setup/starter_projects/Instagram Copywriter.json +322 -203
  11. langflow/initial_setup/starter_projects/Invoice Summarizer.json +47 -21
  12. langflow/initial_setup/starter_projects/Market Research.json +63 -394
  13. langflow/initial_setup/starter_projects/Meeting Summary.json +266 -168
  14. langflow/initial_setup/starter_projects/Memory Chatbot.json +136 -81
  15. langflow/initial_setup/starter_projects/News Aggregator.json +49 -24
  16. langflow/initial_setup/starter_projects/Nvidia Remix.json +48 -23
  17. langflow/initial_setup/starter_projects/Pok/303/251dex Agent.json" +49 -23
  18. langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json +113 -418
  19. langflow/initial_setup/starter_projects/Price Deal Finder.json +48 -22
  20. langflow/initial_setup/starter_projects/Research Agent.json +319 -181
  21. langflow/initial_setup/starter_projects/Research Translation Loop.json +636 -615
  22. langflow/initial_setup/starter_projects/SEO Keyword Generator.json +145 -89
  23. langflow/initial_setup/starter_projects/SaaS Pricing.json +48 -22
  24. langflow/initial_setup/starter_projects/Search agent.json +47 -21
  25. langflow/initial_setup/starter_projects/Sequential Tasks Agents.json +147 -54
  26. langflow/initial_setup/starter_projects/Simple Agent.json +47 -16
  27. langflow/initial_setup/starter_projects/Social Media Agent.json +47 -16
  28. langflow/initial_setup/starter_projects/Text Sentiment Analysis.json +398 -251
  29. langflow/initial_setup/starter_projects/Travel Planning Agents.json +146 -53
  30. langflow/initial_setup/starter_projects/Twitter Thread Generator.json +137 -81
  31. langflow/initial_setup/starter_projects/Vector Store RAG.json +133 -82
  32. langflow/initial_setup/starter_projects/Youtube Analysis.json +182 -106
  33. langflow/services/storage/local.py +13 -8
  34. langflow/services/storage/s3.py +0 -6
  35. {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev57.dist-info}/METADATA +2 -2
  36. {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev57.dist-info}/RECORD +38 -38
  37. {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev57.dist-info}/WHEEL +0 -0
  38. {langflow_base_nightly-1.7.0.dev55.dist-info → langflow_base_nightly-1.7.0.dev57.dist-info}/entry_points.txt +0 -0
@@ -24,12 +24,12 @@
24
24
  "type": "other"
25
25
  }
26
26
  },
27
- "id": "reactflow__edge-ParserComponent-NUETC{œdataTypeœ:œParserComponentœ,œidœ:œParserComponent-NUETCœ,œnameœ:œparsed_textœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-HTCA7{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-HTCA7œ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œotherœ}",
27
+ "id": "reactflow__edge-ParserComponent-NUETC{\u0153dataType\u0153:\u0153ParserComponent\u0153,\u0153id\u0153:\u0153ParserComponent-NUETC\u0153,\u0153name\u0153:\u0153parsed_text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-ChatOutput-HTCA7{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153ChatOutput-HTCA7\u0153,\u0153inputTypes\u0153:[\u0153Data\u0153,\u0153DataFrame\u0153,\u0153Message\u0153],\u0153type\u0153:\u0153other\u0153}",
28
28
  "selected": false,
29
29
  "source": "ParserComponent-NUETC",
30
- "sourceHandle": "{œdataTypeœ: œParserComponentœ, œidœ: œParserComponent-NUETCœ, œnameœ: œparsed_textœ, œoutput_typesœ: [œMessageœ]}",
30
+ "sourceHandle": "{\u0153dataType\u0153: \u0153ParserComponent\u0153, \u0153id\u0153: \u0153ParserComponent-NUETC\u0153, \u0153name\u0153: \u0153parsed_text\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
31
31
  "target": "ChatOutput-HTCA7",
32
- "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-HTCA7œ, œinputTypesœ: [œDataœ, œDataFrameœ, œMessageœ], œtypeœ: œotherœ}"
32
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153ChatOutput-HTCA7\u0153, \u0153inputTypes\u0153: [\u0153Data\u0153, \u0153DataFrame\u0153, \u0153Message\u0153], \u0153type\u0153: \u0153other\u0153}"
33
33
  },
34
34
  {
35
35
  "animated": false,
@@ -52,68 +52,12 @@
52
52
  "type": "query"
53
53
  }
54
54
  },
55
- "id": "reactflow__edge-ChatInput-RLI5m{œdataTypeœ:œChatInputœ,œidœ:œChatInput-RLI5mœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-AstraDB-u1JXb{œfieldNameœ:œsearch_queryœ,œidœ:œAstraDB-u1JXbœ,œinputTypesœ:[œMessageœ],œtypeœ:œqueryœ}",
55
+ "id": "reactflow__edge-ChatInput-RLI5m{\u0153dataType\u0153:\u0153ChatInput\u0153,\u0153id\u0153:\u0153ChatInput-RLI5m\u0153,\u0153name\u0153:\u0153message\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-AstraDB-u1JXb{\u0153fieldName\u0153:\u0153search_query\u0153,\u0153id\u0153:\u0153AstraDB-u1JXb\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153query\u0153}",
56
56
  "selected": false,
57
57
  "source": "ChatInput-RLI5m",
58
- "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-RLI5mœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
58
+ "sourceHandle": "{\u0153dataType\u0153: \u0153ChatInput\u0153, \u0153id\u0153: \u0153ChatInput-RLI5m\u0153, \u0153name\u0153: \u0153message\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
59
59
  "target": "AstraDB-u1JXb",
60
- "targetHandle": "{œfieldNameœ: œsearch_queryœ, œidœ: œAstraDB-u1JXbœ, œinputTypesœ: [œMessageœ], œtypeœ: œqueryœ}"
61
- },
62
- {
63
- "animated": false,
64
- "className": "",
65
- "data": {
66
- "sourceHandle": {
67
- "dataType": "LanguageModelComponent",
68
- "id": "LanguageModelComponent-aH5Bi",
69
- "name": "model_output",
70
- "output_types": [
71
- "LanguageModel"
72
- ]
73
- },
74
- "targetHandle": {
75
- "fieldName": "llm",
76
- "id": "StructuredOutput-MyXBb",
77
- "inputTypes": [
78
- "LanguageModel"
79
- ],
80
- "type": "other"
81
- }
82
- },
83
- "id": "reactflow__edge-LanguageModelComponent-aH5Bi{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-aH5Biœ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutput-MyXBb{œfieldNameœ:œllmœ,œidœ:œStructuredOutput-MyXBbœ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}",
84
- "selected": false,
85
- "source": "LanguageModelComponent-aH5Bi",
86
- "sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-aH5Biœ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}",
87
- "target": "StructuredOutput-MyXBb",
88
- "targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutput-MyXBbœ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}"
89
- },
90
- {
91
- "animated": false,
92
- "className": "",
93
- "data": {
94
- "sourceHandle": {
95
- "dataType": "LanguageModelComponent",
96
- "id": "LanguageModelComponent-WUfVa",
97
- "name": "text_output",
98
- "output_types": [
99
- "Message"
100
- ]
101
- },
102
- "targetHandle": {
103
- "fieldName": "system_prompt",
104
- "id": "StructuredOutput-MyXBb",
105
- "inputTypes": [
106
- "Message"
107
- ],
108
- "type": "str"
109
- }
110
- },
111
- "id": "reactflow__edge-LanguageModelComponent-WUfVa{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-WUfVaœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-StructuredOutput-MyXBb{œfieldNameœ:œsystem_promptœ,œidœ:œStructuredOutput-MyXBbœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
112
- "selected": false,
113
- "source": "LanguageModelComponent-WUfVa",
114
- "sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-WUfVaœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}",
115
- "target": "StructuredOutput-MyXBb",
116
- "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œStructuredOutput-MyXBbœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
60
+ "targetHandle": "{\u0153fieldName\u0153: \u0153search_query\u0153, \u0153id\u0153: \u0153AstraDB-u1JXb\u0153, \u0153inputTypes\u0153: [\u0153Message\u0153], \u0153type\u0153: \u0153query\u0153}"
117
61
  },
118
62
  {
119
63
  "animated": false,
@@ -136,12 +80,12 @@
136
80
  "type": "str"
137
81
  }
138
82
  },
139
- "id": "reactflow__edge-ChatInput-RLI5m{œdataTypeœ:œChatInputœ,œidœ:œChatInput-RLI5mœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-StructuredOutput-MyXBb{œfieldNameœ:œinput_valueœ,œidœ:œStructuredOutput-MyXBbœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
83
+ "id": "reactflow__edge-ChatInput-RLI5m{\u0153dataType\u0153:\u0153ChatInput\u0153,\u0153id\u0153:\u0153ChatInput-RLI5m\u0153,\u0153name\u0153:\u0153message\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-StructuredOutput-MyXBb{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153StructuredOutput-MyXBb\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
140
84
  "selected": false,
141
85
  "source": "ChatInput-RLI5m",
142
- "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-RLI5mœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
86
+ "sourceHandle": "{\u0153dataType\u0153: \u0153ChatInput\u0153, \u0153id\u0153: \u0153ChatInput-RLI5m\u0153, \u0153name\u0153: \u0153message\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
143
87
  "target": "StructuredOutput-MyXBb",
144
- "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œStructuredOutput-MyXBbœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
88
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153StructuredOutput-MyXBb\u0153, \u0153inputTypes\u0153: [\u0153Message\u0153], \u0153type\u0153: \u0153str\u0153}"
145
89
  },
146
90
  {
147
91
  "animated": false,
@@ -165,12 +109,12 @@
165
109
  "type": "other"
166
110
  }
167
111
  },
168
- "id": "reactflow__edge-StructuredOutput-MyXBb{œdataTypeœ:œStructuredOutputœ,œidœ:œStructuredOutput-MyXBbœ,œnameœ:œdataframe_outputœ,œoutput_typesœ:[œDataFrameœ]}-ParserComponent-HTPnn{œfieldNameœ:œinput_dataœ,œidœ:œParserComponent-HTPnnœ,œinputTypesœ:[œDataFrameœ,œDataœ],œtypeœ:œotherœ}",
112
+ "id": "reactflow__edge-StructuredOutput-MyXBb{\u0153dataType\u0153:\u0153StructuredOutput\u0153,\u0153id\u0153:\u0153StructuredOutput-MyXBb\u0153,\u0153name\u0153:\u0153dataframe_output\u0153,\u0153output_types\u0153:[\u0153DataFrame\u0153]}-ParserComponent-HTPnn{\u0153fieldName\u0153:\u0153input_data\u0153,\u0153id\u0153:\u0153ParserComponent-HTPnn\u0153,\u0153inputTypes\u0153:[\u0153DataFrame\u0153,\u0153Data\u0153],\u0153type\u0153:\u0153other\u0153}",
169
113
  "selected": false,
170
114
  "source": "StructuredOutput-MyXBb",
171
- "sourceHandle": "{œdataTypeœ: œStructuredOutputœ, œidœ: œStructuredOutput-MyXBbœ, œnameœ: œdataframe_outputœ, œoutput_typesœ: [œDataFrameœ]}",
115
+ "sourceHandle": "{\u0153dataType\u0153: \u0153StructuredOutput\u0153, \u0153id\u0153: \u0153StructuredOutput-MyXBb\u0153, \u0153name\u0153: \u0153dataframe_output\u0153, \u0153output_types\u0153: [\u0153DataFrame\u0153]}",
172
116
  "target": "ParserComponent-HTPnn",
173
- "targetHandle": "{œfieldNameœ: œinput_dataœ, œidœ: œParserComponent-HTPnnœ, œinputTypesœ: [œDataFrameœ, œDataœ], œtypeœ: œotherœ}"
117
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_data\u0153, \u0153id\u0153: \u0153ParserComponent-HTPnn\u0153, \u0153inputTypes\u0153: [\u0153DataFrame\u0153, \u0153Data\u0153], \u0153type\u0153: \u0153other\u0153}"
174
118
  },
175
119
  {
176
120
  "animated": false,
@@ -193,12 +137,12 @@
193
137
  "type": "query"
194
138
  }
195
139
  },
196
- "id": "xy-edge__ParserComponent-HTPnn{œdataTypeœ:œParserComponentœ,œidœ:œParserComponent-HTPnnœ,œnameœ:œparsed_textœ,œoutput_typesœ:[œMessageœ]}-AstraDB-u1JXb{œfieldNameœ:œlexical_termsœ,œidœ:œAstraDB-u1JXbœ,œinputTypesœ:[œMessageœ],œtypeœ:œqueryœ}",
140
+ "id": "xy-edge__ParserComponent-HTPnn{\u0153dataType\u0153:\u0153ParserComponent\u0153,\u0153id\u0153:\u0153ParserComponent-HTPnn\u0153,\u0153name\u0153:\u0153parsed_text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-AstraDB-u1JXb{\u0153fieldName\u0153:\u0153lexical_terms\u0153,\u0153id\u0153:\u0153AstraDB-u1JXb\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153query\u0153}",
197
141
  "selected": false,
198
142
  "source": "ParserComponent-HTPnn",
199
- "sourceHandle": "{œdataTypeœ: œParserComponentœ, œidœ: œParserComponent-HTPnnœ, œnameœ: œparsed_textœ, œoutput_typesœ: [œMessageœ]}",
143
+ "sourceHandle": "{\u0153dataType\u0153: \u0153ParserComponent\u0153, \u0153id\u0153: \u0153ParserComponent-HTPnn\u0153, \u0153name\u0153: \u0153parsed_text\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
200
144
  "target": "AstraDB-u1JXb",
201
- "targetHandle": "{œfieldNameœ: œlexical_termsœ, œidœ: œAstraDB-u1JXbœ, œinputTypesœ: [œMessageœ], œtypeœ: œqueryœ}"
145
+ "targetHandle": "{\u0153fieldName\u0153: \u0153lexical_terms\u0153, \u0153id\u0153: \u0153AstraDB-u1JXb\u0153, \u0153inputTypes\u0153: [\u0153Message\u0153], \u0153type\u0153: \u0153query\u0153}"
202
146
  },
203
147
  {
204
148
  "animated": false,
@@ -222,12 +166,12 @@
222
166
  "type": "other"
223
167
  }
224
168
  },
225
- "id": "xy-edge__AstraDB-u1JXb{œdataTypeœ:œAstraDBœ,œidœ:œAstraDB-u1JXbœ,œnameœ:œdataframeœ,œoutput_typesœ:[œDataFrameœ]}-ParserComponent-NUETC{œfieldNameœ:œinput_dataœ,œidœ:œParserComponent-NUETCœ,œinputTypesœ:[œDataFrameœ,œDataœ],œtypeœ:œotherœ}",
169
+ "id": "xy-edge__AstraDB-u1JXb{\u0153dataType\u0153:\u0153AstraDB\u0153,\u0153id\u0153:\u0153AstraDB-u1JXb\u0153,\u0153name\u0153:\u0153dataframe\u0153,\u0153output_types\u0153:[\u0153DataFrame\u0153]}-ParserComponent-NUETC{\u0153fieldName\u0153:\u0153input_data\u0153,\u0153id\u0153:\u0153ParserComponent-NUETC\u0153,\u0153inputTypes\u0153:[\u0153DataFrame\u0153,\u0153Data\u0153],\u0153type\u0153:\u0153other\u0153}",
226
170
  "selected": false,
227
171
  "source": "AstraDB-u1JXb",
228
- "sourceHandle": "{œdataTypeœ: œAstraDBœ, œidœ: œAstraDB-u1JXbœ, œnameœ: œdataframeœ, œoutput_typesœ: [œDataFrameœ]}",
172
+ "sourceHandle": "{\u0153dataType\u0153: \u0153AstraDB\u0153, \u0153id\u0153: \u0153AstraDB-u1JXb\u0153, \u0153name\u0153: \u0153dataframe\u0153, \u0153output_types\u0153: [\u0153DataFrame\u0153]}",
229
173
  "target": "ParserComponent-NUETC",
230
- "targetHandle": "{œfieldNameœ: œinput_dataœ, œidœ: œParserComponent-NUETCœ, œinputTypesœ: [œDataFrameœ, œDataœ], œtypeœ: œotherœ}"
174
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_data\u0153, \u0153id\u0153: \u0153ParserComponent-NUETC\u0153, \u0153inputTypes\u0153: [\u0153DataFrame\u0153, \u0153Data\u0153], \u0153type\u0153: \u0153other\u0153}"
231
175
  }
232
176
  ],
233
177
  "nodes": [
@@ -1162,660 +1106,6 @@
1162
1106
  "selected": false,
1163
1107
  "type": "genericNode"
1164
1108
  },
1165
- {
1166
- "data": {
1167
- "id": "LanguageModelComponent-WUfVa",
1168
- "node": {
1169
- "base_classes": [
1170
- "LanguageModel",
1171
- "Message"
1172
- ],
1173
- "beta": false,
1174
- "conditional_paths": [],
1175
- "custom_fields": {},
1176
- "description": "Runs a language model given a specified provider.",
1177
- "display_name": "Language Model",
1178
- "documentation": "",
1179
- "edited": false,
1180
- "field_order": [
1181
- "provider",
1182
- "model_name",
1183
- "api_key",
1184
- "input_value",
1185
- "system_message",
1186
- "stream",
1187
- "temperature"
1188
- ],
1189
- "frozen": false,
1190
- "icon": "brain-circuit",
1191
- "last_updated": "2025-09-29T15:15:43.053Z",
1192
- "legacy": false,
1193
- "lf_version": "1.6.0",
1194
- "metadata": {
1195
- "code_hash": "bb5f8714781b",
1196
- "dependencies": {
1197
- "dependencies": [
1198
- {
1199
- "name": "langchain_anthropic",
1200
- "version": "0.3.14"
1201
- },
1202
- {
1203
- "name": "langchain_google_genai",
1204
- "version": "2.0.6"
1205
- },
1206
- {
1207
- "name": "langchain_openai",
1208
- "version": "0.3.23"
1209
- },
1210
- {
1211
- "name": "lfx",
1212
- "version": null
1213
- }
1214
- ],
1215
- "total_dependencies": 4
1216
- },
1217
- "keywords": [
1218
- "model",
1219
- "llm",
1220
- "language model",
1221
- "large language model"
1222
- ],
1223
- "module": "lfx.components.models.language_model.LanguageModelComponent"
1224
- },
1225
- "minimized": false,
1226
- "output_types": [],
1227
- "outputs": [
1228
- {
1229
- "allows_loop": false,
1230
- "cache": true,
1231
- "display_name": "Model Response",
1232
- "group_outputs": false,
1233
- "method": "text_response",
1234
- "name": "text_output",
1235
- "options": null,
1236
- "required_inputs": null,
1237
- "selected": "Message",
1238
- "tool_mode": true,
1239
- "types": [
1240
- "Message"
1241
- ],
1242
- "value": "__UNDEFINED__"
1243
- },
1244
- {
1245
- "allows_loop": false,
1246
- "cache": true,
1247
- "display_name": "Language Model",
1248
- "group_outputs": false,
1249
- "method": "build_model",
1250
- "name": "model_output",
1251
- "options": null,
1252
- "required_inputs": null,
1253
- "selected": "LanguageModel",
1254
- "tool_mode": true,
1255
- "types": [
1256
- "LanguageModel"
1257
- ],
1258
- "value": "__UNDEFINED__"
1259
- }
1260
- ],
1261
- "pinned": false,
1262
- "priority": 0,
1263
- "template": {
1264
- "_type": "Component",
1265
- "api_key": {
1266
- "_input_type": "SecretStrInput",
1267
- "advanced": false,
1268
- "display_name": "OpenAI API Key",
1269
- "dynamic": false,
1270
- "info": "Model Provider API key",
1271
- "input_types": [],
1272
- "load_from_db": true,
1273
- "name": "api_key",
1274
- "password": true,
1275
- "placeholder": "",
1276
- "real_time_refresh": true,
1277
- "required": false,
1278
- "show": true,
1279
- "title_case": false,
1280
- "type": "str",
1281
- "value": "OPENAI_API_KEY"
1282
- },
1283
- "code": {
1284
- "advanced": true,
1285
- "dynamic": true,
1286
- "fileTypes": [],
1287
- "file_path": "",
1288
- "info": "",
1289
- "list": false,
1290
- "load_from_db": false,
1291
- "multiline": true,
1292
- "name": "code",
1293
- "password": false,
1294
- "placeholder": "",
1295
- "required": true,
1296
- "show": true,
1297
- "title_case": false,
1298
- "type": "code",
1299
- "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"
1300
- },
1301
- "input_value": {
1302
- "_input_type": "MessageInput",
1303
- "advanced": false,
1304
- "display_name": "Input",
1305
- "dynamic": false,
1306
- "info": "The input text to send to the model",
1307
- "input_types": [
1308
- "Message"
1309
- ],
1310
- "list": false,
1311
- "list_add_label": "Add More",
1312
- "load_from_db": false,
1313
- "name": "input_value",
1314
- "placeholder": "",
1315
- "required": false,
1316
- "show": true,
1317
- "title_case": false,
1318
- "tool_mode": false,
1319
- "trace_as_input": true,
1320
- "trace_as_metadata": true,
1321
- "type": "str",
1322
- "value": "You are an AI system designed to extract structured information from unstructured text.Given the input_text, return a JSON object with predefined keys based on the expected structure.Extract values accurately and format them according to the specified type (e.g., string, integer, float, date).If a value is missing or cannot be determined, return a default (e.g., null, 0, or 'N/A').If multiple instances of the expected structure exist within the input_text, stream each as a separate JSON object."
1323
- },
1324
- "model_name": {
1325
- "_input_type": "DropdownInput",
1326
- "advanced": false,
1327
- "combobox": false,
1328
- "dialog_inputs": {},
1329
- "display_name": "Model Name",
1330
- "dynamic": false,
1331
- "info": "Select the model to use",
1332
- "name": "model_name",
1333
- "options": [
1334
- "gpt-4o-mini",
1335
- "gpt-4o",
1336
- "gpt-4.1",
1337
- "gpt-4.1-mini",
1338
- "gpt-4.1-nano",
1339
- "gpt-4-turbo",
1340
- "gpt-4-turbo-preview",
1341
- "gpt-4",
1342
- "gpt-3.5-turbo",
1343
- "gpt-5",
1344
- "gpt-5-mini",
1345
- "gpt-5-nano",
1346
- "gpt-5-chat-latest",
1347
- "o1",
1348
- "o3-mini",
1349
- "o3",
1350
- "o3-pro",
1351
- "o4-mini",
1352
- "o4-mini-high"
1353
- ],
1354
- "options_metadata": [],
1355
- "placeholder": "",
1356
- "required": false,
1357
- "show": true,
1358
- "title_case": false,
1359
- "toggle": false,
1360
- "tool_mode": false,
1361
- "trace_as_metadata": true,
1362
- "type": "str",
1363
- "value": "gpt-4o-mini"
1364
- },
1365
- "provider": {
1366
- "_input_type": "DropdownInput",
1367
- "advanced": false,
1368
- "combobox": false,
1369
- "dialog_inputs": {},
1370
- "display_name": "Model Provider",
1371
- "dynamic": false,
1372
- "info": "Select the model provider",
1373
- "name": "provider",
1374
- "options": [
1375
- "OpenAI",
1376
- "Anthropic",
1377
- "Google"
1378
- ],
1379
- "options_metadata": [
1380
- {
1381
- "icon": "OpenAI"
1382
- },
1383
- {
1384
- "icon": "Anthropic"
1385
- },
1386
- {
1387
- "icon": "Google"
1388
- }
1389
- ],
1390
- "placeholder": "",
1391
- "real_time_refresh": true,
1392
- "required": false,
1393
- "show": true,
1394
- "title_case": false,
1395
- "toggle": false,
1396
- "tool_mode": false,
1397
- "trace_as_metadata": true,
1398
- "type": "str",
1399
- "value": "OpenAI"
1400
- },
1401
- "stream": {
1402
- "_input_type": "BoolInput",
1403
- "advanced": true,
1404
- "display_name": "Stream",
1405
- "dynamic": false,
1406
- "info": "Whether to stream the response",
1407
- "list": false,
1408
- "list_add_label": "Add More",
1409
- "name": "stream",
1410
- "placeholder": "",
1411
- "required": false,
1412
- "show": true,
1413
- "title_case": false,
1414
- "tool_mode": false,
1415
- "trace_as_metadata": true,
1416
- "type": "bool",
1417
- "value": false
1418
- },
1419
- "system_message": {
1420
- "_input_type": "MultilineInput",
1421
- "advanced": true,
1422
- "copy_field": false,
1423
- "display_name": "System Message",
1424
- "dynamic": false,
1425
- "info": "A system message that helps set the behavior of the assistant",
1426
- "input_types": [
1427
- "Message"
1428
- ],
1429
- "list": false,
1430
- "list_add_label": "Add More",
1431
- "load_from_db": false,
1432
- "multiline": true,
1433
- "name": "system_message",
1434
- "placeholder": "",
1435
- "required": false,
1436
- "show": true,
1437
- "title_case": false,
1438
- "tool_mode": false,
1439
- "trace_as_input": true,
1440
- "trace_as_metadata": true,
1441
- "type": "str",
1442
- "value": ""
1443
- },
1444
- "temperature": {
1445
- "_input_type": "SliderInput",
1446
- "advanced": true,
1447
- "display_name": "Temperature",
1448
- "dynamic": false,
1449
- "info": "Controls randomness in responses",
1450
- "max_label": "",
1451
- "max_label_icon": "",
1452
- "min_label": "",
1453
- "min_label_icon": "",
1454
- "name": "temperature",
1455
- "placeholder": "",
1456
- "range_spec": {
1457
- "max": 1,
1458
- "min": 0,
1459
- "step": 0.01,
1460
- "step_type": "float"
1461
- },
1462
- "required": false,
1463
- "show": true,
1464
- "slider_buttons": false,
1465
- "slider_buttons_options": [],
1466
- "slider_input": false,
1467
- "title_case": false,
1468
- "tool_mode": false,
1469
- "type": "slider",
1470
- "value": 0.1
1471
- }
1472
- },
1473
- "tool_mode": false
1474
- },
1475
- "selected_output": "text_output",
1476
- "showNode": true,
1477
- "type": "LanguageModelComponent"
1478
- },
1479
- "dragging": false,
1480
- "id": "LanguageModelComponent-WUfVa",
1481
- "measured": {
1482
- "height": 451,
1483
- "width": 320
1484
- },
1485
- "position": {
1486
- "x": 320.756607335245,
1487
- "y": 486.0770655861057
1488
- },
1489
- "selected": false,
1490
- "type": "genericNode"
1491
- },
1492
- {
1493
- "data": {
1494
- "id": "LanguageModelComponent-aH5Bi",
1495
- "node": {
1496
- "base_classes": [
1497
- "LanguageModel",
1498
- "Message"
1499
- ],
1500
- "beta": false,
1501
- "conditional_paths": [],
1502
- "custom_fields": {},
1503
- "description": "Runs a language model given a specified provider.",
1504
- "display_name": "Language Model",
1505
- "documentation": "",
1506
- "edited": false,
1507
- "field_order": [
1508
- "provider",
1509
- "model_name",
1510
- "api_key",
1511
- "input_value",
1512
- "system_message",
1513
- "stream",
1514
- "temperature"
1515
- ],
1516
- "frozen": false,
1517
- "icon": "brain-circuit",
1518
- "last_updated": "2025-09-29T15:15:43.054Z",
1519
- "legacy": false,
1520
- "lf_version": "1.6.0",
1521
- "metadata": {
1522
- "code_hash": "bb5f8714781b",
1523
- "dependencies": {
1524
- "dependencies": [
1525
- {
1526
- "name": "langchain_anthropic",
1527
- "version": "0.3.14"
1528
- },
1529
- {
1530
- "name": "langchain_google_genai",
1531
- "version": "2.0.6"
1532
- },
1533
- {
1534
- "name": "langchain_openai",
1535
- "version": "0.3.23"
1536
- },
1537
- {
1538
- "name": "lfx",
1539
- "version": null
1540
- }
1541
- ],
1542
- "total_dependencies": 4
1543
- },
1544
- "keywords": [
1545
- "model",
1546
- "llm",
1547
- "language model",
1548
- "large language model"
1549
- ],
1550
- "module": "lfx.components.models.language_model.LanguageModelComponent"
1551
- },
1552
- "minimized": false,
1553
- "output_types": [],
1554
- "outputs": [
1555
- {
1556
- "allows_loop": false,
1557
- "cache": true,
1558
- "display_name": "Model Response",
1559
- "group_outputs": false,
1560
- "method": "text_response",
1561
- "name": "text_output",
1562
- "options": null,
1563
- "required_inputs": null,
1564
- "selected": "Message",
1565
- "tool_mode": true,
1566
- "types": [
1567
- "Message"
1568
- ],
1569
- "value": "__UNDEFINED__"
1570
- },
1571
- {
1572
- "allows_loop": false,
1573
- "cache": true,
1574
- "display_name": "Language Model",
1575
- "group_outputs": false,
1576
- "method": "build_model",
1577
- "name": "model_output",
1578
- "options": null,
1579
- "required_inputs": null,
1580
- "selected": "LanguageModel",
1581
- "tool_mode": true,
1582
- "types": [
1583
- "LanguageModel"
1584
- ],
1585
- "value": "__UNDEFINED__"
1586
- }
1587
- ],
1588
- "pinned": false,
1589
- "priority": 0,
1590
- "template": {
1591
- "_type": "Component",
1592
- "api_key": {
1593
- "_input_type": "SecretStrInput",
1594
- "advanced": false,
1595
- "display_name": "OpenAI API Key",
1596
- "dynamic": false,
1597
- "info": "Model Provider API key",
1598
- "input_types": [],
1599
- "load_from_db": true,
1600
- "name": "api_key",
1601
- "password": true,
1602
- "placeholder": "",
1603
- "real_time_refresh": true,
1604
- "required": false,
1605
- "show": true,
1606
- "title_case": false,
1607
- "type": "str",
1608
- "value": "OPENAI_API_KEY"
1609
- },
1610
- "code": {
1611
- "advanced": true,
1612
- "dynamic": true,
1613
- "fileTypes": [],
1614
- "file_path": "",
1615
- "info": "",
1616
- "list": false,
1617
- "load_from_db": false,
1618
- "multiline": true,
1619
- "name": "code",
1620
- "password": false,
1621
- "placeholder": "",
1622
- "required": true,
1623
- "show": true,
1624
- "title_case": false,
1625
- "type": "code",
1626
- "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"
1627
- },
1628
- "input_value": {
1629
- "_input_type": "MessageInput",
1630
- "advanced": false,
1631
- "display_name": "Input",
1632
- "dynamic": false,
1633
- "info": "The input text to send to the model",
1634
- "input_types": [
1635
- "Message"
1636
- ],
1637
- "list": false,
1638
- "list_add_label": "Add More",
1639
- "load_from_db": false,
1640
- "name": "input_value",
1641
- "placeholder": "",
1642
- "required": false,
1643
- "show": true,
1644
- "title_case": false,
1645
- "tool_mode": false,
1646
- "trace_as_input": true,
1647
- "trace_as_metadata": true,
1648
- "type": "str",
1649
- "value": ""
1650
- },
1651
- "model_name": {
1652
- "_input_type": "DropdownInput",
1653
- "advanced": false,
1654
- "combobox": false,
1655
- "dialog_inputs": {},
1656
- "display_name": "Model Name",
1657
- "dynamic": false,
1658
- "info": "Select the model to use",
1659
- "name": "model_name",
1660
- "options": [
1661
- "gpt-4o-mini",
1662
- "gpt-4o",
1663
- "gpt-4.1",
1664
- "gpt-4.1-mini",
1665
- "gpt-4.1-nano",
1666
- "gpt-4-turbo",
1667
- "gpt-4-turbo-preview",
1668
- "gpt-4",
1669
- "gpt-3.5-turbo",
1670
- "gpt-5",
1671
- "gpt-5-mini",
1672
- "gpt-5-nano",
1673
- "gpt-5-chat-latest",
1674
- "o1",
1675
- "o3-mini",
1676
- "o3",
1677
- "o3-pro",
1678
- "o4-mini",
1679
- "o4-mini-high"
1680
- ],
1681
- "options_metadata": [],
1682
- "placeholder": "",
1683
- "required": false,
1684
- "show": true,
1685
- "title_case": false,
1686
- "toggle": false,
1687
- "tool_mode": false,
1688
- "trace_as_metadata": true,
1689
- "type": "str",
1690
- "value": "gpt-4o-mini"
1691
- },
1692
- "provider": {
1693
- "_input_type": "DropdownInput",
1694
- "advanced": false,
1695
- "combobox": false,
1696
- "dialog_inputs": {},
1697
- "display_name": "Model Provider",
1698
- "dynamic": false,
1699
- "info": "Select the model provider",
1700
- "name": "provider",
1701
- "options": [
1702
- "OpenAI",
1703
- "Anthropic",
1704
- "Google"
1705
- ],
1706
- "options_metadata": [
1707
- {
1708
- "icon": "OpenAI"
1709
- },
1710
- {
1711
- "icon": "Anthropic"
1712
- },
1713
- {
1714
- "icon": "Google"
1715
- }
1716
- ],
1717
- "placeholder": "",
1718
- "real_time_refresh": true,
1719
- "required": false,
1720
- "show": true,
1721
- "title_case": false,
1722
- "toggle": false,
1723
- "tool_mode": false,
1724
- "trace_as_metadata": true,
1725
- "type": "str",
1726
- "value": "OpenAI"
1727
- },
1728
- "stream": {
1729
- "_input_type": "BoolInput",
1730
- "advanced": true,
1731
- "display_name": "Stream",
1732
- "dynamic": false,
1733
- "info": "Whether to stream the response",
1734
- "list": false,
1735
- "list_add_label": "Add More",
1736
- "name": "stream",
1737
- "placeholder": "",
1738
- "required": false,
1739
- "show": true,
1740
- "title_case": false,
1741
- "tool_mode": false,
1742
- "trace_as_metadata": true,
1743
- "type": "bool",
1744
- "value": false
1745
- },
1746
- "system_message": {
1747
- "_input_type": "MultilineInput",
1748
- "advanced": true,
1749
- "copy_field": false,
1750
- "display_name": "System Message",
1751
- "dynamic": false,
1752
- "info": "A system message that helps set the behavior of the assistant",
1753
- "input_types": [
1754
- "Message"
1755
- ],
1756
- "list": false,
1757
- "list_add_label": "Add More",
1758
- "load_from_db": false,
1759
- "multiline": true,
1760
- "name": "system_message",
1761
- "placeholder": "",
1762
- "required": false,
1763
- "show": true,
1764
- "title_case": false,
1765
- "tool_mode": false,
1766
- "trace_as_input": true,
1767
- "trace_as_metadata": true,
1768
- "type": "str",
1769
- "value": ""
1770
- },
1771
- "temperature": {
1772
- "_input_type": "SliderInput",
1773
- "advanced": true,
1774
- "display_name": "Temperature",
1775
- "dynamic": false,
1776
- "info": "Controls randomness in responses",
1777
- "max_label": "",
1778
- "max_label_icon": "",
1779
- "min_label": "",
1780
- "min_label_icon": "",
1781
- "name": "temperature",
1782
- "placeholder": "",
1783
- "range_spec": {
1784
- "max": 1,
1785
- "min": 0,
1786
- "step": 0.01,
1787
- "step_type": "float"
1788
- },
1789
- "required": false,
1790
- "show": true,
1791
- "slider_buttons": false,
1792
- "slider_buttons_options": [],
1793
- "slider_input": false,
1794
- "title_case": false,
1795
- "tool_mode": false,
1796
- "type": "slider",
1797
- "value": 0.1
1798
- }
1799
- },
1800
- "tool_mode": false
1801
- },
1802
- "selected_output": "model_output",
1803
- "showNode": true,
1804
- "type": "LanguageModelComponent"
1805
- },
1806
- "dragging": false,
1807
- "id": "LanguageModelComponent-aH5Bi",
1808
- "measured": {
1809
- "height": 451,
1810
- "width": 320
1811
- },
1812
- "position": {
1813
- "x": 322.5971643968167,
1814
- "y": -36.64113990031162
1815
- },
1816
- "selected": false,
1817
- "type": "genericNode"
1818
- },
1819
1109
  {
1820
1110
  "data": {
1821
1111
  "id": "note-jle0B",
@@ -2786,7 +2076,7 @@
2786
2076
  "show": true,
2787
2077
  "title_case": false,
2788
2078
  "type": "code",
2789
- "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"
2079
+ "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"
2790
2080
  },
2791
2081
  "input_value": {
2792
2082
  "_input_type": "MultilineInput",