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
@@ -22,12 +22,12 @@
22
22
  "type": "other"
23
23
  }
24
24
  },
25
- "id": "reactflow__edge-TavilySearchComponent-3WTYa{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-3WTYaœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-Hz2it{œfieldNameœ:œtoolsœ,œidœ:œAgent-Hz2itœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}",
25
+ "id": "reactflow__edge-TavilySearchComponent-3WTYa{\u0153dataType\u0153:\u0153TavilySearchComponent\u0153,\u0153id\u0153:\u0153TavilySearchComponent-3WTYa\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}-Agent-Hz2it{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Hz2it\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}",
26
26
  "selected": false,
27
27
  "source": "TavilySearchComponent-3WTYa",
28
- "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-3WTYaœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}",
28
+ "sourceHandle": "{\u0153dataType\u0153: \u0153TavilySearchComponent\u0153, \u0153id\u0153: \u0153TavilySearchComponent-3WTYa\u0153, \u0153name\u0153: \u0153component_as_tool\u0153, \u0153output_types\u0153: [\u0153Tool\u0153]}",
29
29
  "target": "Agent-Hz2it",
30
- "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-Hz2itœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}"
30
+ "targetHandle": "{\u0153fieldName\u0153: \u0153tools\u0153, \u0153id\u0153: \u0153Agent-Hz2it\u0153, \u0153inputTypes\u0153: [\u0153Tool\u0153], \u0153type\u0153: \u0153other\u0153}"
31
31
  },
32
32
  {
33
33
  "animated": false,
@@ -50,12 +50,12 @@
50
50
  "type": "str"
51
51
  }
52
52
  },
53
- "id": "reactflow__edge-ChatInput-OSw5o{œdataTypeœ:œChatInputœ,œidœ:œChatInput-OSw5oœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-Hz2it{œfieldNameœ:œinput_valueœ,œidœ:œAgent-Hz2itœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
53
+ "id": "reactflow__edge-ChatInput-OSw5o{\u0153dataType\u0153:\u0153ChatInput\u0153,\u0153id\u0153:\u0153ChatInput-OSw5o\u0153,\u0153name\u0153:\u0153message\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-Agent-Hz2it{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153Agent-Hz2it\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
54
54
  "selected": false,
55
55
  "source": "ChatInput-OSw5o",
56
- "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-OSw5oœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
56
+ "sourceHandle": "{\u0153dataType\u0153: \u0153ChatInput\u0153, \u0153id\u0153: \u0153ChatInput-OSw5o\u0153, \u0153name\u0153: \u0153message\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
57
57
  "target": "Agent-Hz2it",
58
- "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-Hz2itœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
58
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153Agent-Hz2it\u0153, \u0153inputTypes\u0153: [\u0153Message\u0153], \u0153type\u0153: \u0153str\u0153}"
59
59
  },
60
60
  {
61
61
  "animated": false,
@@ -80,12 +80,12 @@
80
80
  "type": "str"
81
81
  }
82
82
  },
83
- "id": "xy-edge__ParserComponent-8lfAE{œdataTypeœ:œParserComponentœ,œidœ:œParserComponent-8lfAEœ,œnameœ:œparsed_textœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-tjFWM{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-tjFWMœ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œstrœ}",
83
+ "id": "xy-edge__ParserComponent-8lfAE{\u0153dataType\u0153:\u0153ParserComponent\u0153,\u0153id\u0153:\u0153ParserComponent-8lfAE\u0153,\u0153name\u0153:\u0153parsed_text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-ChatOutput-tjFWM{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153ChatOutput-tjFWM\u0153,\u0153inputTypes\u0153:[\u0153Data\u0153,\u0153DataFrame\u0153,\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
84
84
  "selected": false,
85
85
  "source": "ParserComponent-8lfAE",
86
- "sourceHandle": "{œdataTypeœ: œParserComponentœ, œidœ: œParserComponent-8lfAEœ, œnameœ: œparsed_textœ, œoutput_typesœ: [œMessageœ]}",
86
+ "sourceHandle": "{\u0153dataType\u0153: \u0153ParserComponent\u0153, \u0153id\u0153: \u0153ParserComponent-8lfAE\u0153, \u0153name\u0153: \u0153parsed_text\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
87
87
  "target": "ChatOutput-tjFWM",
88
- "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-tjFWMœ, œinputTypesœ: [œDataœ, œDataFrameœ, œMessageœ], œtypeœ: œstrœ}"
88
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153ChatOutput-tjFWM\u0153, \u0153inputTypes\u0153: [\u0153Data\u0153, \u0153DataFrame\u0153, \u0153Message\u0153], \u0153type\u0153: \u0153str\u0153}"
89
89
  },
90
90
  {
91
91
  "animated": false,
@@ -108,40 +108,12 @@
108
108
  "type": "str"
109
109
  }
110
110
  },
111
- "id": "xy-edge__Agent-Hz2it{œdataTypeœ:œAgentœ,œidœ:œAgent-Hz2itœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-StructuredOutput-zfjb9{œfieldNameœ:œinput_valueœ,œidœ:œStructuredOutput-zfjb9œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
111
+ "id": "xy-edge__Agent-Hz2it{\u0153dataType\u0153:\u0153Agent\u0153,\u0153id\u0153:\u0153Agent-Hz2it\u0153,\u0153name\u0153:\u0153response\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-StructuredOutput-zfjb9{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153StructuredOutput-zfjb9\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
112
112
  "selected": false,
113
113
  "source": "Agent-Hz2it",
114
- "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-Hz2itœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}",
114
+ "sourceHandle": "{\u0153dataType\u0153: \u0153Agent\u0153, \u0153id\u0153: \u0153Agent-Hz2it\u0153, \u0153name\u0153: \u0153response\u0153, \u0153output_types\u0153: [\u0153Message\u0153]}",
115
115
  "target": "StructuredOutput-zfjb9",
116
- "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œStructuredOutput-zfjb9œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
117
- },
118
- {
119
- "animated": false,
120
- "className": "",
121
- "data": {
122
- "sourceHandle": {
123
- "dataType": "LanguageModelComponent",
124
- "id": "LanguageModelComponent-Enuj5",
125
- "name": "model_output",
126
- "output_types": [
127
- "LanguageModel"
128
- ]
129
- },
130
- "targetHandle": {
131
- "fieldName": "llm",
132
- "id": "StructuredOutput-zfjb9",
133
- "inputTypes": [
134
- "LanguageModel"
135
- ],
136
- "type": "other"
137
- }
138
- },
139
- "id": "xy-edge__LanguageModelComponent-Enuj5{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-Enuj5œ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutput-zfjb9{œfieldNameœ:œllmœ,œidœ:œStructuredOutput-zfjb9œ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}",
140
- "selected": false,
141
- "source": "LanguageModelComponent-Enuj5",
142
- "sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-Enuj5œ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}",
143
- "target": "StructuredOutput-zfjb9",
144
- "targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutput-zfjb9œ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}"
116
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_value\u0153, \u0153id\u0153: \u0153StructuredOutput-zfjb9\u0153, \u0153inputTypes\u0153: [\u0153Message\u0153], \u0153type\u0153: \u0153str\u0153}"
145
117
  },
146
118
  {
147
119
  "animated": false,
@@ -165,12 +137,12 @@
165
137
  "type": "other"
166
138
  }
167
139
  },
168
- "id": "xy-edge__StructuredOutput-zfjb9{œdataTypeœ:œStructuredOutputœ,œidœ:œStructuredOutput-zfjb9œ,œnameœ:œdataframe_outputœ,œoutput_typesœ:[œDataFrameœ]}-ParserComponent-8lfAE{œfieldNameœ:œinput_dataœ,œidœ:œParserComponent-8lfAEœ,œinputTypesœ:[œDataFrameœ,œDataœ],œtypeœ:œotherœ}",
140
+ "id": "xy-edge__StructuredOutput-zfjb9{\u0153dataType\u0153:\u0153StructuredOutput\u0153,\u0153id\u0153:\u0153StructuredOutput-zfjb9\u0153,\u0153name\u0153:\u0153dataframe_output\u0153,\u0153output_types\u0153:[\u0153DataFrame\u0153]}-ParserComponent-8lfAE{\u0153fieldName\u0153:\u0153input_data\u0153,\u0153id\u0153:\u0153ParserComponent-8lfAE\u0153,\u0153inputTypes\u0153:[\u0153DataFrame\u0153,\u0153Data\u0153],\u0153type\u0153:\u0153other\u0153}",
169
141
  "selected": false,
170
142
  "source": "StructuredOutput-zfjb9",
171
- "sourceHandle": "{œdataTypeœ: œStructuredOutputœ, œidœ: œStructuredOutput-zfjb9œ, œnameœ: œdataframe_outputœ, œoutput_typesœ: [œDataFrameœ]}",
143
+ "sourceHandle": "{\u0153dataType\u0153: \u0153StructuredOutput\u0153, \u0153id\u0153: \u0153StructuredOutput-zfjb9\u0153, \u0153name\u0153: \u0153dataframe_output\u0153, \u0153output_types\u0153: [\u0153DataFrame\u0153]}",
172
144
  "target": "ParserComponent-8lfAE",
173
- "targetHandle": "{œfieldNameœ: œinput_dataœ, œidœ: œParserComponent-8lfAEœ, œinputTypesœ: [œDataFrameœ, œDataœ], œtypeœ: œotherœ}"
145
+ "targetHandle": "{\u0153fieldName\u0153: \u0153input_data\u0153, \u0153id\u0153: \u0153ParserComponent-8lfAE\u0153, \u0153inputTypes\u0153: [\u0153DataFrame\u0153, \u0153Data\u0153], \u0153type\u0153: \u0153other\u0153}"
174
146
  }
175
147
  ],
176
148
  "nodes": [
@@ -1172,333 +1144,6 @@
1172
1144
  "selected": false,
1173
1145
  "type": "genericNode"
1174
1146
  },
1175
- {
1176
- "data": {
1177
- "id": "LanguageModelComponent-Enuj5",
1178
- "node": {
1179
- "base_classes": [
1180
- "LanguageModel",
1181
- "Message"
1182
- ],
1183
- "beta": false,
1184
- "conditional_paths": [],
1185
- "custom_fields": {},
1186
- "description": "Runs a language model given a specified provider.",
1187
- "display_name": "Language Model",
1188
- "documentation": "",
1189
- "edited": false,
1190
- "field_order": [
1191
- "provider",
1192
- "model_name",
1193
- "api_key",
1194
- "input_value",
1195
- "system_message",
1196
- "stream",
1197
- "temperature"
1198
- ],
1199
- "frozen": false,
1200
- "icon": "brain-circuit",
1201
- "last_updated": "2025-09-29T15:47:37.204Z",
1202
- "legacy": false,
1203
- "lf_version": "1.6.0",
1204
- "metadata": {
1205
- "code_hash": "bb5f8714781b",
1206
- "dependencies": {
1207
- "dependencies": [
1208
- {
1209
- "name": "langchain_anthropic",
1210
- "version": "0.3.14"
1211
- },
1212
- {
1213
- "name": "langchain_google_genai",
1214
- "version": "2.0.6"
1215
- },
1216
- {
1217
- "name": "langchain_openai",
1218
- "version": "0.3.23"
1219
- },
1220
- {
1221
- "name": "lfx",
1222
- "version": null
1223
- }
1224
- ],
1225
- "total_dependencies": 4
1226
- },
1227
- "keywords": [
1228
- "model",
1229
- "llm",
1230
- "language model",
1231
- "large language model"
1232
- ],
1233
- "module": "lfx.components.models.language_model.LanguageModelComponent"
1234
- },
1235
- "minimized": false,
1236
- "output_types": [],
1237
- "outputs": [
1238
- {
1239
- "allows_loop": false,
1240
- "cache": true,
1241
- "display_name": "Model Response",
1242
- "group_outputs": false,
1243
- "method": "text_response",
1244
- "name": "text_output",
1245
- "options": null,
1246
- "required_inputs": null,
1247
- "selected": "Message",
1248
- "tool_mode": true,
1249
- "types": [
1250
- "Message"
1251
- ],
1252
- "value": "__UNDEFINED__"
1253
- },
1254
- {
1255
- "allows_loop": false,
1256
- "cache": true,
1257
- "display_name": "Language Model",
1258
- "group_outputs": false,
1259
- "method": "build_model",
1260
- "name": "model_output",
1261
- "options": null,
1262
- "required_inputs": null,
1263
- "selected": "LanguageModel",
1264
- "tool_mode": true,
1265
- "types": [
1266
- "LanguageModel"
1267
- ],
1268
- "value": "__UNDEFINED__"
1269
- }
1270
- ],
1271
- "pinned": false,
1272
- "priority": 0,
1273
- "template": {
1274
- "_type": "Component",
1275
- "api_key": {
1276
- "_input_type": "SecretStrInput",
1277
- "advanced": false,
1278
- "display_name": "OpenAI API Key",
1279
- "dynamic": false,
1280
- "info": "Model Provider API key",
1281
- "input_types": [],
1282
- "load_from_db": true,
1283
- "name": "api_key",
1284
- "password": true,
1285
- "placeholder": "",
1286
- "real_time_refresh": true,
1287
- "required": false,
1288
- "show": true,
1289
- "title_case": false,
1290
- "type": "str",
1291
- "value": "OPENAI_API_KEY"
1292
- },
1293
- "code": {
1294
- "advanced": true,
1295
- "dynamic": true,
1296
- "fileTypes": [],
1297
- "file_path": "",
1298
- "info": "",
1299
- "list": false,
1300
- "load_from_db": false,
1301
- "multiline": true,
1302
- "name": "code",
1303
- "password": false,
1304
- "placeholder": "",
1305
- "required": true,
1306
- "show": true,
1307
- "title_case": false,
1308
- "type": "code",
1309
- "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"
1310
- },
1311
- "input_value": {
1312
- "_input_type": "MessageInput",
1313
- "advanced": false,
1314
- "display_name": "Input",
1315
- "dynamic": false,
1316
- "info": "The input text to send to the model",
1317
- "input_types": [
1318
- "Message"
1319
- ],
1320
- "list": false,
1321
- "list_add_label": "Add More",
1322
- "load_from_db": false,
1323
- "name": "input_value",
1324
- "placeholder": "",
1325
- "required": false,
1326
- "show": true,
1327
- "title_case": false,
1328
- "tool_mode": false,
1329
- "trace_as_input": true,
1330
- "trace_as_metadata": true,
1331
- "type": "str",
1332
- "value": ""
1333
- },
1334
- "model_name": {
1335
- "_input_type": "DropdownInput",
1336
- "advanced": false,
1337
- "combobox": false,
1338
- "dialog_inputs": {},
1339
- "display_name": "Model Name",
1340
- "dynamic": false,
1341
- "info": "Select the model to use",
1342
- "name": "model_name",
1343
- "options": [
1344
- "gpt-4o-mini",
1345
- "gpt-4o",
1346
- "gpt-4.1",
1347
- "gpt-4.1-mini",
1348
- "gpt-4.1-nano",
1349
- "gpt-4-turbo",
1350
- "gpt-4-turbo-preview",
1351
- "gpt-4",
1352
- "gpt-3.5-turbo",
1353
- "gpt-5",
1354
- "gpt-5-mini",
1355
- "gpt-5-nano",
1356
- "gpt-5-chat-latest",
1357
- "o1",
1358
- "o3-mini",
1359
- "o3",
1360
- "o3-pro",
1361
- "o4-mini",
1362
- "o4-mini-high"
1363
- ],
1364
- "options_metadata": [],
1365
- "placeholder": "",
1366
- "required": false,
1367
- "show": true,
1368
- "title_case": false,
1369
- "toggle": false,
1370
- "tool_mode": false,
1371
- "trace_as_metadata": true,
1372
- "type": "str",
1373
- "value": "gpt-4o-mini"
1374
- },
1375
- "provider": {
1376
- "_input_type": "DropdownInput",
1377
- "advanced": false,
1378
- "combobox": false,
1379
- "dialog_inputs": {},
1380
- "display_name": "Model Provider",
1381
- "dynamic": false,
1382
- "info": "Select the model provider",
1383
- "name": "provider",
1384
- "options": [
1385
- "OpenAI",
1386
- "Anthropic",
1387
- "Google"
1388
- ],
1389
- "options_metadata": [
1390
- {
1391
- "icon": "OpenAI"
1392
- },
1393
- {
1394
- "icon": "Anthropic"
1395
- },
1396
- {
1397
- "icon": "GoogleGenerativeAI"
1398
- }
1399
- ],
1400
- "placeholder": "",
1401
- "real_time_refresh": true,
1402
- "required": false,
1403
- "show": true,
1404
- "title_case": false,
1405
- "toggle": false,
1406
- "tool_mode": false,
1407
- "trace_as_metadata": true,
1408
- "type": "str",
1409
- "value": "OpenAI"
1410
- },
1411
- "stream": {
1412
- "_input_type": "BoolInput",
1413
- "advanced": true,
1414
- "display_name": "Stream",
1415
- "dynamic": false,
1416
- "info": "Whether to stream the response",
1417
- "list": false,
1418
- "list_add_label": "Add More",
1419
- "name": "stream",
1420
- "placeholder": "",
1421
- "required": false,
1422
- "show": true,
1423
- "title_case": false,
1424
- "tool_mode": false,
1425
- "trace_as_metadata": true,
1426
- "type": "bool",
1427
- "value": false
1428
- },
1429
- "system_message": {
1430
- "_input_type": "MultilineInput",
1431
- "advanced": true,
1432
- "copy_field": false,
1433
- "display_name": "System Message",
1434
- "dynamic": false,
1435
- "info": "A system message that helps set the behavior of the assistant",
1436
- "input_types": [
1437
- "Message"
1438
- ],
1439
- "list": false,
1440
- "list_add_label": "Add More",
1441
- "load_from_db": false,
1442
- "multiline": true,
1443
- "name": "system_message",
1444
- "placeholder": "",
1445
- "required": false,
1446
- "show": true,
1447
- "title_case": false,
1448
- "tool_mode": false,
1449
- "trace_as_input": true,
1450
- "trace_as_metadata": true,
1451
- "type": "str",
1452
- "value": ""
1453
- },
1454
- "temperature": {
1455
- "_input_type": "SliderInput",
1456
- "advanced": true,
1457
- "display_name": "Temperature",
1458
- "dynamic": false,
1459
- "info": "Controls randomness in responses",
1460
- "max_label": "",
1461
- "max_label_icon": "",
1462
- "min_label": "",
1463
- "min_label_icon": "",
1464
- "name": "temperature",
1465
- "placeholder": "",
1466
- "range_spec": {
1467
- "max": 1,
1468
- "min": 0,
1469
- "step": 0.01,
1470
- "step_type": "float"
1471
- },
1472
- "required": false,
1473
- "show": true,
1474
- "slider_buttons": false,
1475
- "slider_buttons_options": [],
1476
- "slider_input": false,
1477
- "title_case": false,
1478
- "tool_mode": false,
1479
- "type": "slider",
1480
- "value": 0.1
1481
- }
1482
- },
1483
- "tool_mode": false
1484
- },
1485
- "selected_output": "model_output",
1486
- "showNode": true,
1487
- "type": "LanguageModelComponent"
1488
- },
1489
- "dragging": false,
1490
- "id": "LanguageModelComponent-Enuj5",
1491
- "measured": {
1492
- "height": 451,
1493
- "width": 320
1494
- },
1495
- "position": {
1496
- "x": 1238.9336326592597,
1497
- "y": 1187.129728383852
1498
- },
1499
- "selected": false,
1500
- "type": "genericNode"
1501
- },
1502
1147
  {
1503
1148
  "data": {
1504
1149
  "id": "Agent-Hz2it",
@@ -1507,27 +1152,20 @@
1507
1152
  "Message"
1508
1153
  ],
1509
1154
  "beta": false,
1510
- "category": "agents",
1511
1155
  "conditional_paths": [],
1512
1156
  "custom_fields": {},
1513
1157
  "description": "Define the agent's instructions, then enter a task to complete using tools.",
1514
1158
  "display_name": "Agent",
1515
- "documentation": "",
1159
+ "documentation": "https://docs.langflow.org/agents",
1516
1160
  "edited": false,
1517
1161
  "field_order": [
1518
- "agent_llm",
1519
- "max_tokens",
1520
- "model_kwargs",
1521
- "json_mode",
1522
- "model_name",
1523
- "openai_api_base",
1162
+ "model",
1524
1163
  "api_key",
1525
- "temperature",
1526
- "seed",
1527
- "max_retries",
1528
- "timeout",
1529
1164
  "system_prompt",
1165
+ "context_id",
1530
1166
  "n_messages",
1167
+ "format_instructions",
1168
+ "output_schema",
1531
1169
  "tools",
1532
1170
  "input_value",
1533
1171
  "handle_parsing_errors",
@@ -1538,10 +1176,8 @@
1538
1176
  ],
1539
1177
  "frozen": false,
1540
1178
  "icon": "bot",
1541
- "key": "Agent",
1542
- "last_updated": "2025-09-29T15:47:37.204Z",
1179
+ "last_updated": "2025-12-11T21:41:48.407Z",
1543
1180
  "legacy": false,
1544
- "lf_version": "1.6.0",
1545
1181
  "metadata": {
1546
1182
  "code_hash": "1834a4d901fa",
1547
1183
  "dependencies": {
@@ -1573,8 +1209,6 @@
1573
1209
  "group_outputs": false,
1574
1210
  "method": "message_response",
1575
1211
  "name": "response",
1576
- "options": null,
1577
- "required_inputs": null,
1578
1212
  "selected": "Message",
1579
1213
  "tool_mode": true,
1580
1214
  "types": [
@@ -1584,7 +1218,6 @@
1584
1218
  }
1585
1219
  ],
1586
1220
  "pinned": false,
1587
- "score": 1.1732828199964098e-19,
1588
1221
  "template": {
1589
1222
  "_type": "Component",
1590
1223
  "add_current_date_tool": {
@@ -1593,21 +1226,25 @@
1593
1226
  "display_name": "Current Date",
1594
1227
  "dynamic": false,
1595
1228
  "info": "If true, will add a tool to the agent that returns the current date.",
1229
+ "input_types": [],
1596
1230
  "list": false,
1597
1231
  "list_add_label": "Add More",
1598
1232
  "name": "add_current_date_tool",
1233
+ "override_skip": false,
1599
1234
  "placeholder": "",
1600
1235
  "required": false,
1601
1236
  "show": true,
1602
1237
  "title_case": false,
1603
1238
  "tool_mode": false,
1604
1239
  "trace_as_metadata": true,
1240
+ "track_in_telemetry": true,
1605
1241
  "type": "bool",
1606
1242
  "value": true
1607
1243
  },
1608
1244
  "agent_description": {
1609
1245
  "_input_type": "MultilineInput",
1610
1246
  "advanced": true,
1247
+ "ai_enabled": false,
1611
1248
  "copy_field": false,
1612
1249
  "display_name": "Agent Description [Deprecated]",
1613
1250
  "dynamic": false,
@@ -1620,6 +1257,7 @@
1620
1257
  "load_from_db": false,
1621
1258
  "multiline": true,
1622
1259
  "name": "agent_description",
1260
+ "override_skip": false,
1623
1261
  "placeholder": "",
1624
1262
  "required": false,
1625
1263
  "show": true,
@@ -1627,26 +1265,29 @@
1627
1265
  "tool_mode": false,
1628
1266
  "trace_as_input": true,
1629
1267
  "trace_as_metadata": true,
1268
+ "track_in_telemetry": false,
1630
1269
  "type": "str",
1631
1270
  "value": "A helpful assistant with access to the following tools:"
1632
1271
  },
1633
1272
  "api_key": {
1634
1273
  "_input_type": "SecretStrInput",
1635
- "advanced": false,
1274
+ "advanced": true,
1636
1275
  "display_name": "API Key",
1637
1276
  "dynamic": false,
1638
1277
  "info": "Model Provider API key",
1639
1278
  "input_types": [],
1640
- "load_from_db": true,
1279
+ "load_from_db": false,
1641
1280
  "name": "api_key",
1281
+ "override_skip": false,
1642
1282
  "password": true,
1643
1283
  "placeholder": "",
1644
1284
  "real_time_refresh": true,
1645
1285
  "required": false,
1646
1286
  "show": true,
1647
1287
  "title_case": false,
1288
+ "track_in_telemetry": false,
1648
1289
  "type": "str",
1649
- "value": "OPENAI_API_KEY"
1290
+ "value": ""
1650
1291
  },
1651
1292
  "code": {
1652
1293
  "advanced": true,
@@ -1679,6 +1320,7 @@
1679
1320
  "list_add_label": "Add More",
1680
1321
  "load_from_db": false,
1681
1322
  "name": "context_id",
1323
+ "override_skip": false,
1682
1324
  "placeholder": "",
1683
1325
  "required": false,
1684
1326
  "show": true,
@@ -1686,12 +1328,14 @@
1686
1328
  "tool_mode": false,
1687
1329
  "trace_as_input": true,
1688
1330
  "trace_as_metadata": true,
1331
+ "track_in_telemetry": false,
1689
1332
  "type": "str",
1690
1333
  "value": ""
1691
1334
  },
1692
1335
  "format_instructions": {
1693
1336
  "_input_type": "MultilineInput",
1694
1337
  "advanced": true,
1338
+ "ai_enabled": false,
1695
1339
  "copy_field": false,
1696
1340
  "display_name": "Output Format Instructions",
1697
1341
  "dynamic": false,
@@ -1704,6 +1348,7 @@
1704
1348
  "load_from_db": false,
1705
1349
  "multiline": true,
1706
1350
  "name": "format_instructions",
1351
+ "override_skip": false,
1707
1352
  "placeholder": "",
1708
1353
  "required": false,
1709
1354
  "show": true,
@@ -1711,6 +1356,7 @@
1711
1356
  "tool_mode": false,
1712
1357
  "trace_as_input": true,
1713
1358
  "trace_as_metadata": true,
1359
+ "track_in_telemetry": false,
1714
1360
  "type": "str",
1715
1361
  "value": "You are an AI that extracts structured JSON objects from unstructured text. Use a predefined schema with expected types (str, int, float, bool, dict). Extract ALL relevant instances that match the schema - if multiple patterns exist, capture them all. Fill missing or ambiguous values with defaults: null for missing values. Remove exact duplicates but keep variations that have different field values. Always return valid JSON in the expected format, never throw errors. If multiple objects can be extracted, return them all in the structured format."
1716
1362
  },
@@ -1720,20 +1366,23 @@
1720
1366
  "display_name": "Handle Parse Errors",
1721
1367
  "dynamic": false,
1722
1368
  "info": "Should the Agent fix errors when reading user input for better processing?",
1369
+ "input_types": [],
1723
1370
  "list": false,
1724
1371
  "list_add_label": "Add More",
1725
1372
  "name": "handle_parsing_errors",
1373
+ "override_skip": false,
1726
1374
  "placeholder": "",
1727
1375
  "required": false,
1728
1376
  "show": true,
1729
1377
  "title_case": false,
1730
1378
  "tool_mode": false,
1731
1379
  "trace_as_metadata": true,
1380
+ "track_in_telemetry": true,
1732
1381
  "type": "bool",
1733
1382
  "value": true
1734
1383
  },
1735
1384
  "input_value": {
1736
- "_input_type": "MessageTextInput",
1385
+ "_input_type": "MessageInput",
1737
1386
  "advanced": false,
1738
1387
  "display_name": "Input",
1739
1388
  "dynamic": false,
@@ -1745,6 +1394,7 @@
1745
1394
  "list_add_label": "Add More",
1746
1395
  "load_from_db": false,
1747
1396
  "name": "input_value",
1397
+ "override_skip": false,
1748
1398
  "placeholder": "",
1749
1399
  "required": false,
1750
1400
  "show": true,
@@ -1752,6 +1402,7 @@
1752
1402
  "tool_mode": true,
1753
1403
  "trace_as_input": true,
1754
1404
  "trace_as_metadata": true,
1405
+ "track_in_telemetry": false,
1755
1406
  "type": "str",
1756
1407
  "value": ""
1757
1408
  },
@@ -1761,15 +1412,18 @@
1761
1412
  "display_name": "Max Iterations",
1762
1413
  "dynamic": false,
1763
1414
  "info": "The maximum number of attempts the agent can make to complete its task before it stops.",
1415
+ "input_types": [],
1764
1416
  "list": false,
1765
1417
  "list_add_label": "Add More",
1766
1418
  "name": "max_iterations",
1419
+ "override_skip": false,
1767
1420
  "placeholder": "",
1768
1421
  "required": false,
1769
1422
  "show": true,
1770
1423
  "title_case": false,
1771
1424
  "tool_mode": false,
1772
1425
  "trace_as_metadata": true,
1426
+ "track_in_telemetry": true,
1773
1427
  "type": "int",
1774
1428
  "value": 15
1775
1429
  },
@@ -1797,6 +1451,7 @@
1797
1451
  "list_add_label": "Add More",
1798
1452
  "model_type": "language",
1799
1453
  "name": "model",
1454
+ "options": [],
1800
1455
  "override_skip": false,
1801
1456
  "placeholder": "Setup Provider",
1802
1457
  "real_time_refresh": true,
@@ -1808,7 +1463,7 @@
1808
1463
  "trace_as_input": true,
1809
1464
  "track_in_telemetry": false,
1810
1465
  "type": "model",
1811
- "value": ""
1466
+ "value": []
1812
1467
  },
1813
1468
  "n_messages": {
1814
1469
  "_input_type": "IntInput",
@@ -1816,15 +1471,18 @@
1816
1471
  "display_name": "Number of Chat History Messages",
1817
1472
  "dynamic": false,
1818
1473
  "info": "Number of chat history messages to retrieve.",
1474
+ "input_types": [],
1819
1475
  "list": false,
1820
1476
  "list_add_label": "Add More",
1821
1477
  "name": "n_messages",
1478
+ "override_skip": false,
1822
1479
  "placeholder": "",
1823
1480
  "required": false,
1824
1481
  "show": true,
1825
1482
  "title_case": false,
1826
1483
  "tool_mode": false,
1827
1484
  "trace_as_metadata": true,
1485
+ "track_in_telemetry": true,
1828
1486
  "type": "int",
1829
1487
  "value": 100
1830
1488
  },
@@ -1834,9 +1492,11 @@
1834
1492
  "display_name": "Output Schema",
1835
1493
  "dynamic": false,
1836
1494
  "info": "Schema Validation: Define the structure and data types for structured output. No validation if no output schema.",
1495
+ "input_types": [],
1837
1496
  "is_list": true,
1838
1497
  "list_add_label": "Add More",
1839
1498
  "name": "output_schema",
1499
+ "override_skip": false,
1840
1500
  "placeholder": "",
1841
1501
  "required": false,
1842
1502
  "show": true,
@@ -1885,6 +1545,7 @@
1885
1545
  "title_case": false,
1886
1546
  "tool_mode": false,
1887
1547
  "trace_as_metadata": true,
1548
+ "track_in_telemetry": false,
1888
1549
  "trigger_icon": "Table",
1889
1550
  "trigger_text": "Open table",
1890
1551
  "type": "table",
@@ -1893,6 +1554,7 @@
1893
1554
  "system_prompt": {
1894
1555
  "_input_type": "MultilineInput",
1895
1556
  "advanced": false,
1557
+ "ai_enabled": false,
1896
1558
  "copy_field": false,
1897
1559
  "display_name": "Agent Instructions",
1898
1560
  "dynamic": false,
@@ -1905,6 +1567,7 @@
1905
1567
  "load_from_db": false,
1906
1568
  "multiline": true,
1907
1569
  "name": "system_prompt",
1570
+ "override_skip": false,
1908
1571
  "placeholder": "",
1909
1572
  "required": false,
1910
1573
  "show": true,
@@ -1912,6 +1575,7 @@
1912
1575
  "tool_mode": false,
1913
1576
  "trace_as_input": true,
1914
1577
  "trace_as_metadata": true,
1578
+ "track_in_telemetry": false,
1915
1579
  "type": "str",
1916
1580
  "value": "You are a helpful assistant that can use tools to answer questions and perform tasks."
1917
1581
  },
@@ -1927,11 +1591,13 @@
1927
1591
  "list": true,
1928
1592
  "list_add_label": "Add More",
1929
1593
  "name": "tools",
1594
+ "override_skip": false,
1930
1595
  "placeholder": "",
1931
1596
  "required": false,
1932
1597
  "show": true,
1933
1598
  "title_case": false,
1934
1599
  "trace_as_metadata": true,
1600
+ "track_in_telemetry": false,
1935
1601
  "type": "other",
1936
1602
  "value": ""
1937
1603
  },
@@ -1941,15 +1607,18 @@
1941
1607
  "display_name": "Verbose",
1942
1608
  "dynamic": false,
1943
1609
  "info": "",
1610
+ "input_types": [],
1944
1611
  "list": false,
1945
1612
  "list_add_label": "Add More",
1946
1613
  "name": "verbose",
1614
+ "override_skip": false,
1947
1615
  "placeholder": "",
1948
1616
  "required": false,
1949
1617
  "show": true,
1950
1618
  "title_case": false,
1951
1619
  "tool_mode": false,
1952
1620
  "trace_as_metadata": true,
1621
+ "track_in_telemetry": true,
1953
1622
  "type": "bool",
1954
1623
  "value": true
1955
1624
  }
@@ -2275,7 +1944,7 @@
2275
1944
  "show": true,
2276
1945
  "title_case": false,
2277
1946
  "type": "code",
2278
- "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"
1947
+ "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"
2279
1948
  },
2280
1949
  "input_value": {
2281
1950
  "_input_type": "MultilineInput",