From 47728f5816f77dba87f3c0490ea6fed0b35c0d45 Mon Sep 17 00:00:00 2001 From: Adam-Aghili <149833988+Adam-Aghili@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:35:53 -0500 Subject: [PATCH] fix: add Language Model components to Basic Prompt Chaining.json in starter_projects (#11567) fix: add LM components to starter_projects in BPC add Language Model components to Basic Prompt Chaining,json in starter_projects --- .secrets.baseline | 50 + .../Basic Prompt Chaining.json | 2523 +++++++++++++++-- 2 files changed, 2382 insertions(+), 191 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 5c96ca490b..02e00ec6d0 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -871,6 +871,56 @@ "is_secret": false } ], + "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json": [ + { + "type": "Hex High Entropy String", + "filename": "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json", + "hashed_secret": "54ed260e3bc31bc77ee06754dff850981d39a66c", + "is_verified": false, + "line_number": 357, + "is_secret": false + }, + { + "type": "Hex High Entropy String", + "filename": "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json", + "hashed_secret": "35be14614e83fe56d9b2ca1c0e2c2a74890b6889", + "is_verified": false, + "line_number": 625, + "is_secret": false + }, + { + "type": "Secret Keyword", + "filename": "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json", + "hashed_secret": "665b1e3851eefefa3fb878654292f16597d25155", + "is_verified": false, + "line_number": 1400, + "is_secret": false + }, + { + "type": "Secret Keyword", + "filename": "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json", + "hashed_secret": "3f2df46921dd8e2c36e2ce85238705ac0774c74a", + "is_verified": false, + "line_number": 1535, + "is_secret": false + }, + { + "type": "Secret Keyword", + "filename": "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json", + "hashed_secret": "d3d6fe3f7d33d0f4aa28c49544a865982a48a00a", + "is_verified": false, + "line_number": 1595, + "is_secret": false + }, + { + "type": "Secret Keyword", + "filename": "src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json", + "hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030", + "is_verified": false, + "line_number": 1660, + "is_secret": false + } + ], "src/backend/base/langflow/inputs/input_mixin.py": [ { "type": "Secret Keyword", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json b/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json index 835572efc8..f39c985491 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json @@ -2,96 +2,183 @@ "data": { "edges": [ { + "animated": false, + "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-B7vXK", + "id": "ChatInput-pNKvO", "name": "message", "output_types": [ "Message" ] }, "targetHandle": { - "fieldName": "tool_placeholder", - "id": "Prompt-RcCgD", + "fieldName": "input_value", + "id": "LanguageModelComponent-Q5bRY", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-B7vXKmessage-Prompt-RcCgDtool_placeholder", - "source": "ChatInput-B7vXK", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-B7vXKœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-RcCgD", - "targetHandle": "{œfieldNameœ: œtool_placeholderœ, œidœ: œPrompt-RcCgDœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}", - "type": "default" + "id": "xy-edge__ChatInput-pNKvO{œdataTypeœ:œChatInputœ,œidœ:œChatInput-pNKvOœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-LanguageModelComponent-Q5bRY{œfieldNameœ:œinput_valueœ,œidœ:œLanguageModelComponent-Q5bRYœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "selected": false, + "source": "ChatInput-pNKvO", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-pNKvOœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "LanguageModelComponent-Q5bRY", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œLanguageModelComponent-Q5bRYœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { + "animated": false, + "className": "", "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-RcCgD", + "id": "Prompt-vc20t", "name": "prompt", "output_types": [ "Message" ] }, "targetHandle": { - "fieldName": "tool_placeholder", - "id": "Prompt-gxyFu", + "fieldName": "system_message", + "id": "LanguageModelComponent-Q5bRY", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-RcCgDprompt-Prompt-gxyFutool_placeholder", - "source": "Prompt-RcCgD", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-RcCgDœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-gxyFu", - "targetHandle": "{œfieldNameœ: œtool_placeholderœ, œidœ: œPrompt-gxyFuœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}", - "type": "default" + "id": "xy-edge__Prompt-vc20t{œdataTypeœ:œPromptœ,œidœ:œPrompt-vc20tœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-LanguageModelComponent-Q5bRY{œfieldNameœ:œsystem_messageœ,œidœ:œLanguageModelComponent-Q5bRYœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "selected": false, + "source": "Prompt-vc20t", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-vc20tœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "LanguageModelComponent-Q5bRY", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œLanguageModelComponent-Q5bRYœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { + "animated": false, + "className": "", "data": { "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-gxyFu", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "tool_placeholder", - "id": "Prompt-7PuDH", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-gxyFuprompt-Prompt-7PuDHtool_placeholder", - "source": "Prompt-gxyFu", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-gxyFuœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-7PuDH", - "targetHandle": "{œfieldNameœ: œtool_placeholderœ, œidœ: œPrompt-7PuDHœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}", - "type": "default" - }, - { - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-7PuDH", - "name": "prompt", + "dataType": "LanguageModelComponent", + "id": "LanguageModelComponent-Q5bRY", + "name": "text_output", "output_types": [ "Message" ] }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-mc2Rz", + "id": "LanguageModelComponent-ZBPrp", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__LanguageModelComponent-Q5bRY{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-Q5bRYœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-LanguageModelComponent-ZBPrp{œfieldNameœ:œinput_valueœ,œidœ:œLanguageModelComponent-ZBPrpœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "selected": false, + "source": "LanguageModelComponent-Q5bRY", + "sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-Q5bRYœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "LanguageModelComponent-ZBPrp", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œLanguageModelComponent-ZBPrpœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "animated": false, + "className": "", + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-wnec9", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "LanguageModelComponent-ZBPrp", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-wnec9{œdataTypeœ:œPromptœ,œidœ:œPrompt-wnec9œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-LanguageModelComponent-ZBPrp{œfieldNameœ:œsystem_messageœ,œidœ:œLanguageModelComponent-ZBPrpœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "selected": false, + "source": "Prompt-wnec9", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-wnec9œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "LanguageModelComponent-ZBPrp", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œLanguageModelComponent-ZBPrpœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "LanguageModelComponent", + "id": "LanguageModelComponent-ZBPrp", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "LanguageModelComponent-YIUOh", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__LanguageModelComponent-ZBPrp{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-ZBPrpœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-LanguageModelComponent-YIUOh{œfieldNameœ:œinput_valueœ,œidœ:œLanguageModelComponent-YIUOhœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "LanguageModelComponent-ZBPrp", + "sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-ZBPrpœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "LanguageModelComponent-YIUOh", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œLanguageModelComponent-YIUOhœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-Ph34L", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "LanguageModelComponent-YIUOh", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-Ph34L{œdataTypeœ:œPromptœ,œidœ:œPrompt-Ph34Lœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-LanguageModelComponent-YIUOh{œfieldNameœ:œsystem_messageœ,œidœ:œLanguageModelComponent-YIUOhœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-Ph34L", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-Ph34Lœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "LanguageModelComponent-YIUOh", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œLanguageModelComponent-YIUOhœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "LanguageModelComponent", + "id": "LanguageModelComponent-YIUOh", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-WSW39", "inputTypes": [ "Data", "DataFrame", @@ -100,20 +187,19 @@ "type": "str" } }, - "id": "reactflow__edge-Prompt-7PuDHprompt-ChatOutput-mc2Rzinput_value", - "source": "Prompt-7PuDH", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-7PuDHœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-mc2Rz", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-mc2Rzœ, œinputTypesœ: [œDataœ, œDataFrameœ, œMessageœ], œtypeœ: œstrœ}", - "type": "default" + "id": "xy-edge__LanguageModelComponent-YIUOh{œdataTypeœ:œLanguageModelComponentœ,œidœ:œLanguageModelComponent-YIUOhœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-WSW39{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-WSW39œ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œstrœ}", + "source": "LanguageModelComponent-YIUOh", + "sourceHandle": "{œdataTypeœ: œLanguageModelComponentœ, œidœ: œLanguageModelComponent-YIUOhœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-WSW39", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-WSW39œ, œinputTypesœ: [œDataœ, œDataFrameœ, œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ { "data": { "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt Template", - "id": "Prompt-gxyFu", + "display_name": "Prompt", + "id": "Prompt-wnec9", "node": { "base_classes": [ "Message" @@ -124,29 +210,17 @@ "template": [] }, "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt Template", + "display_name": "Prompt", "documentation": "", "edited": false, "field_order": [ "template" ], "frozen": false, - "icon": "prompts", + "icon": "braces", "legacy": false, "lf_version": "1.5.0", - "metadata": { - "code_hash": "42558628ed51", - "dependencies": { - "dependencies": [ - { - "name": "lfx", - "version": null - } - ], - "total_dependencies": 1 - }, - "module": "lfx.components.models_and_agents.prompt.PromptComponent" - }, + "metadata": {}, "output_types": [], "outputs": [ { @@ -183,7 +257,7 @@ "show": true, "title_case": false, "type": "code", - "value": "from typing import Any\n\nfrom lfx.base.prompts.api_utils import process_prompt_template\nfrom lfx.custom.custom_component.component import Component\nfrom lfx.inputs.input_mixin import FieldTypes\nfrom lfx.inputs.inputs import DefaultPromptField\nfrom lfx.io import BoolInput, MessageTextInput, Output, PromptInput\nfrom lfx.schema.dotdict import dotdict\nfrom lfx.schema.message import Message\nfrom lfx.template.utils import update_template_values\nfrom lfx.utils.mustache_security import validate_mustache_template\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt Template\"\n description: str = \"Create a prompt template with dynamic variables.\"\n documentation: str = \"https://docs.langflow.org/components-prompts\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n name = \"Prompt Template\"\n priority = 0 # Set priority to 0 to make it appear first\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n BoolInput(\n name=\"use_double_brackets\",\n display_name=\"Use Double Brackets\",\n value=False,\n advanced=True,\n info=\"Use {{variable}} syntax instead of {variable}.\",\n real_time_refresh=True,\n ),\n MessageTextInput(\n name=\"tool_placeholder\",\n display_name=\"Tool Placeholder\",\n tool_mode=True,\n advanced=True,\n info=\"A placeholder input for tool mode.\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict:\n \"\"\"Update the template field type based on the selected mode.\"\"\"\n if field_name == \"use_double_brackets\":\n # Change the template field type based on mode\n is_mustache = field_value is True\n if is_mustache:\n build_config[\"template\"][\"type\"] = FieldTypes.MUSTACHE_PROMPT.value\n else:\n build_config[\"template\"][\"type\"] = FieldTypes.PROMPT.value\n\n # Re-process the template to update variables when mode changes\n template_value = build_config.get(\"template\", {}).get(\"value\", \"\")\n if template_value:\n # Ensure custom_fields is properly initialized\n if \"custom_fields\" not in build_config:\n build_config[\"custom_fields\"] = {}\n\n # Clean up fields from the OLD mode before processing with NEW mode\n # This ensures we don't keep fields with wrong syntax even if validation fails\n old_custom_fields = build_config[\"custom_fields\"].get(\"template\", [])\n for old_field in list(old_custom_fields):\n # Remove the field from custom_fields and template\n if old_field in old_custom_fields:\n old_custom_fields.remove(old_field)\n build_config.pop(old_field, None)\n\n # Try to process template with new mode to add new variables\n # If validation fails, at least we cleaned up old fields\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(template_value)\n\n # Re-process template with new mode to add new variables\n _ = process_prompt_template(\n template=template_value,\n name=\"template\",\n custom_fields=build_config[\"custom_fields\"],\n frontend_node_template=build_config,\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, we still updated the mode and cleaned old fields\n # User will see error when they try to save\n pass\n return build_config\n\n async def build_prompt(self) -> Message:\n use_double_brackets = self.use_double_brackets if hasattr(self, \"use_double_brackets\") else False\n template_format = \"mustache\" if use_double_brackets else \"f-string\"\n prompt = await Message.from_template_and_variables(template_format=template_format, **self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n use_double_brackets = frontend_node[\"template\"].get(\"use_double_brackets\", {}).get(\"value\", False)\n is_mustache = use_double_brackets is True\n\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(prompt_template)\n\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, don't add variables but allow component to be created\n pass\n return frontend_node\n\n async def update_frontend_node(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = await super().update_frontend_node(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n use_double_brackets = frontend_node[\"template\"].get(\"use_double_brackets\", {}).get(\"value\", False)\n is_mustache = use_double_brackets is True\n\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(template)\n\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, don't add variables but allow component to be updated\n pass\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n" + "value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom.custom_component.component import Component\nfrom langflow.inputs.inputs import DefaultPromptField\nfrom langflow.io import MessageTextInput, Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"braces\"\n trace_type = \"prompt\"\n name = \"Prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n MessageTextInput(\n name=\"tool_placeholder\",\n display_name=\"Tool Placeholder\",\n tool_mode=True,\n advanced=True,\n info=\"A placeholder input for tool mode.\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(self) -> Message:\n prompt = Message.from_template(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n )\n return frontend_node\n\n async def update_frontend_node(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = await super().update_frontend_node(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n" }, "template": { "_input_type": "PromptInput", @@ -224,27 +298,6 @@ "trace_as_metadata": true, "type": "str", "value": "" - }, - "use_double_brackets": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "Use Double Brackets", - "dynamic": false, - "info": "Use {{variable}} syntax instead of {variable}.", - "list": false, - "list_add_label": "Add More", - "name": "use_double_brackets", - "override_skip": false, - "placeholder": "", - "real_time_refresh": true, - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "track_in_telemetry": true, - "type": "bool", - "value": false } }, "tool_mode": false @@ -253,9 +306,9 @@ "type": "Prompt" }, "dragging": false, - "id": "Prompt-gxyFu", + "id": "Prompt-wnec9", "measured": { - "height": 260, + "height": 284, "width": 320 }, "position": { @@ -271,7 +324,7 @@ }, { "data": { - "id": "ChatInput-B7vXK", + "id": "ChatInput-pNKvO", "node": { "base_classes": [ "Message" @@ -521,9 +574,9 @@ "type": "ChatInput" }, "dragging": false, - "id": "ChatInput-B7vXK", + "id": "ChatInput-pNKvO", "measured": { - "height": 234, + "height": 204, "width": 320 }, "position": { @@ -541,7 +594,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-mc2Rz", + "id": "ChatOutput-WSW39", "node": { "base_classes": [ "Message" @@ -800,9 +853,9 @@ "type": "ChatOutput" }, "dragging": false, - "id": "ChatOutput-mc2Rz", + "id": "ChatOutput-WSW39", "measured": { - "height": 234, + "height": 204, "width": 320 }, "position": { @@ -819,8 +872,8 @@ { "data": { "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt Template", - "id": "Prompt-7PuDH", + "display_name": "Prompt", + "id": "Prompt-Ph34L", "node": { "base_classes": [ "Message" @@ -831,29 +884,17 @@ "template": [] }, "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt Template", + "display_name": "Prompt", "documentation": "", "edited": false, "field_order": [ "template" ], "frozen": false, - "icon": "prompts", + "icon": "braces", "legacy": false, "lf_version": "1.5.0", - "metadata": { - "code_hash": "42558628ed51", - "dependencies": { - "dependencies": [ - { - "name": "lfx", - "version": null - } - ], - "total_dependencies": 1 - }, - "module": "lfx.components.models_and_agents.prompt.PromptComponent" - }, + "metadata": {}, "output_types": [], "outputs": [ { @@ -890,7 +931,7 @@ "show": true, "title_case": false, "type": "code", - "value": "from typing import Any\n\nfrom lfx.base.prompts.api_utils import process_prompt_template\nfrom lfx.custom.custom_component.component import Component\nfrom lfx.inputs.input_mixin import FieldTypes\nfrom lfx.inputs.inputs import DefaultPromptField\nfrom lfx.io import BoolInput, MessageTextInput, Output, PromptInput\nfrom lfx.schema.dotdict import dotdict\nfrom lfx.schema.message import Message\nfrom lfx.template.utils import update_template_values\nfrom lfx.utils.mustache_security import validate_mustache_template\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt Template\"\n description: str = \"Create a prompt template with dynamic variables.\"\n documentation: str = \"https://docs.langflow.org/components-prompts\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n name = \"Prompt Template\"\n priority = 0 # Set priority to 0 to make it appear first\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n BoolInput(\n name=\"use_double_brackets\",\n display_name=\"Use Double Brackets\",\n value=False,\n advanced=True,\n info=\"Use {{variable}} syntax instead of {variable}.\",\n real_time_refresh=True,\n ),\n MessageTextInput(\n name=\"tool_placeholder\",\n display_name=\"Tool Placeholder\",\n tool_mode=True,\n advanced=True,\n info=\"A placeholder input for tool mode.\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict:\n \"\"\"Update the template field type based on the selected mode.\"\"\"\n if field_name == \"use_double_brackets\":\n # Change the template field type based on mode\n is_mustache = field_value is True\n if is_mustache:\n build_config[\"template\"][\"type\"] = FieldTypes.MUSTACHE_PROMPT.value\n else:\n build_config[\"template\"][\"type\"] = FieldTypes.PROMPT.value\n\n # Re-process the template to update variables when mode changes\n template_value = build_config.get(\"template\", {}).get(\"value\", \"\")\n if template_value:\n # Ensure custom_fields is properly initialized\n if \"custom_fields\" not in build_config:\n build_config[\"custom_fields\"] = {}\n\n # Clean up fields from the OLD mode before processing with NEW mode\n # This ensures we don't keep fields with wrong syntax even if validation fails\n old_custom_fields = build_config[\"custom_fields\"].get(\"template\", [])\n for old_field in list(old_custom_fields):\n # Remove the field from custom_fields and template\n if old_field in old_custom_fields:\n old_custom_fields.remove(old_field)\n build_config.pop(old_field, None)\n\n # Try to process template with new mode to add new variables\n # If validation fails, at least we cleaned up old fields\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(template_value)\n\n # Re-process template with new mode to add new variables\n _ = process_prompt_template(\n template=template_value,\n name=\"template\",\n custom_fields=build_config[\"custom_fields\"],\n frontend_node_template=build_config,\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, we still updated the mode and cleaned old fields\n # User will see error when they try to save\n pass\n return build_config\n\n async def build_prompt(self) -> Message:\n use_double_brackets = self.use_double_brackets if hasattr(self, \"use_double_brackets\") else False\n template_format = \"mustache\" if use_double_brackets else \"f-string\"\n prompt = await Message.from_template_and_variables(template_format=template_format, **self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n use_double_brackets = frontend_node[\"template\"].get(\"use_double_brackets\", {}).get(\"value\", False)\n is_mustache = use_double_brackets is True\n\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(prompt_template)\n\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, don't add variables but allow component to be created\n pass\n return frontend_node\n\n async def update_frontend_node(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = await super().update_frontend_node(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n use_double_brackets = frontend_node[\"template\"].get(\"use_double_brackets\", {}).get(\"value\", False)\n is_mustache = use_double_brackets is True\n\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(template)\n\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, don't add variables but allow component to be updated\n pass\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n" + "value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom.custom_component.component import Component\nfrom langflow.inputs.inputs import DefaultPromptField\nfrom langflow.io import MessageTextInput, Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"braces\"\n trace_type = \"prompt\"\n name = \"Prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n MessageTextInput(\n name=\"tool_placeholder\",\n display_name=\"Tool Placeholder\",\n tool_mode=True,\n advanced=True,\n info=\"A placeholder input for tool mode.\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(self) -> Message:\n prompt = Message.from_template(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n )\n return frontend_node\n\n async def update_frontend_node(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = await super().update_frontend_node(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n" }, "template": { "_input_type": "PromptInput", @@ -931,27 +972,6 @@ "trace_as_metadata": true, "type": "str", "value": "" - }, - "use_double_brackets": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "Use Double Brackets", - "dynamic": false, - "info": "Use {{variable}} syntax instead of {variable}.", - "list": false, - "list_add_label": "Add More", - "name": "use_double_brackets", - "override_skip": false, - "placeholder": "", - "real_time_refresh": true, - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "track_in_telemetry": true, - "type": "bool", - "value": false } }, "tool_mode": false @@ -960,9 +980,9 @@ "type": "Prompt" }, "dragging": false, - "id": "Prompt-7PuDH", + "id": "Prompt-Ph34L", "measured": { - "height": 260, + "height": 284, "width": 320 }, "position": { @@ -979,8 +999,8 @@ { "data": { "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt Template", - "id": "Prompt-RcCgD", + "display_name": "Prompt", + "id": "Prompt-vc20t", "node": { "base_classes": [ "Message" @@ -991,29 +1011,17 @@ "template": [] }, "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt Template", + "display_name": "Prompt", "documentation": "", "edited": false, "field_order": [ "template" ], "frozen": false, - "icon": "prompts", + "icon": "braces", "legacy": false, "lf_version": "1.5.0", - "metadata": { - "code_hash": "42558628ed51", - "dependencies": { - "dependencies": [ - { - "name": "lfx", - "version": null - } - ], - "total_dependencies": 1 - }, - "module": "lfx.components.models_and_agents.prompt.PromptComponent" - }, + "metadata": {}, "output_types": [], "outputs": [ { @@ -1050,7 +1058,7 @@ "show": true, "title_case": false, "type": "code", - "value": "from typing import Any\n\nfrom lfx.base.prompts.api_utils import process_prompt_template\nfrom lfx.custom.custom_component.component import Component\nfrom lfx.inputs.input_mixin import FieldTypes\nfrom lfx.inputs.inputs import DefaultPromptField\nfrom lfx.io import BoolInput, MessageTextInput, Output, PromptInput\nfrom lfx.schema.dotdict import dotdict\nfrom lfx.schema.message import Message\nfrom lfx.template.utils import update_template_values\nfrom lfx.utils.mustache_security import validate_mustache_template\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt Template\"\n description: str = \"Create a prompt template with dynamic variables.\"\n documentation: str = \"https://docs.langflow.org/components-prompts\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n name = \"Prompt Template\"\n priority = 0 # Set priority to 0 to make it appear first\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n BoolInput(\n name=\"use_double_brackets\",\n display_name=\"Use Double Brackets\",\n value=False,\n advanced=True,\n info=\"Use {{variable}} syntax instead of {variable}.\",\n real_time_refresh=True,\n ),\n MessageTextInput(\n name=\"tool_placeholder\",\n display_name=\"Tool Placeholder\",\n tool_mode=True,\n advanced=True,\n info=\"A placeholder input for tool mode.\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict:\n \"\"\"Update the template field type based on the selected mode.\"\"\"\n if field_name == \"use_double_brackets\":\n # Change the template field type based on mode\n is_mustache = field_value is True\n if is_mustache:\n build_config[\"template\"][\"type\"] = FieldTypes.MUSTACHE_PROMPT.value\n else:\n build_config[\"template\"][\"type\"] = FieldTypes.PROMPT.value\n\n # Re-process the template to update variables when mode changes\n template_value = build_config.get(\"template\", {}).get(\"value\", \"\")\n if template_value:\n # Ensure custom_fields is properly initialized\n if \"custom_fields\" not in build_config:\n build_config[\"custom_fields\"] = {}\n\n # Clean up fields from the OLD mode before processing with NEW mode\n # This ensures we don't keep fields with wrong syntax even if validation fails\n old_custom_fields = build_config[\"custom_fields\"].get(\"template\", [])\n for old_field in list(old_custom_fields):\n # Remove the field from custom_fields and template\n if old_field in old_custom_fields:\n old_custom_fields.remove(old_field)\n build_config.pop(old_field, None)\n\n # Try to process template with new mode to add new variables\n # If validation fails, at least we cleaned up old fields\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(template_value)\n\n # Re-process template with new mode to add new variables\n _ = process_prompt_template(\n template=template_value,\n name=\"template\",\n custom_fields=build_config[\"custom_fields\"],\n frontend_node_template=build_config,\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, we still updated the mode and cleaned old fields\n # User will see error when they try to save\n pass\n return build_config\n\n async def build_prompt(self) -> Message:\n use_double_brackets = self.use_double_brackets if hasattr(self, \"use_double_brackets\") else False\n template_format = \"mustache\" if use_double_brackets else \"f-string\"\n prompt = await Message.from_template_and_variables(template_format=template_format, **self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n use_double_brackets = frontend_node[\"template\"].get(\"use_double_brackets\", {}).get(\"value\", False)\n is_mustache = use_double_brackets is True\n\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(prompt_template)\n\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, don't add variables but allow component to be created\n pass\n return frontend_node\n\n async def update_frontend_node(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = await super().update_frontend_node(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n use_double_brackets = frontend_node[\"template\"].get(\"use_double_brackets\", {}).get(\"value\", False)\n is_mustache = use_double_brackets is True\n\n try:\n # Validate mustache templates for security\n if is_mustache:\n validate_mustache_template(template)\n\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n is_mustache=is_mustache,\n )\n except ValueError:\n # If validation fails, don't add variables but allow component to be updated\n pass\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n" + "value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom.custom_component.component import Component\nfrom langflow.inputs.inputs import DefaultPromptField\nfrom langflow.io import MessageTextInput, Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"braces\"\n trace_type = \"prompt\"\n name = \"Prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n MessageTextInput(\n name=\"tool_placeholder\",\n display_name=\"Tool Placeholder\",\n tool_mode=True,\n advanced=True,\n info=\"A placeholder input for tool mode.\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(self) -> Message:\n prompt = Message.from_template(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n )\n return frontend_node\n\n async def update_frontend_node(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = await super().update_frontend_node(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n" }, "template": { "_input_type": "PromptInput", @@ -1091,27 +1099,6 @@ "trace_as_metadata": true, "type": "str", "value": "" - }, - "use_double_brackets": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "Use Double Brackets", - "dynamic": false, - "info": "Use {{variable}} syntax instead of {variable}.", - "list": false, - "list_add_label": "Add More", - "name": "use_double_brackets", - "override_skip": false, - "placeholder": "", - "real_time_refresh": true, - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "track_in_telemetry": true, - "type": "bool", - "value": false } }, "tool_mode": false @@ -1120,9 +1107,9 @@ "type": "Prompt" }, "dragging": false, - "id": "Prompt-RcCgD", + "id": "Prompt-vc20t", "measured": { - "height": 260, + "height": 284, "width": 320 }, "position": { @@ -1138,7 +1125,7 @@ }, { "data": { - "id": "note-7A8gW", + "id": "note-RraDH", "node": { "description": "# Prompt chaining\n\nThis flow demonstrates chaining three prompts and three language models.\nEach prompt is specifically designed to process previous output, with each LLM call building upon previous results\n\n\n## Prerequisites\n\n* [OpenAI API Key](https://platform.openai.com/)\n\n## Quickstart\n\n1. In all **Language Model** components, add your OpenAI API key.\n2. To run the flow, open the **Playground*. An example input is provided, with other suggestions listed below.\n\n \"The increasing need for secure and user-friendly decentralized finance (DeFi) platforms that make cryptocurrency investments accessible to non-tech-savvy users.\"\n\n \"The rising popularity of immersive, augmented reality (AR) experiences for remote collaboration and virtual team-building in distributed workforces.\"\n\n \"The expanding market for smart, IoT-enabled urban farming solutions that allow city dwellers to grow their own food efficiently in small spaces.\"\n\n \"The emerging demand for AI-powered personal styling and shopping assistants that consider sustainability, body positivity, and individual style preferences.\"\n\n", "display_name": "", @@ -1149,7 +1136,7 @@ }, "dragging": false, "height": 920, - "id": "note-7A8gW", + "id": "note-RraDH", "measured": { "height": 920, "width": 521 @@ -1162,21 +1149,2175 @@ "selected": false, "type": "noteNode", "width": 521 + }, + { + "data": { + "id": "LanguageModelComponent-Q5bRY", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "conditional_paths": [], + "custom_fields": {}, + "description": "Runs a language model given a specified provider.", + "display_name": "Language Model", + "documentation": "https://docs.langflow.org/components-models", + "edited": false, + "field_order": [ + "model", + "api_key", + "base_url_ibm_watsonx", + "project_id", + "ollama_base_url", + "input_value", + "system_message", + "stream", + "temperature", + "max_tokens" + ], + "frozen": false, + "icon": "brain-circuit", + "last_updated": "2026-02-03T17:50:39.662Z", + "legacy": false, + "metadata": { + "code_hash": "07d0ce9ea77e", + "dependencies": { + "dependencies": [ + { + "name": "lfx", + "version": null + } + ], + "total_dependencies": 1 + }, + "keywords": [ + "model", + "llm", + "language model", + "large language model" + ], + "module": "lfx.components.models_and_agents.language_model.LanguageModelComponent" + }, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Model Response", + "group_outputs": false, + "loop_types": null, + "method": "text_response", + "name": "text_output", + "options": null, + "required_inputs": null, + "selected": "Message", + "tool_mode": true, + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "group_outputs": false, + "loop_types": null, + "method": "build_model", + "name": "model_output", + "options": null, + "required_inputs": null, + "selected": "LanguageModel", + "tool_mode": true, + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "priority": 0, + "template": { + "_frontend_node_flow_id": { + "value": "52c2f293-f061-4de4-b85d-1797345315cd" + }, + "_frontend_node_folder_id": { + "value": "aef5b25f-4aef-4e08-b410-3bacfd40f7f9" + }, + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": true, + "display_name": "API Key", + "dynamic": false, + "info": "Model Provider API key", + "input_types": [], + "load_from_db": false, + "name": "api_key", + "override_skip": false, + "password": true, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "title_case": false, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "base_url_ibm_watsonx": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "watsonx API Endpoint", + "dynamic": false, + "external_options": {}, + "info": "The base URL of the API (IBM watsonx.ai only)", + "name": "base_url_ibm_watsonx", + "options": [ + "https://us-south.ml.cloud.ibm.com", + "https://eu-de.ml.cloud.ibm.com", + "https://eu-gb.ml.cloud.ibm.com", + "https://au-syd.ml.cloud.ibm.com", + "https://jp-tok.ml.cloud.ibm.com", + "https://ca-tor.ml.cloud.ibm.com" + ], + "options_metadata": [], + "override_skip": false, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": false, + "title_case": false, + "toggle": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "str", + "value": "https://us-south.ml.cloud.ibm.com" + }, + "code": { + "advanced": true, + "dynamic": true, + "fileTypes": [], + "file_path": "", + "info": "", + "list": false, + "load_from_db": false, + "multiline": true, + "name": "code", + "password": false, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "code", + "value": "from 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 IntInput, 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 IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n info=\"Maximum number of tokens to generate. Field name varies by provider.\",\n advanced=True,\n range_spec=RangeSpec(min=1, max=128000, step=1, step_type=\"int\"),\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 max_tokens=getattr(self, \"max_tokens\", None),\n watsonx_url=getattr(self, \"base_url_ibm_watsonx\", None),\n watsonx_project_id=getattr(self, \"project_id\", None),\n ollama_base_url=getattr(self, \"ollama_base_url\", None),\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 # Update model options\n build_config = 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 # Show/hide provider-specific fields based on selected model\n # Get current model value - from field_value if model is being changed, otherwise from build_config\n current_model_value = field_value if field_name == \"model\" else build_config.get(\"model\", {}).get(\"value\")\n if isinstance(current_model_value, list) and len(current_model_value) > 0:\n selected_model = current_model_value[0]\n provider = selected_model.get(\"provider\", \"\")\n\n # Show/hide watsonx fields\n is_watsonx = provider == \"IBM WatsonX\"\n build_config[\"base_url_ibm_watsonx\"][\"show\"] = is_watsonx\n build_config[\"project_id\"][\"show\"] = is_watsonx\n build_config[\"base_url_ibm_watsonx\"][\"required\"] = is_watsonx\n build_config[\"project_id\"][\"required\"] = is_watsonx\n\n # Show/hide Ollama fields\n is_ollama = provider == \"Ollama\"\n build_config[\"ollama_base_url\"][\"show\"] = is_ollama\n\n return build_config\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "The input text to send to the model", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "override_skip": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "is_refresh": false, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "Maximum number of tokens to generate. Field name varies by provider.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "override_skip": false, + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 1, + "step": 1, + "step_type": "int" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "int", + "value": 0 + }, + "model": { + "_input_type": "ModelInput", + "advanced": false, + "display_name": "Language Model", + "dynamic": false, + "external_options": { + "fields": { + "data": { + "node": { + "display_name": "Connect other models", + "icon": "CornerDownLeft", + "name": "connect_other_models" + } + } + } + }, + "info": "Select your model provider", + "input_types": [], + "list": false, + "list_add_label": "Add More", + "model_type": "language", + "name": "model", + "options": [ + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-5-20251101", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-haiku-4-5-20251001", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-sonnet-4-5-20250929", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-1-20250805", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-20250514", + "provider": "Anthropic" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5.1" + ] + }, + "name": "gpt-5.1", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5" + ] + }, + "name": "gpt-5", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-mini" + ] + }, + "name": "gpt-5-mini", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-nano" + ] + }, + "name": "gpt-5-nano", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-chat-latest" + ] + }, + "name": "gpt-5-chat-latest", + "provider": "OpenAI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-pro", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-flash", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-flash-8b", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-2.0-flash-lite", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-3-pro-preview", + "provider": "Google Generative AI" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.3", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "qwq", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.2", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.1", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "mistral", + "provider": "Ollama" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-3-2b-instruct", + "provider": "IBM WatsonX" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-3-8b-instruct", + "provider": "IBM WatsonX" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-13b-instruct-v2", + "provider": "IBM WatsonX" + } + ], + "override_skip": false, + "placeholder": "Setup Provider", + "real_time_refresh": true, + "refresh_button": true, + "required": true, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "track_in_telemetry": false, + "type": "model", + "value": [ + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-5-20251101", + "provider": "Anthropic" + } + ] + }, + "ollama_base_url": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Ollama API URL", + "dynamic": false, + "info": "Endpoint of the Ollama API (Ollama only). Defaults to http://localhost:11434", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "ollama_base_url", + "override_skip": false, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": false, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "project_id": { + "_input_type": "StrInput", + "advanced": false, + "display_name": "watsonx Project ID", + "dynamic": false, + "info": "The project ID associated with the foundation model (IBM watsonx.ai only)", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "project_id", + "override_skip": false, + "placeholder": "", + "required": false, + "show": false, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "stream": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "Stream", + "dynamic": false, + "info": "Whether to stream the response", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "override_skip": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "ai_enabled": false, + "copy_field": false, + "display_name": "System Message", + "dynamic": false, + "info": "A system message that helps set the behavior of the assistant", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "override_skip": false, + "password": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": true, + "display_name": "Temperature", + "dynamic": false, + "info": "Controls randomness in responses", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "override_skip": false, + "placeholder": "", + "range_spec": { + "max": 1, + "min": 0, + "step": 0.01, + "step_type": "float" + }, + "required": false, + "show": true, + "slider_buttons": false, + "slider_buttons_options": [], + "slider_input": false, + "title_case": false, + "tool_mode": false, + "track_in_telemetry": false, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "selected_output": "text_output", + "showNode": true, + "type": "LanguageModelComponent" + }, + "dragging": false, + "id": "LanguageModelComponent-Q5bRY", + "measured": { + "height": 369, + "width": 320 + }, + "position": { + "x": 1956.829495677478, + "y": 510.07647141958097 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "LanguageModelComponent-ZBPrp", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "conditional_paths": [], + "custom_fields": {}, + "description": "Runs a language model given a specified provider.", + "display_name": "Language Model", + "documentation": "https://docs.langflow.org/components-models", + "edited": false, + "field_order": [ + "model", + "api_key", + "base_url_ibm_watsonx", + "project_id", + "ollama_base_url", + "input_value", + "system_message", + "stream", + "temperature", + "max_tokens" + ], + "frozen": false, + "icon": "brain-circuit", + "last_updated": "2026-02-03T17:50:58.836Z", + "legacy": false, + "metadata": { + "code_hash": "07d0ce9ea77e", + "dependencies": { + "dependencies": [ + { + "name": "lfx", + "version": null + } + ], + "total_dependencies": 1 + }, + "keywords": [ + "model", + "llm", + "language model", + "large language model" + ], + "module": "lfx.components.models_and_agents.language_model.LanguageModelComponent" + }, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Model Response", + "group_outputs": false, + "loop_types": null, + "method": "text_response", + "name": "text_output", + "options": null, + "required_inputs": null, + "selected": "Message", + "tool_mode": true, + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "group_outputs": false, + "loop_types": null, + "method": "build_model", + "name": "model_output", + "options": null, + "required_inputs": null, + "selected": "LanguageModel", + "tool_mode": true, + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "priority": 0, + "template": { + "_frontend_node_flow_id": { + "value": "52c2f293-f061-4de4-b85d-1797345315cd" + }, + "_frontend_node_folder_id": { + "value": "aef5b25f-4aef-4e08-b410-3bacfd40f7f9" + }, + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": true, + "display_name": "API Key", + "dynamic": false, + "info": "Model Provider API key", + "input_types": [], + "load_from_db": false, + "name": "api_key", + "override_skip": false, + "password": true, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "title_case": false, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "base_url_ibm_watsonx": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "watsonx API Endpoint", + "dynamic": false, + "external_options": {}, + "info": "The base URL of the API (IBM watsonx.ai only)", + "name": "base_url_ibm_watsonx", + "options": [ + "https://us-south.ml.cloud.ibm.com", + "https://eu-de.ml.cloud.ibm.com", + "https://eu-gb.ml.cloud.ibm.com", + "https://au-syd.ml.cloud.ibm.com", + "https://jp-tok.ml.cloud.ibm.com", + "https://ca-tor.ml.cloud.ibm.com" + ], + "options_metadata": [], + "override_skip": false, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": false, + "title_case": false, + "toggle": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "str", + "value": "https://us-south.ml.cloud.ibm.com" + }, + "code": { + "advanced": true, + "dynamic": true, + "fileTypes": [], + "file_path": "", + "info": "", + "list": false, + "load_from_db": false, + "multiline": true, + "name": "code", + "password": false, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "code", + "value": "from 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 IntInput, 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 IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n info=\"Maximum number of tokens to generate. Field name varies by provider.\",\n advanced=True,\n range_spec=RangeSpec(min=1, max=128000, step=1, step_type=\"int\"),\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 max_tokens=getattr(self, \"max_tokens\", None),\n watsonx_url=getattr(self, \"base_url_ibm_watsonx\", None),\n watsonx_project_id=getattr(self, \"project_id\", None),\n ollama_base_url=getattr(self, \"ollama_base_url\", None),\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 # Update model options\n build_config = 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 # Show/hide provider-specific fields based on selected model\n # Get current model value - from field_value if model is being changed, otherwise from build_config\n current_model_value = field_value if field_name == \"model\" else build_config.get(\"model\", {}).get(\"value\")\n if isinstance(current_model_value, list) and len(current_model_value) > 0:\n selected_model = current_model_value[0]\n provider = selected_model.get(\"provider\", \"\")\n\n # Show/hide watsonx fields\n is_watsonx = provider == \"IBM WatsonX\"\n build_config[\"base_url_ibm_watsonx\"][\"show\"] = is_watsonx\n build_config[\"project_id\"][\"show\"] = is_watsonx\n build_config[\"base_url_ibm_watsonx\"][\"required\"] = is_watsonx\n build_config[\"project_id\"][\"required\"] = is_watsonx\n\n # Show/hide Ollama fields\n is_ollama = provider == \"Ollama\"\n build_config[\"ollama_base_url\"][\"show\"] = is_ollama\n\n return build_config\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "The input text to send to the model", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "override_skip": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "is_refresh": false, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "Maximum number of tokens to generate. Field name varies by provider.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "override_skip": false, + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 1, + "step": 1, + "step_type": "int" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "int", + "value": 0 + }, + "model": { + "_input_type": "ModelInput", + "advanced": false, + "display_name": "Language Model", + "dynamic": false, + "external_options": { + "fields": { + "data": { + "node": { + "display_name": "Connect other models", + "icon": "CornerDownLeft", + "name": "connect_other_models" + } + } + } + }, + "info": "Select your model provider", + "input_types": [], + "list": false, + "list_add_label": "Add More", + "model_type": "language", + "name": "model", + "options": [ + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-5-20251101", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-haiku-4-5-20251001", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-sonnet-4-5-20250929", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-1-20250805", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-20250514", + "provider": "Anthropic" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5.1" + ] + }, + "name": "gpt-5.1", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5" + ] + }, + "name": "gpt-5", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-mini" + ] + }, + "name": "gpt-5-mini", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-nano" + ] + }, + "name": "gpt-5-nano", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-chat-latest" + ] + }, + "name": "gpt-5-chat-latest", + "provider": "OpenAI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-pro", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-flash", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-flash-8b", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-2.0-flash-lite", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-3-pro-preview", + "provider": "Google Generative AI" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.3", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "qwq", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.2", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.1", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "mistral", + "provider": "Ollama" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-3-2b-instruct", + "provider": "IBM WatsonX" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-3-8b-instruct", + "provider": "IBM WatsonX" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-13b-instruct-v2", + "provider": "IBM WatsonX" + } + ], + "override_skip": false, + "placeholder": "Setup Provider", + "real_time_refresh": true, + "refresh_button": true, + "required": true, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "track_in_telemetry": false, + "type": "model", + "value": [ + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-5-20251101", + "provider": "Anthropic" + } + ] + }, + "ollama_base_url": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Ollama API URL", + "dynamic": false, + "info": "Endpoint of the Ollama API (Ollama only). Defaults to http://localhost:11434", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "ollama_base_url", + "override_skip": false, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": false, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "project_id": { + "_input_type": "StrInput", + "advanced": false, + "display_name": "watsonx Project ID", + "dynamic": false, + "info": "The project ID associated with the foundation model (IBM watsonx.ai only)", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "project_id", + "override_skip": false, + "placeholder": "", + "required": false, + "show": false, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "stream": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "Stream", + "dynamic": false, + "info": "Whether to stream the response", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "override_skip": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "ai_enabled": false, + "copy_field": false, + "display_name": "System Message", + "dynamic": false, + "info": "A system message that helps set the behavior of the assistant", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "override_skip": false, + "password": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": true, + "display_name": "Temperature", + "dynamic": false, + "info": "Controls randomness in responses", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "override_skip": false, + "placeholder": "", + "range_spec": { + "max": 1, + "min": 0, + "step": 0.01, + "step_type": "float" + }, + "required": false, + "show": true, + "slider_buttons": false, + "slider_buttons_options": [], + "slider_input": false, + "title_case": false, + "tool_mode": false, + "track_in_telemetry": false, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "selected_output": "text_output", + "showNode": true, + "type": "LanguageModelComponent" + }, + "dragging": false, + "id": "LanguageModelComponent-ZBPrp", + "measured": { + "height": 369, + "width": 320 + }, + "position": { + "x": 2403.914916304805, + "y": 775.0159799394784 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "LanguageModelComponent-YIUOh", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "conditional_paths": [], + "custom_fields": {}, + "description": "Runs a language model given a specified provider.", + "display_name": "Language Model", + "documentation": "https://docs.langflow.org/components-models", + "edited": false, + "field_order": [ + "model", + "api_key", + "base_url_ibm_watsonx", + "project_id", + "ollama_base_url", + "input_value", + "system_message", + "stream", + "temperature", + "max_tokens" + ], + "frozen": false, + "icon": "brain-circuit", + "last_updated": "2026-02-03T17:51:09.488Z", + "legacy": false, + "metadata": { + "code_hash": "07d0ce9ea77e", + "dependencies": { + "dependencies": [ + { + "name": "lfx", + "version": null + } + ], + "total_dependencies": 1 + }, + "keywords": [ + "model", + "llm", + "language model", + "large language model" + ], + "module": "lfx.components.models_and_agents.language_model.LanguageModelComponent" + }, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Model Response", + "group_outputs": false, + "loop_types": null, + "method": "text_response", + "name": "text_output", + "options": null, + "required_inputs": null, + "selected": "Message", + "tool_mode": true, + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "group_outputs": false, + "loop_types": null, + "method": "build_model", + "name": "model_output", + "options": null, + "required_inputs": null, + "selected": "LanguageModel", + "tool_mode": true, + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "priority": 0, + "template": { + "_frontend_node_flow_id": { + "value": "52c2f293-f061-4de4-b85d-1797345315cd" + }, + "_frontend_node_folder_id": { + "value": "aef5b25f-4aef-4e08-b410-3bacfd40f7f9" + }, + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": true, + "display_name": "API Key", + "dynamic": false, + "info": "Model Provider API key", + "input_types": [], + "load_from_db": false, + "name": "api_key", + "override_skip": false, + "password": true, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "title_case": false, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "base_url_ibm_watsonx": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "watsonx API Endpoint", + "dynamic": false, + "external_options": {}, + "info": "The base URL of the API (IBM watsonx.ai only)", + "name": "base_url_ibm_watsonx", + "options": [ + "https://us-south.ml.cloud.ibm.com", + "https://eu-de.ml.cloud.ibm.com", + "https://eu-gb.ml.cloud.ibm.com", + "https://au-syd.ml.cloud.ibm.com", + "https://jp-tok.ml.cloud.ibm.com", + "https://ca-tor.ml.cloud.ibm.com" + ], + "options_metadata": [], + "override_skip": false, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": false, + "title_case": false, + "toggle": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "str", + "value": "https://us-south.ml.cloud.ibm.com" + }, + "code": { + "advanced": true, + "dynamic": true, + "fileTypes": [], + "file_path": "", + "info": "", + "list": false, + "load_from_db": false, + "multiline": true, + "name": "code", + "password": false, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "code", + "value": "from 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 IntInput, 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 IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n info=\"Maximum number of tokens to generate. Field name varies by provider.\",\n advanced=True,\n range_spec=RangeSpec(min=1, max=128000, step=1, step_type=\"int\"),\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 max_tokens=getattr(self, \"max_tokens\", None),\n watsonx_url=getattr(self, \"base_url_ibm_watsonx\", None),\n watsonx_project_id=getattr(self, \"project_id\", None),\n ollama_base_url=getattr(self, \"ollama_base_url\", None),\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 # Update model options\n build_config = 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 # Show/hide provider-specific fields based on selected model\n # Get current model value - from field_value if model is being changed, otherwise from build_config\n current_model_value = field_value if field_name == \"model\" else build_config.get(\"model\", {}).get(\"value\")\n if isinstance(current_model_value, list) and len(current_model_value) > 0:\n selected_model = current_model_value[0]\n provider = selected_model.get(\"provider\", \"\")\n\n # Show/hide watsonx fields\n is_watsonx = provider == \"IBM WatsonX\"\n build_config[\"base_url_ibm_watsonx\"][\"show\"] = is_watsonx\n build_config[\"project_id\"][\"show\"] = is_watsonx\n build_config[\"base_url_ibm_watsonx\"][\"required\"] = is_watsonx\n build_config[\"project_id\"][\"required\"] = is_watsonx\n\n # Show/hide Ollama fields\n is_ollama = provider == \"Ollama\"\n build_config[\"ollama_base_url\"][\"show\"] = is_ollama\n\n return build_config\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "The input text to send to the model", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "override_skip": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "is_refresh": false, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "Maximum number of tokens to generate. Field name varies by provider.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "override_skip": false, + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 1, + "step": 1, + "step_type": "int" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "int", + "value": 0 + }, + "model": { + "_input_type": "ModelInput", + "advanced": false, + "display_name": "Language Model", + "dynamic": false, + "external_options": { + "fields": { + "data": { + "node": { + "display_name": "Connect other models", + "icon": "CornerDownLeft", + "name": "connect_other_models" + } + } + } + }, + "info": "Select your model provider", + "input_types": [], + "list": false, + "list_add_label": "Add More", + "model_type": "language", + "name": "model", + "options": [ + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-5-20251101", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-haiku-4-5-20251001", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-sonnet-4-5-20250929", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-1-20250805", + "provider": "Anthropic" + }, + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-20250514", + "provider": "Anthropic" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5.1" + ] + }, + "name": "gpt-5.1", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5" + ] + }, + "name": "gpt-5", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-mini" + ] + }, + "name": "gpt-5-mini", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-nano" + ] + }, + "name": "gpt-5-nano", + "provider": "OpenAI" + }, + { + "category": "OpenAI", + "icon": "OpenAI", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatOpenAI", + "model_name_param": "model", + "reasoning_models": [ + "gpt-5-chat-latest" + ] + }, + "name": "gpt-5-chat-latest", + "provider": "OpenAI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-pro", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-flash", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-1.5-flash-8b", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-2.0-flash-lite", + "provider": "Google Generative AI" + }, + { + "category": "Google Generative AI", + "icon": "GoogleGenerativeAI", + "metadata": { + "api_key_param": "google_api_key", + "context_length": 128000, + "model_class": "ChatGoogleGenerativeAIFixed", + "model_name_param": "model" + }, + "name": "gemini-3-pro-preview", + "provider": "Google Generative AI" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.3", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "qwq", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.2", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "llama3.1", + "provider": "Ollama" + }, + { + "category": "Ollama", + "icon": "Ollama", + "metadata": { + "api_key_param": "base_url", + "base_url_param": "base_url", + "context_length": 128000, + "model_class": "ChatOllama", + "model_name_param": "model" + }, + "name": "mistral", + "provider": "Ollama" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-3-2b-instruct", + "provider": "IBM WatsonX" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-3-8b-instruct", + "provider": "IBM WatsonX" + }, + { + "category": "IBM WatsonX", + "icon": "WatsonxAI", + "metadata": { + "api_key_param": "apikey", + "context_length": 128000, + "model_class": "ChatWatsonx", + "model_name_param": "model_id", + "project_id_param": "project_id", + "url_param": "url" + }, + "name": "ibm/granite-13b-instruct-v2", + "provider": "IBM WatsonX" + } + ], + "override_skip": false, + "placeholder": "Setup Provider", + "real_time_refresh": true, + "refresh_button": true, + "required": true, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "track_in_telemetry": false, + "type": "model", + "value": [ + { + "category": "Anthropic", + "icon": "Anthropic", + "metadata": { + "api_key_param": "api_key", + "context_length": 128000, + "model_class": "ChatAnthropic", + "model_name_param": "model" + }, + "name": "claude-opus-4-5-20251101", + "provider": "Anthropic" + } + ] + }, + "ollama_base_url": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Ollama API URL", + "dynamic": false, + "info": "Endpoint of the Ollama API (Ollama only). Defaults to http://localhost:11434", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "ollama_base_url", + "override_skip": false, + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": false, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "project_id": { + "_input_type": "StrInput", + "advanced": false, + "display_name": "watsonx Project ID", + "dynamic": false, + "info": "The project ID associated with the foundation model (IBM watsonx.ai only)", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "project_id", + "override_skip": false, + "placeholder": "", + "required": false, + "show": false, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "stream": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "Stream", + "dynamic": false, + "info": "Whether to stream the response", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "override_skip": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "track_in_telemetry": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "ai_enabled": false, + "copy_field": false, + "display_name": "System Message", + "dynamic": false, + "info": "A system message that helps set the behavior of the assistant", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "override_skip": false, + "password": false, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "track_in_telemetry": false, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": true, + "display_name": "Temperature", + "dynamic": false, + "info": "Controls randomness in responses", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "override_skip": false, + "placeholder": "", + "range_spec": { + "max": 1, + "min": 0, + "step": 0.01, + "step_type": "float" + }, + "required": false, + "show": true, + "slider_buttons": false, + "slider_buttons_options": [], + "slider_input": false, + "title_case": false, + "tool_mode": false, + "track_in_telemetry": false, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "selected_output": "text_output", + "showNode": true, + "type": "LanguageModelComponent" + }, + "dragging": false, + "id": "LanguageModelComponent-YIUOh", + "measured": { + "height": 369, + "width": 320 + }, + "position": { + "x": 2815.813058456833, + "y": 1068.9332472037395 + }, + "selected": true, + "type": "genericNode" } ], "viewport": { - "x": -277.2451206894975, - "y": 97.74227843275781, - "zoom": 0.3918551313771338 + "x": -343.40137424579757, + "y": 14.567187066767758, + "zoom": 0.48312915168855225 } }, "description": "Connect multiple prompts in sequence where each output becomes the next stage's input, enabling step-by-step text processing.", "endpoint_name": null, - "id": "e1d24fdb-ce84-44ec-937f-1672d8609a35", + "id": "52c2f293-f061-4de4-b85d-1797345315cd", "is_component": false, - "last_tested_version": "1.5.0", + "last_tested_version": "1.8.0", "name": "Basic Prompt Chaining", "tags": [ "chatbots" ] -} +} \ No newline at end of file