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 fb784c675..b6cac0cf3 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,40 +2,10 @@ "data": { "edges": [ { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-jhEkE", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-FlJ4C", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-jhEkE{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-jhEkEœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-FlJ4C{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-FlJ4Cœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "OpenAIModel-jhEkE", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-jhEkEœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-FlJ4C", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-FlJ4Cœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-Lmlx2", + "id": "Prompt-PG8Vd", "name": "prompt", "output_types": [ "Message" @@ -43,26 +13,24 @@ }, "targetHandle": { "fieldName": "system_message", - "id": "OpenAIModel-cn7cK", + "id": "OpenAIModel-3VRcc", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-Lmlx2{œdataTypeœ:œPromptœ,œidœ:œPrompt-Lmlx2œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-cn7cK{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-cn7cKœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-Lmlx2", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-Lmlx2œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-cn7cK", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-cn7cKœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__Prompt-PG8Vd{œdataTypeœ:œPromptœ,œidœ:œPrompt-PG8Vdœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-3VRcc{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-3VRccœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-PG8Vd", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-PG8Vdœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-3VRcc", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-3VRccœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-MbPd9", + "id": "ChatInput-nB59E", "name": "message", "output_types": [ "Message" @@ -70,53 +38,24 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-cn7cK", + "id": "OpenAIModel-3VRcc", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-MbPd9{œdataTypeœ:œChatInputœ,œidœ:œChatInput-MbPd9œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-cn7cK{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-cn7cKœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-MbPd9", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-MbPd9œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-cn7cK", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-cn7cKœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__ChatInput-nB59E{œdataTypeœ:œChatInputœ,œidœ:œChatInput-nB59Eœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-3VRcc{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-3VRccœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-nB59E", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-nB59Eœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-3VRcc", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-3VRccœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-TbFnC", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "system_message", - "id": "OpenAIModel-xWhtK", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-TbFnC{œdataTypeœ:œPromptœ,œidœ:œPrompt-TbFnCœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-xWhtK{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-xWhtKœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-TbFnC", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-TbFnCœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-xWhtK", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-xWhtKœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "OpenAIModel", - "id": "OpenAIModel-cn7cK", + "id": "OpenAIModel-3VRcc", "name": "text_output", "output_types": [ "Message" @@ -124,26 +63,24 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-xWhtK", + "id": "OpenAIModel-01mE2", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-OpenAIModel-cn7cK{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-cn7cKœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-xWhtK{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-xWhtKœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-cn7cK", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-cn7cKœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-xWhtK", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-xWhtKœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__OpenAIModel-3VRcc{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-3VRccœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-01mE2{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-01mE2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-3VRcc", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-3VRccœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-01mE2", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-01mE2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-3CcjN", + "id": "Prompt-aDWJD", "name": "prompt", "output_types": [ "Message" @@ -151,26 +88,24 @@ }, "targetHandle": { "fieldName": "system_message", - "id": "OpenAIModel-jhEkE", + "id": "OpenAIModel-01mE2", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-3CcjN{œdataTypeœ:œPromptœ,œidœ:œPrompt-3CcjNœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-jhEkE{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-jhEkEœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-3CcjN", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-3CcjNœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-jhEkE", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-jhEkEœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__Prompt-aDWJD{œdataTypeœ:œPromptœ,œidœ:œPrompt-aDWJDœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-01mE2{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-01mE2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-aDWJD", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-aDWJDœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-01mE2", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-01mE2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "OpenAIModel", - "id": "OpenAIModel-xWhtK", + "id": "OpenAIModel-01mE2", "name": "text_output", "output_types": [ "Message" @@ -178,18 +113,68 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-jhEkE", + "id": "OpenAIModel-4DgWt", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-OpenAIModel-xWhtK{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-xWhtKœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-jhEkE{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-jhEkEœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-xWhtK", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-xWhtKœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-jhEkE", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-jhEkEœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__OpenAIModel-01mE2{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-01mE2œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-4DgWt{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-4DgWtœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-01mE2", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-01mE2œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-4DgWt", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-4DgWtœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-fv4MA", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "OpenAIModel-4DgWt", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-fv4MA{œdataTypeœ:œPromptœ,œidœ:œPrompt-fv4MAœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-4DgWt{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-4DgWtœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-fv4MA", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-fv4MAœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-4DgWt", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-4DgWtœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-4DgWt", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-PE0wW", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-4DgWt{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-4DgWtœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-PE0wW{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-PE0wWœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-4DgWt", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-4DgWtœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-PE0wW", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-PE0wWœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -197,7 +182,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-TbFnC", + "id": "Prompt-aDWJD", "node": { "base_classes": [ "Message" @@ -302,7 +287,11 @@ }, "dragging": false, "height": 260, - "id": "Prompt-TbFnC", + "id": "Prompt-aDWJD", + "measured": { + "height": 260, + "width": 360 + }, "position": { "x": 1921.9168573384, "y": 1162.4082184281983 @@ -317,7 +306,7 @@ }, { "data": { - "id": "ChatInput-MbPd9", + "id": "ChatInput-nB59E", "node": { "base_classes": [ "Message" @@ -592,7 +581,11 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-MbPd9", + "id": "ChatInput-nB59E", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1178.0239685549568, "y": 879.9087836229152 @@ -609,7 +602,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-FlJ4C", + "id": "ChatOutput-PE0wW", "node": { "base_classes": [ "Message" @@ -870,16 +863,20 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-FlJ4C", + "id": "ChatOutput-PE0wW", + "measured": { + "height": 234, + "width": 360 + }, "position": { - "x": 3363.868906129255, - "y": 1189.5351768654318 + "x": 3389.8335347035913, + "y": 1185.8259442119552 }, "positionAbsolute": { "x": 3363.868906129255, "y": 1189.5351768654318 }, - "selected": true, + "selected": false, "type": "genericNode", "width": 320 }, @@ -887,7 +884,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-3CcjN", + "id": "Prompt-fv4MA", "node": { "base_classes": [ "Message" @@ -992,7 +989,11 @@ }, "dragging": false, "height": 260, - "id": "Prompt-3CcjN", + "id": "Prompt-fv4MA", + "measured": { + "height": 260, + "width": 360 + }, "position": { "x": 2647.8305106628454, "y": 1161.2328062686402 @@ -1005,639 +1006,11 @@ "type": "genericNode", "width": 320 }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-cn7cK", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-cn7cK", - "position": { - "x": 1561.5122766985614, - "y": 805.4323582784689 - }, - "positionAbsolute": { - "x": 1561.5122766985614, - "y": 805.4323582784689 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-jhEkE", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-jhEkE", - "position": { - "x": 3013.354174710099, - "y": 800.0470124871745 - }, - "positionAbsolute": { - "x": 3013.354174710099, - "y": 800.0470124871745 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-Lmlx2", + "id": "Prompt-PG8Vd", "node": { "base_classes": [ "Message" @@ -1742,7 +1115,11 @@ }, "dragging": false, "height": 260, - "id": "Prompt-Lmlx2", + "id": "Prompt-PG8Vd", + "measured": { + "height": 260, + "width": 360 + }, "position": { "x": 1178.7099500302636, "y": 1167.8586867404465 @@ -1757,7 +1134,7 @@ }, { "data": { - "id": "note-tSZsX", + "id": "note-rGShm", "node": { "description": "### Input Examples\n1.\n \"The growing demand for personalized, AI-driven mental health support tools that can provide real-time interventions and track long-term emotional well-being.\"\n\n\n2. \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\n3. \n \"The rising popularity of immersive, augmented reality (AR) experiences for remote collaboration and virtual team-building in distributed workforces.\"\n\n\n4. \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\n5. \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": "", @@ -1770,7 +1147,11 @@ }, "dragging": false, "height": 430, - "id": "note-tSZsX", + "id": "note-rGShm", + "measured": { + "height": 430, + "width": 328 + }, "position": { "x": 528.0392006831054, "y": 973.781986567496 @@ -1790,7 +1171,7 @@ }, { "data": { - "id": "note-FCbTW", + "id": "note-ECxh2", "node": { "description": "### Prompt Chaining\n\nThis flow demonstrates fundamental prompt chaining principles:\n\n1. **Chain Structure**\n • User input → First Prompt → LLM\n • First output → Second Prompt → LLM\n • Second output → Final Prompt → LLM\n • Final output\n\n2. **Key Technique Elements**\n • Each prompt is specifically designed to process previous output\n • Output formatting ensures clean handoff between stages\n • Context flows naturally through the chain\n • Each LLM call builds upon previous results\n\n3. **Technical Implementation**\n • Multiple prompt templates working in sequence\n • Strategic input/output connections\n • Consistent message handling between stages\n • Progressive refinement through the chain\n\nThis pattern can be adapted for any use case by modifying the prompt templates while keeping the same chaining structure.", "display_name": "", @@ -1803,7 +1184,11 @@ }, "dragging": false, "height": 451, - "id": "note-FCbTW", + "id": "note-ECxh2", + "measured": { + "height": 451, + "width": 328 + }, "position": { "x": 892.4280059782889, "y": 406.2411111617474 @@ -1823,15 +1208,14 @@ }, { "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-xWhtK", + "id": "OpenAIModel-3VRcc", "node": { "base_classes": [ "LanguageModel", "Message" ], "beta": false, + "category": "models", "conditional_paths": [], "custom_fields": {}, "description": "Generates text using OpenAI LLMs.", @@ -1845,19 +1229,18 @@ "max_tokens", "model_kwargs", "json_mode", - "output_schema", "model_name", "openai_api_base", "api_key", "temperature", - "seed", - "output_parser" + "seed" ], "frozen": false, "icon": "OpenAI", + "key": "OpenAIModel", "legacy": false, - "lf_version": "1.0.19.post2", "metadata": {}, + "minimized": false, "output_types": [], "outputs": [ { @@ -1888,6 +1271,7 @@ } ], "pinned": false, + "score": 0.14285714285714285, "template": { "_type": "Component", "api_key": { @@ -1937,12 +1321,14 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "input_value", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_input": true, "trace_as_metadata": true, "type": "str", @@ -1955,11 +1341,13 @@ "dynamic": false, "info": "If True, it will output JSON regardless of passing a schema.", "list": false, + "list_add_label": "Add More", "name": "json_mode", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "bool", "value": false @@ -1971,6 +1359,7 @@ "dynamic": false, "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", "list": false, + "list_add_label": "Add More", "name": "max_tokens", "placeholder": "", "range_spec": { @@ -1982,6 +1371,7 @@ "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "int", "value": "" @@ -1993,11 +1383,13 @@ "dynamic": false, "info": "Additional keyword arguments to pass to the model.", "list": false, + "list_add_label": "Add More", "name": "model_kwargs", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_input": true, "type": "dict", "value": {} @@ -2006,6 +1398,7 @@ "_input_type": "DropdownInput", "advanced": false, "combobox": false, + "dialog_inputs": {}, "display_name": "Model Name", "dynamic": false, "info": "", @@ -2019,6 +1412,7 @@ "gpt-3.5-turbo", "gpt-3.5-turbo-0125" ], + "options_metadata": [], "placeholder": "", "required": false, "show": true, @@ -2035,12 +1429,14 @@ "dynamic": false, "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "openai_api_base", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "str", "value": "" @@ -2052,11 +1448,13 @@ "dynamic": false, "info": "The seed controls the reproducibility of the job.", "list": false, + "list_add_label": "Add More", "name": "seed", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "int", "value": 1 @@ -2068,17 +1466,19 @@ "dynamic": false, "info": "Stream the response from the model. Streaming works only in Chat.", "list": false, + "list_add_label": "Add More", "name": "stream", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "bool", "value": false }, "system_message": { - "_input_type": "MessageTextInput", + "_input_type": "MultilineInput", "advanced": false, "display_name": "System Message", "dynamic": false, @@ -2087,7 +1487,9 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, + "multiline": true, "name": "system_message", "placeholder": "", "required": false, @@ -2100,46 +1502,741 @@ "value": "" }, "temperature": { - "_input_type": "FloatInput", + "_input_type": "SliderInput", "advanced": false, "display_name": "Temperature", "dynamic": false, "info": "", - "list": false, + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", "name": "temperature", "placeholder": "", + "range_spec": { + "max": 2, + "min": 0, + "step": 0.01, + "step_type": "float" + }, "required": false, "show": true, + "slider_buttons": false, + "slider_buttons_options": [], + "slider_input": false, "title_case": false, - "trace_as_metadata": true, - "type": "float", + "tool_mode": false, + "type": "slider", "value": 0.1 } }, "tool_mode": false }, + "showNode": true, "type": "OpenAIModel" }, "dragging": false, - "height": 630, - "id": "OpenAIModel-xWhtK", - "position": { - "x": 2294.5699142425065, - "y": 796.3787911368381 + "id": "OpenAIModel-3VRcc", + "measured": { + "height": 734, + "width": 360 }, - "positionAbsolute": { - "x": 2294.5699142425065, - "y": 796.3787911368381 + "position": { + "x": 1563.1591714154865, + "y": 811.7524000203542 }, "selected": false, - "type": "genericNode", - "width": 320 + "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-01mE2", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-01mE2", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 2289.2925714867265, + "y": 849.5992204058788 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-4DgWt", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-4DgWt", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 3018.8917918926063, + "y": 844.6876489700377 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -648.2477908002534, - "y": -146.07166399594246, - "zoom": 0.5557618545546786 + "x": -659.8399794180846, + "y": -252.56300712780512, + "zoom": 0.5391950807198421 } }, "description": "Connect multiple prompts in sequence where each output becomes the next stage's input, enabling step-by-step text processing.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json b/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json index 2e9f7312b..af736f040 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json @@ -2,35 +2,11 @@ "data": { "edges": [ { - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-51zV0", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "system_message", - "id": "OpenAIModel-GtPty", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "xy-edge__Prompt-51zV0{œdataTypeœ:œPromptœ,œidœ:œPrompt-51zV0œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-GtPty{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-GtPtyœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-51zV0", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-51zV0œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-GtPty", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-GtPtyœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { + "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-5i1v3", + "id": "ChatInput-sU0vL", "name": "message", "output_types": [ "Message" @@ -38,24 +14,51 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-GtPty", + "id": "OpenAIModel-6Uq9A", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "xy-edge__ChatInput-5i1v3{œdataTypeœ:œChatInputœ,œidœ:œChatInput-5i1v3œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-GtPty{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-GtPtyœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-5i1v3", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-5i1v3œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-GtPty", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-GtPtyœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ChatInput-sU0vL{œdataTypeœ:œChatInputœ,œidœ:œChatInput-sU0vLœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-6Uq9A{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-6Uq9Aœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-sU0vL", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-sU0vLœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-6Uq9A", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-6Uq9Aœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { + "className": "", + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-a0CWD", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "OpenAIModel-6Uq9A", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "reactflow__edge-Prompt-a0CWD{œdataTypeœ:œPromptœ,œidœ:œPrompt-a0CWDœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-6Uq9A{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-6Uq9Aœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-a0CWD", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-a0CWDœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-6Uq9A", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-6Uq9Aœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "className": "", "data": { "sourceHandle": { "dataType": "OpenAIModel", - "id": "OpenAIModel-GtPty", + "id": "OpenAIModel-6Uq9A", "name": "text_output", "output_types": [ "Message" @@ -63,18 +66,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-0kSEM", + "id": "ChatOutput-S56f5", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "xy-edge__OpenAIModel-GtPty{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-GtPtyœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-0kSEM{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-0kSEMœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-GtPty", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-GtPtyœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-0kSEM", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-0kSEMœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-OpenAIModel-6Uq9A{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-6Uq9Aœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-S56f5{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-S56f5œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-6Uq9A", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-6Uq9Aœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-S56f5", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-S56f5œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -82,7 +85,7 @@ "data": { "description": "Get chat inputs from the Playground.", "display_name": "Chat Input", - "id": "ChatInput-5i1v3", + "id": "ChatInput-sU0vL", "node": { "base_classes": [ "Message" @@ -346,10 +349,10 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-5i1v3", + "id": "ChatInput-sU0vL", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 689.5720422421635, @@ -367,7 +370,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-51zV0", + "id": "Prompt-a0CWD", "node": { "base_classes": [ "Message" @@ -471,10 +474,10 @@ }, "dragging": false, "height": 260, - "id": "Prompt-51zV0", + "id": "Prompt-a0CWD", "measured": { "height": 260, - "width": 320 + "width": 360 }, "position": { "x": 690.2015147036818, @@ -490,7 +493,7 @@ }, { "data": { - "id": "undefined-uksjN", + "id": "undefined-omGwP", "node": { "description": "## 📖 README\n\nPerform basic prompting with an OpenAI model.\n\n#### Quick Start\n- Add your **OpenAI API key** to the **OpenAI Model**\n- Open the **Playground** to chat with your bot.\n\n#### Next steps:\n Experiment by changing the prompt and the OpenAI model temperature to see how the bot's responses change.", "display_name": "Read Me", @@ -502,10 +505,10 @@ }, "dragging": false, "height": 250, - "id": "undefined-uksjN", + "id": "undefined-omGwP", "measured": { "height": 250, - "width": 600 + "width": 328 }, "position": { "x": 66.38770028934243, @@ -526,7 +529,7 @@ }, { "data": { - "id": "note-krY7d", + "id": "note-bk1gl", "node": { "description": "### 💡 Add your OpenAI API key here 👇", "display_name": "", @@ -539,10 +542,10 @@ }, "dragging": false, "height": 324, - "id": "note-krY7d", + "id": "note-bk1gl", "measured": { "height": 324, - "width": 324 + "width": 326 }, "position": { "x": 1075.829573520873, @@ -563,7 +566,7 @@ }, { "data": { - "id": "ChatOutput-0kSEM", + "id": "ChatOutput-S56f5", "node": { "base_classes": [ "Message" @@ -823,10 +826,10 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-0kSEM", + "id": "ChatOutput-S56f5", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 1460.070372772908, @@ -842,7 +845,7 @@ }, { "data": { - "id": "OpenAIModel-GtPty", + "id": "OpenAIModel-6Uq9A", "node": { "base_classes": [ "LanguageModel", @@ -905,7 +908,7 @@ } ], "pinned": false, - "score": 2.220446049250313e-16, + "score": 0.14285714285714285, "template": { "_type": "Component", "api_key": { @@ -925,7 +928,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -955,6 +958,7 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "input_value", "placeholder": "", @@ -974,6 +978,7 @@ "dynamic": false, "info": "If True, it will output JSON regardless of passing a schema.", "list": false, + "list_add_label": "Add More", "name": "json_mode", "placeholder": "", "required": false, @@ -991,6 +996,7 @@ "dynamic": false, "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", "list": false, + "list_add_label": "Add More", "name": "max_tokens", "placeholder": "", "range_spec": { @@ -1014,6 +1020,7 @@ "dynamic": false, "info": "Additional keyword arguments to pass to the model.", "list": false, + "list_add_label": "Add More", "name": "model_kwargs", "placeholder": "", "required": false, @@ -1028,6 +1035,7 @@ "_input_type": "DropdownInput", "advanced": false, "combobox": false, + "dialog_inputs": {}, "display_name": "Model Name", "dynamic": false, "info": "", @@ -1041,6 +1049,7 @@ "gpt-3.5-turbo", "gpt-3.5-turbo-0125" ], + "options_metadata": [], "placeholder": "", "required": false, "show": true, @@ -1057,6 +1066,7 @@ "dynamic": false, "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "openai_api_base", "placeholder": "", @@ -1075,6 +1085,7 @@ "dynamic": false, "info": "The seed controls the reproducibility of the job.", "list": false, + "list_add_label": "Add More", "name": "seed", "placeholder": "", "required": false, @@ -1092,6 +1103,7 @@ "dynamic": false, "info": "Stream the response from the model. Streaming works only in Chat.", "list": false, + "list_add_label": "Add More", "name": "stream", "placeholder": "", "required": false, @@ -1112,6 +1124,7 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, "multiline": true, "name": "system_message", @@ -1160,23 +1173,23 @@ "type": "OpenAIModel" }, "dragging": false, - "id": "OpenAIModel-GtPty", + "id": "OpenAIModel-6Uq9A", "measured": { - "height": 770, + "height": 734, "width": 360 }, "position": { - "x": 1075.2249314800433, - "y": 729.622454137517 + "x": 1071.3015591664102, + "y": 724.6650363109242 }, - "selected": false, + "selected": true, "type": "genericNode" } ], "viewport": { - "x": -352.0739415813646, - "y": -439.19385215506, - "zoom": 0.8590218788624804 + "x": 17.718959514444805, + "y": -430.8864814643483, + "zoom": 0.8320153537381677 } }, "description": "Perform basic prompting with an OpenAI model.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json b/src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json index 923b86f95..36663d242 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json @@ -1,40 +1,13 @@ { "data": { "edges": [ - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "URL", - "id": "URL-ewId1", - "name": "data", - "output_types": [ - "Data" - ] - }, - "targetHandle": { - "fieldName": "data", - "id": "ParseData-Zwm0z", - "inputTypes": [ - "Data" - ], - "type": "other" - } - }, - "id": "reactflow__edge-URL-ewId1{œdataTypeœ:œURLœ,œidœ:œURL-ewId1œ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-ParseData-Zwm0z{œfieldNameœ:œdataœ,œidœ:œParseData-Zwm0zœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", - "source": "URL-ewId1", - "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-ewId1œ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", - "target": "ParseData-Zwm0z", - "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-Zwm0zœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" - }, { "animated": false, "className": "", "data": { "sourceHandle": { "dataType": "ParseData", - "id": "ParseData-Zwm0z", + "id": "ParseData-E96Aq", "name": "text", "output_types": [ "Message" @@ -42,7 +15,7 @@ }, "targetHandle": { "fieldName": "references", - "id": "Prompt-WTVXx", + "id": "Prompt-so3We", "inputTypes": [ "Message", "Text" @@ -50,11 +23,11 @@ "type": "str" } }, - "id": "reactflow__edge-ParseData-Zwm0z{œdataTypeœ:œParseDataœ,œidœ:œParseData-Zwm0zœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-WTVXx{œfieldNameœ:œreferencesœ,œidœ:œPrompt-WTVXxœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "ParseData-Zwm0z", - "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-Zwm0zœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-WTVXx", - "targetHandle": "{œfieldNameœ: œreferencesœ, œidœ: œPrompt-WTVXxœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ParseData-E96Aq{œdataTypeœ:œParseDataœ,œidœ:œParseData-E96Aqœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-so3We{œfieldNameœ:œreferencesœ,œidœ:œPrompt-so3Weœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "ParseData-E96Aq", + "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-E96Aqœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-so3We", + "targetHandle": "{œfieldNameœ: œreferencesœ, œidœ: œPrompt-so3Weœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -62,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-PAceh", + "id": "TextInput-NyDgC", "name": "text", "output_types": [ "Message" @@ -70,7 +43,7 @@ }, "targetHandle": { "fieldName": "instructions", - "id": "Prompt-WTVXx", + "id": "Prompt-so3We", "inputTypes": [ "Message", "Text" @@ -78,19 +51,18 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-PAceh{œdataTypeœ:œTextInputœ,œidœ:œTextInput-PAcehœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-WTVXx{œfieldNameœ:œinstructionsœ,œidœ:œPrompt-WTVXxœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-PAceh", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-PAcehœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-WTVXx", - "targetHandle": "{œfieldNameœ: œinstructionsœ, œidœ: œPrompt-WTVXxœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-NyDgC{œdataTypeœ:œTextInputœ,œidœ:œTextInput-NyDgCœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-so3We{œfieldNameœ:œinstructionsœ,œidœ:œPrompt-so3Weœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-NyDgC", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-NyDgCœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-so3We", + "targetHandle": "{œfieldNameœ: œinstructionsœ, œidœ: œPrompt-so3Weœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { - "animated": false, "className": "", "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-WTVXx", + "id": "Prompt-so3We", "name": "prompt", "output_types": [ "Message" @@ -98,26 +70,25 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-s4uQ3", + "id": "OpenAIModel-PSlnR", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-WTVXx{œdataTypeœ:œPromptœ,œidœ:œPrompt-WTVXxœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-s4uQ3{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-s4uQ3œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-WTVXx", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-WTVXxœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-s4uQ3", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-s4uQ3œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Prompt-so3We{œdataTypeœ:œPromptœ,œidœ:œPrompt-so3Weœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-PSlnR{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-PSlnRœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-so3We", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-so3Weœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-PSlnR", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-PSlnRœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, "className": "", "data": { "sourceHandle": { "dataType": "OpenAIModel", - "id": "OpenAIModel-s4uQ3", + "id": "OpenAIModel-PSlnR", "name": "text_output", "output_types": [ "Message" @@ -125,173 +96,51 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-uL64L", + "id": "ChatOutput-rX0kw", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-OpenAIModel-s4uQ3{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-s4uQ3œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-uL64L{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-uL64Lœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-s4uQ3", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-s4uQ3œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-uL64L", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-uL64Lœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-OpenAIModel-PSlnR{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-PSlnRœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-rX0kw{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-rX0kwœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-PSlnR", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-PSlnRœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-rX0kw", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-rX0kwœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "URL", + "id": "URL-3QRyA", + "name": "data", + "output_types": [ + "Data" + ] + }, + "targetHandle": { + "fieldName": "data", + "id": "ParseData-E96Aq", + "inputTypes": [ + "Data" + ], + "type": "other" + } + }, + "id": "xy-edge__URL-3QRyA{œdataTypeœ:œURLœ,œidœ:œURL-3QRyAœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-ParseData-E96Aq{œfieldNameœ:œdataœ,œidœ:œParseData-E96Aqœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "source": "URL-3QRyA", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-3QRyAœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", + "target": "ParseData-E96Aq", + "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-E96Aqœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" } ], "nodes": [ - { - "data": { - "description": "Fetch content from one or more URLs.", - "display_name": "URL", - "id": "URL-ewId1", - "node": { - "base_classes": [ - "Data" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Fetch content from one or more URLs.", - "display_name": "URL", - "documentation": "", - "edited": false, - "field_order": [ - "urls" - ], - "frozen": false, - "icon": "layout-template", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Data", - "method": "fetch_content", - "name": "data", - "selected": "Data", - "types": [ - "Data" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "fetch_content_text", - "name": "text", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "DataFrame", - "method": "as_dataframe", - "name": "dataframe", - "selected": "DataFrame", - "types": [ - "DataFrame" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "code": { - "advanced": true, - "dynamic": true, - "fileTypes": [], - "file_path": "", - "info": "", - "list": false, - "load_from_db": false, - "multiline": true, - "name": "code", - "password": false, - "placeholder": "", - "required": true, - "show": true, - "title_case": false, - "type": "code", - - "value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.dataframe import DataFrame\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Load and retrive data from specified URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n is_list=True,\n tool_mode=True,\n placeholder=\"Enter a URL...\",\n list_add_label=\"Add URL\",\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Message\", name=\"text\", method=\"fetch_content_text\"),\n Output(display_name=\"DataFrame\", name=\"dataframe\", method=\"as_dataframe\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n\n def as_dataframe(self) -> DataFrame:\n return DataFrame(self.fetch_content())\n" - }, - "format": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Output Format", - "dynamic": false, - "info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.", - "name": "format", - "options": [ - "Text", - "Raw HTML" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "Text" - }, - "urls": { - "advanced": false, - "display_name": "URLs", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": true, - "load_from_db": false, - "name": "urls", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": [ - "https://langflow.org/", - "https://docs.langflow.org/" - ] - } - } - }, - "type": "URL" - }, - "dragging": false, - "height": 418, - "id": "URL-ewId1", - "position": { - "x": 544.3302626182673, - "y": 495.2237424466647 - }, - "positionAbsolute": { - "x": 544.3302626182673, - "y": 495.2237424466647 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Convert Data into plain text following a specified template.", "display_name": "Parse Data", - "id": "ParseData-Zwm0z", + "id": "ParseData-E96Aq", "node": { "base_classes": [ "Message" @@ -423,7 +272,11 @@ }, "dragging": false, "height": 302, - "id": "ParseData-Zwm0z", + "id": "ParseData-E96Aq", + "measured": { + "height": 302, + "width": 360 + }, "position": { "x": 955.6736985046297, "y": 702.7003891105396 @@ -440,7 +293,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-WTVXx", + "id": "Prompt-so3We", "node": { "base_classes": [ "Message" @@ -593,7 +446,11 @@ }, "dragging": false, "height": 433, - "id": "Prompt-WTVXx", + "id": "Prompt-so3We", + "measured": { + "height": 433, + "width": 360 + }, "position": { "x": 1341.1018009526915, "y": 456.4098573354365 @@ -610,7 +467,7 @@ "data": { "description": "Get text inputs from the Playground.", "display_name": "Instructions", - "id": "TextInput-PAceh", + "id": "TextInput-NyDgC", "node": { "base_classes": [ "Message" @@ -694,7 +551,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-PAceh", + "id": "TextInput-NyDgC", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 955.8314364398983, "y": 402.24423846638155 @@ -711,7 +572,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-uL64L", + "id": "ChatOutput-rX0kw", "node": { "base_classes": [ "Message" @@ -955,10 +816,14 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-uL64L", + "id": "ChatOutput-rX0kw", + "measured": { + "height": 234, + "width": 360 + }, "position": { - "x": 2113.228183852361, - "y": 594.6116538574528 + "x": 2097.489047349972, + "y": 603.355618581002 }, "positionAbsolute": { "x": 2113.228183852361, @@ -970,15 +835,123 @@ }, { "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-s4uQ3", + "id": "note-o0nz4", + "node": { + "description": "## URL Component Setup\n\n**Purpose:**\nFetch and process content from the web to use as reference material for creating a blog post.\n\n**Instructions:**\n1. **Input URLs**: List the URLs of web pages whose content you want to fetch. Ensure the URLs start with `http://` or `https://`.\n2. **Select Output Format**:\n - **Text**: To extract plain text from the pages.\n - **Raw HTML**: To retrieve the raw HTML content for advanced uses.\n\n**Tips**:\n- Double-check URL formats to prevent any data fetching errors.\n- Use the '+' button to add multiple URLs as needed for comprehensive references.\n", + "display_name": "", + "documentation": "", + "template": { + "backgroundColor": "blue" + } + }, + "type": "note" + }, + "dragging": false, + "height": 329, + "id": "note-o0nz4", + "measured": { + "height": 329, + "width": 328 + }, + "position": { + "x": 484.73635938598477, + "y": 153.29803159918163 + }, + "positionAbsolute": { + "x": 484.73635938598477, + "y": 153.29803159918163 + }, + "resizing": false, + "selected": false, + "style": { + "height": 329, + "width": 414 + }, + "type": "noteNode", + "width": 414 + }, + { + "data": { + "id": "note-ioTU5", + "node": { + "description": "# Blog Writing Flow Overview\n\n**Workflow Description:**\nThis flow assists in creating a blog post by using content fetched from URLs and user-provided instructions. It combines external references and user inputs to generate coherent and context-rich text.\n\n**Components**:\n1. **URL Component**: Fetches reference content from specified web pages.\n2. **Parse Data**: Converts the fetched content into a text format.\n3. **Text Input**: Accepts user-specific instructions for the blog post.\n4. **Prompt with Variables**: Merges references and instructions into a dynamic writing prompt.\n5. **OpenAI Model**: Generates the blog post using an AI language model.\n6. **Chat Output**: Displays the final blog text for user review and further refinement.\n\n**Steps to Execute**:\n1. Enter the relevant URLs and specify the output format in the **URL Component**.\n2. Provide detailed writing **Instructions** for AI to follow.\n3. Run the flow to generate the blog and view the result in **Chat Output**.\n\n**Benefits**:\n- Simplifies blog creation by using AI to structure and write content.\n- Incorporates comprehensive reference material to enhance post depth and accuracy.", + "display_name": "", + "documentation": "", + "template": {} + }, + "type": "note" + }, + "dragging": false, + "height": 509, + "id": "note-ioTU5", + "measured": { + "height": 509, + "width": 328 + }, + "position": { + "x": -78.41970365609802, + "y": 405.04114164010207 + }, + "positionAbsolute": { + "x": -78.41970365609802, + "y": 405.04114164010207 + }, + "resizing": false, + "selected": false, + "style": { + "height": 509, + "width": 562 + }, + "type": "noteNode", + "width": 562 + }, + { + "data": { + "id": "note-OFdB9", + "node": { + "description": "## Get Your OpenAI API Key\n**Steps**:\n1. **Visit** [OpenAI's API Key Page](https://platform.openai.com/api-keys).\n\n2. **Log In/Sign Up**:\n - Log in or create a new OpenAI account.\n\n3. **Generate API Key**:\n - Click \"Create New Secret Key\" to obtain your key.\n\n4. **Store Your Key Securely**:\n - Note it down as it will only display once.\n\n5. **Enter API Key**:\n - Input your key in the OpenAI API Key field within the component setup.\n\nKeep your key safe and manage it responsibly!", + "display_name": "", + "documentation": "", + "template": { + "backgroundColor": "rose" + } + }, + "type": "note" + }, + "dragging": false, + "height": 324, + "id": "note-OFdB9", + "measured": { + "height": 324, + "width": 328 + }, + "position": { + "x": 1703.974189852056, + "y": 125.15366878585462 + }, + "positionAbsolute": { + "x": 1703.974189852056, + "y": 125.15366878585462 + }, + "resizing": false, + "selected": false, + "style": { + "height": 324, + "width": 343 + }, + "type": "noteNode", + "width": 343 + }, + { + "data": { + "id": "OpenAIModel-PSlnR", "node": { "base_classes": [ "LanguageModel", "Message" ], "beta": false, + "category": "models", "conditional_paths": [], "custom_fields": {}, "description": "Generates text using OpenAI LLMs.", @@ -987,23 +960,23 @@ "edited": false, "field_order": [ "input_value", + "system_message", + "stream", "max_tokens", "model_kwargs", "json_mode", - "output_schema", "model_name", "openai_api_base", - "openai_api_key", + "api_key", "temperature", - "stream", - "system_message", "seed" ], "frozen": false, "icon": "OpenAI", + "key": "OpenAIModel", "legacy": false, - "lf_version": "1.0.19.post2", "metadata": {}, + "minimized": false, "output_types": [], "outputs": [ { @@ -1034,6 +1007,7 @@ } ], "pinned": false, + "score": 0.001, "template": { "_type": "Component", "api_key": { @@ -1074,6 +1048,7 @@ "value": "from langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" }, "input_value": { + "_input_type": "MessageInput", "advanced": false, "display_name": "Input", "dynamic": false, @@ -1082,64 +1057,84 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "input_value", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_input": true, "trace_as_metadata": true, "type": "str", "value": "" }, "json_mode": { + "_input_type": "BoolInput", "advanced": true, "display_name": "JSON Mode", "dynamic": false, "info": "If True, it will output JSON regardless of passing a schema.", "list": false, + "list_add_label": "Add More", "name": "json_mode", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "bool", "value": false }, "max_tokens": { + "_input_type": "IntInput", "advanced": true, "display_name": "Max Tokens", "dynamic": false, "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", "list": false, + "list_add_label": "Add More", "name": "max_tokens", "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "int", "value": "" }, "model_kwargs": { + "_input_type": "DictInput", "advanced": true, "display_name": "Model Kwargs", "dynamic": false, "info": "Additional keyword arguments to pass to the model.", "list": false, + "list_add_label": "Add More", "name": "model_kwargs", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_input": true, "type": "dict", "value": {} }, "model_name": { + "_input_type": "DropdownInput", "advanced": false, + "combobox": false, + "dialog_inputs": {}, "display_name": "Model Name", "dynamic": false, "info": "", @@ -1153,212 +1148,303 @@ "gpt-3.5-turbo", "gpt-3.5-turbo-0125" ], + "options_metadata": [], "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "str", - "value": "gpt-4o" + "value": "gpt-4o-mini" }, "openai_api_base": { + "_input_type": "StrInput", "advanced": true, "display_name": "OpenAI API Base", "dynamic": false, "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "openai_api_base", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "str", "value": "" }, "seed": { + "_input_type": "IntInput", "advanced": true, "display_name": "Seed", "dynamic": false, "info": "The seed controls the reproducibility of the job.", "list": false, + "list_add_label": "Add More", "name": "seed", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "int", "value": 1 }, "stream": { + "_input_type": "BoolInput", "advanced": false, "display_name": "Stream", "dynamic": false, "info": "Stream the response from the model. Streaming works only in Chat.", "list": false, + "list_add_label": "Add More", "name": "stream", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "bool", "value": false }, "system_message": { + "_input_type": "MultilineInput", "advanced": false, "display_name": "System Message", "dynamic": false, "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], "list": false, + "list_add_label": "Add More", "load_from_db": false, + "multiline": true, "name": "system_message", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, + "trace_as_input": true, "trace_as_metadata": true, "type": "str", "value": "" }, "temperature": { + "_input_type": "SliderInput", "advanced": false, "display_name": "Temperature", "dynamic": false, "info": "", - "list": false, + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", "name": "temperature", "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-PSlnR", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 1715.4141756503298, + "y": 434.13478201304184 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "URL-3QRyA", + "node": { + "base_classes": [ + "Data", + "DataFrame", + "Message" + ], + "beta": false, + "category": "data", + "conditional_paths": [], + "custom_fields": {}, + "description": "Load and retrive data from specified URLs.", + "display_name": "URL", + "documentation": "", + "edited": false, + "field_order": [ + "urls", + "format" + ], + "frozen": false, + "icon": "layout-template", + "key": "URL", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Data", + "method": "fetch_content", + "name": "data", + "selected": "Data", + "types": [ + "Data" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "fetch_content_text", + "name": "text", + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "DataFrame", + "method": "as_dataframe", + "name": "dataframe", + "selected": "DataFrame", + "types": [ + "DataFrame" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 2.220446049250313e-16, + "template": { + "_type": "Component", + "code": { + "advanced": true, + "dynamic": true, + "fileTypes": [], + "file_path": "", + "info": "", + "list": false, + "load_from_db": false, + "multiline": true, + "name": "code", + "password": false, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "code", + "value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.dataframe import DataFrame\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Load and retrive data from specified URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n is_list=True,\n tool_mode=True,\n placeholder=\"Enter a URL...\",\n list_add_label=\"Add URL\",\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Message\", name=\"text\", method=\"fetch_content_text\"),\n Output(display_name=\"DataFrame\", name=\"dataframe\", method=\"as_dataframe\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n\n def as_dataframe(self) -> DataFrame:\n return DataFrame(self.fetch_content())\n" + }, + "format": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Output Format", + "dynamic": false, + "info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.", + "name": "format", + "options": [ + "Text", + "Raw HTML" + ], + "options_metadata": [], + "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, - "type": "float", - "value": 0.1 + "type": "str", + "value": "Text" + }, + "urls": { + "_input_type": "MessageTextInput", + "advanced": false, + "display_name": "URLs", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": true, + "list_add_label": "Add URL", + "load_from_db": false, + "name": "urls", + "placeholder": "Enter a URL...", + "required": false, + "show": true, + "title_case": false, + "tool_mode": true, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": [ + "https://langflow.org/", + "https://docs.langflow.org/" + ] } - } + }, + "tool_mode": false }, - "type": "OpenAIModel" + "showNode": true, + "type": "URL" }, "dragging": false, - "height": 495, - "id": "OpenAIModel-s4uQ3", - "position": { - "x": 1713.1213335516065, - "y": 456.3085334094866 + "id": "URL-3QRyA", + "measured": { + "height": 522, + "width": 360 }, - "positionAbsolute": { - "x": 1713.1213335516065, - "y": 456.3085334094866 + "position": { + "x": 498.72695054312635, + "y": 554.4485732587549 }, "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "note-5zVjK", - "node": { - "description": "## URL Component Setup\n\n**Purpose:**\nFetch and process content from the web to use as reference material for creating a blog post.\n\n**Instructions:**\n1. **Input URLs**: List the URLs of web pages whose content you want to fetch. Ensure the URLs start with `http://` or `https://`.\n2. **Select Output Format**:\n - **Text**: To extract plain text from the pages.\n - **Raw HTML**: To retrieve the raw HTML content for advanced uses.\n\n**Tips**:\n- Double-check URL formats to prevent any data fetching errors.\n- Use the '+' button to add multiple URLs as needed for comprehensive references.\n", - "display_name": "", - "documentation": "", - "template": { - "backgroundColor": "blue" - } - }, - "type": "note" - }, - "dragging": false, - "height": 329, - "id": "note-5zVjK", - "position": { - "x": 484.73635938598477, - "y": 153.29803159918163 - }, - "positionAbsolute": { - "x": 484.73635938598477, - "y": 153.29803159918163 - }, - "resizing": false, - "selected": false, - "style": { - "height": 329, - "width": 414 - }, - "type": "noteNode", - "width": 414 - }, - { - "data": { - "id": "note-TrHJa", - "node": { - "description": "# Blog Writing Flow Overview\n\n**Workflow Description:**\nThis flow assists in creating a blog post by using content fetched from URLs and user-provided instructions. It combines external references and user inputs to generate coherent and context-rich text.\n\n**Components**:\n1. **URL Component**: Fetches reference content from specified web pages.\n2. **Parse Data**: Converts the fetched content into a text format.\n3. **Text Input**: Accepts user-specific instructions for the blog post.\n4. **Prompt with Variables**: Merges references and instructions into a dynamic writing prompt.\n5. **OpenAI Model**: Generates the blog post using an AI language model.\n6. **Chat Output**: Displays the final blog text for user review and further refinement.\n\n**Steps to Execute**:\n1. Enter the relevant URLs and specify the output format in the **URL Component**.\n2. Provide detailed writing **Instructions** for AI to follow.\n3. Run the flow to generate the blog and view the result in **Chat Output**.\n\n**Benefits**:\n- Simplifies blog creation by using AI to structure and write content.\n- Incorporates comprehensive reference material to enhance post depth and accuracy.", - "display_name": "", - "documentation": "", - "template": {} - }, - "type": "note" - }, - "dragging": false, - "height": 509, - "id": "note-TrHJa", - "position": { - "x": -78.41970365609802, - "y": 405.04114164010207 - }, - "positionAbsolute": { - "x": -78.41970365609802, - "y": 405.04114164010207 - }, - "resizing": false, - "selected": false, - "style": { - "height": 509, - "width": 562 - }, - "type": "noteNode", - "width": 562 - }, - { - "data": { - "id": "note-b1YaN", - "node": { - "description": "## Get Your OpenAI API Key\n**Steps**:\n1. **Visit** [OpenAI's API Key Page](https://platform.openai.com/api-keys).\n\n2. **Log In/Sign Up**:\n - Log in or create a new OpenAI account.\n\n3. **Generate API Key**:\n - Click \"Create New Secret Key\" to obtain your key.\n\n4. **Store Your Key Securely**:\n - Note it down as it will only display once.\n\n5. **Enter API Key**:\n - Input your key in the OpenAI API Key field within the component setup.\n\nKeep your key safe and manage it responsibly!", - "display_name": "", - "documentation": "", - "template": { - "backgroundColor": "rose" - } - }, - "type": "note" - }, - "dragging": false, - "height": 324, - "id": "note-b1YaN", - "position": { - "x": 1703.974189852056, - "y": 125.15366878585462 - }, - "positionAbsolute": { - "x": 1703.974189852056, - "y": 125.15366878585462 - }, - "resizing": false, - "selected": false, - "style": { - "height": 324, - "width": 343 - }, - "type": "noteNode", - "width": 343 + "type": "genericNode" } ], "viewport": { - "x": 94.80835919355627, - "y": 105.45081997045315, - "zoom": 0.5284811262210728 + "x": 118.07504778051486, + "y": 77.01438585334114, + "zoom": 0.5753720075740282 } }, "description": "Auto-generate a customized blog post from instructions and referenced articles.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json b/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json index 8cb2f862f..cdfc89e7a 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "Memory", - "id": "Memory-QarNf", + "id": "Memory-xB9zW", "name": "messages_text", "output_types": [ "Message" @@ -15,7 +15,7 @@ }, "targetHandle": { "fieldName": "CHAT_HISTORY", - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", "inputTypes": [ "Message", "Text" @@ -23,12 +23,12 @@ "type": "str" } }, - "id": "reactflow__edge-Memory-QarNf{œdataTypeœ:œMemoryœ,œidœ:œMemory-QarNfœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-VXWKj{œfieldNameœ:œCHAT_HISTORYœ,œidœ:œPrompt-VXWKjœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-Memory-xB9zW{œdataTypeœ:œMemoryœ,œidœ:œMemory-xB9zWœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-t7tN0{œfieldNameœ:œCHAT_HISTORYœ,œidœ:œPrompt-t7tN0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", "selected": false, - "source": "Memory-QarNf", - "sourceHandle": "{œdataTypeœ: œMemoryœ, œidœ: œMemory-QarNfœ, œnameœ: œmessages_textœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-VXWKj", - "targetHandle": "{œfieldNameœ: œCHAT_HISTORYœ, œidœ: œPrompt-VXWKjœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "source": "Memory-xB9zW", + "sourceHandle": "{œdataTypeœ: œMemoryœ, œidœ: œMemory-xB9zWœ, œnameœ: œmessages_textœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-t7tN0", + "targetHandle": "{œfieldNameœ: œCHAT_HISTORYœ, œidœ: œPrompt-t7tN0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -36,7 +36,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-j1FgM", + "id": "ChatInput-g2Y61", "name": "message", "output_types": [ "Message" @@ -44,7 +44,7 @@ }, "targetHandle": { "fieldName": "USER_INPUT", - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", "inputTypes": [ "Message", "Text" @@ -52,66 +52,12 @@ "type": "str" } }, - "id": "reactflow__edge-ChatInput-j1FgM{œdataTypeœ:œChatInputœ,œidœ:œChatInput-j1FgMœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-VXWKj{œfieldNameœ:œUSER_INPUTœ,œidœ:œPrompt-VXWKjœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ChatInput-g2Y61{œdataTypeœ:œChatInputœ,œidœ:œChatInput-g2Y61œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-t7tN0{œfieldNameœ:œUSER_INPUTœ,œidœ:œPrompt-t7tN0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", "selected": false, - "source": "ChatInput-j1FgM", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-j1FgMœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-VXWKj", - "targetHandle": "{œfieldNameœ: œUSER_INPUTœ, œidœ: œPrompt-VXWKjœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-VXWKj", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "AnthropicModel-39lt2", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-VXWKj{œdataTypeœ:œPromptœ,œidœ:œPrompt-VXWKjœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-AnthropicModel-39lt2{œfieldNameœ:œinput_valueœ,œidœ:œAnthropicModel-39lt2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-VXWKj", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-VXWKjœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "AnthropicModel-39lt2", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAnthropicModel-39lt2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "AnthropicModel", - "id": "AnthropicModel-39lt2", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-ZCLW2", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-AnthropicModel-39lt2{œdataTypeœ:œAnthropicModelœ,œidœ:œAnthropicModel-39lt2œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-ZCLW2{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-ZCLW2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "AnthropicModel-39lt2", - "sourceHandle": "{œdataTypeœ: œAnthropicModelœ, œidœ: œAnthropicModel-39lt2œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-ZCLW2", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-ZCLW2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "ChatInput-g2Y61", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-g2Y61œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-t7tN0", + "targetHandle": "{œfieldNameœ: œUSER_INPUTœ, œidœ: œPrompt-t7tN0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -119,7 +65,7 @@ "data": { "sourceHandle": { "dataType": "URL", - "id": "URL-ynvHI", + "id": "URL-l7pdF", "name": "text", "output_types": [ "Message" @@ -127,7 +73,7 @@ }, "targetHandle": { "fieldName": "EXAMPLE_COMPONENTS", - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", "inputTypes": [ "Message", "Text" @@ -135,11 +81,11 @@ "type": "str" } }, - "id": "reactflow__edge-URL-ynvHI{œdataTypeœ:œURLœ,œidœ:œURL-ynvHIœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-VXWKj{œfieldNameœ:œEXAMPLE_COMPONENTSœ,œidœ:œPrompt-VXWKjœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "URL-ynvHI", - "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-ynvHIœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-VXWKj", - "targetHandle": "{œfieldNameœ: œEXAMPLE_COMPONENTSœ, œidœ: œPrompt-VXWKjœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-URL-l7pdF{œdataTypeœ:œURLœ,œidœ:œURL-l7pdFœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-t7tN0{œfieldNameœ:œEXAMPLE_COMPONENTSœ,œidœ:œPrompt-t7tN0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "URL-l7pdF", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-l7pdFœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-t7tN0", + "targetHandle": "{œfieldNameœ: œEXAMPLE_COMPONENTSœ, œidœ: œPrompt-t7tN0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -147,7 +93,7 @@ "data": { "sourceHandle": { "dataType": "URL", - "id": "URL-j0mBc", + "id": "URL-vp2La", "name": "text", "output_types": [ "Message" @@ -155,7 +101,7 @@ }, "targetHandle": { "fieldName": "BASE_COMPONENT_CODE", - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", "inputTypes": [ "Message", "Text" @@ -163,11 +109,11 @@ "type": "str" } }, - "id": "reactflow__edge-URL-j0mBc{œdataTypeœ:œURLœ,œidœ:œURL-j0mBcœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-VXWKj{œfieldNameœ:œBASE_COMPONENT_CODEœ,œidœ:œPrompt-VXWKjœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "URL-j0mBc", - "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-j0mBcœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-VXWKj", - "targetHandle": "{œfieldNameœ: œBASE_COMPONENT_CODEœ, œidœ: œPrompt-VXWKjœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-URL-vp2La{œdataTypeœ:œURLœ,œidœ:œURL-vp2Laœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-t7tN0{œfieldNameœ:œBASE_COMPONENT_CODEœ,œidœ:œPrompt-t7tN0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "URL-vp2La", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-vp2Laœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-t7tN0", + "targetHandle": "{œfieldNameœ: œBASE_COMPONENT_CODEœ, œidœ: œPrompt-t7tN0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -175,7 +121,7 @@ "data": { "sourceHandle": { "dataType": "URL", - "id": "URL-xqtKG", + "id": "URL-ak8Jx", "name": "text", "output_types": [ "Message" @@ -183,7 +129,7 @@ }, "targetHandle": { "fieldName": "CUSTOM_COMPONENT_CODE", - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", "inputTypes": [ "Message", "Text" @@ -191,11 +137,61 @@ "type": "str" } }, - "id": "reactflow__edge-URL-xqtKG{œdataTypeœ:œURLœ,œidœ:œURL-xqtKGœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-VXWKj{œfieldNameœ:œCUSTOM_COMPONENT_CODEœ,œidœ:œPrompt-VXWKjœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "URL-xqtKG", - "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-xqtKGœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-VXWKj", - "targetHandle": "{œfieldNameœ: œCUSTOM_COMPONENT_CODEœ, œidœ: œPrompt-VXWKjœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-URL-ak8Jx{œdataTypeœ:œURLœ,œidœ:œURL-ak8Jxœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-t7tN0{œfieldNameœ:œCUSTOM_COMPONENT_CODEœ,œidœ:œPrompt-t7tN0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "URL-ak8Jx", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-ak8Jxœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-t7tN0", + "targetHandle": "{œfieldNameœ: œCUSTOM_COMPONENT_CODEœ, œidœ: œPrompt-t7tN0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-t7tN0", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "AnthropicModel-L37Qm", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-t7tN0{œdataTypeœ:œPromptœ,œidœ:œPrompt-t7tN0œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-AnthropicModel-L37Qm{œfieldNameœ:œinput_valueœ,œidœ:œAnthropicModel-L37Qmœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-t7tN0", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-t7tN0œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "AnthropicModel-L37Qm", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAnthropicModel-L37Qmœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "AnthropicModel", + "id": "AnthropicModel-L37Qm", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-y7MoT", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__AnthropicModel-L37Qm{œdataTypeœ:œAnthropicModelœ,œidœ:œAnthropicModel-L37Qmœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-y7MoT{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-y7MoTœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "AnthropicModel-L37Qm", + "sourceHandle": "{œdataTypeœ: œAnthropicModelœ, œidœ: œAnthropicModel-L37Qmœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-y7MoT", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-y7MoTœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -203,7 +199,7 @@ "data": { "description": "Get chat inputs from the Playground.", "display_name": "Chat Input", - "id": "ChatInput-j1FgM", + "id": "ChatInput-g2Y61", "node": { "base_classes": [ "Message" @@ -484,7 +480,11 @@ }, "dragging": false, "height": 231, - "id": "ChatInput-j1FgM", + "id": "ChatInput-g2Y61", + "measured": { + "height": 231, + "width": 360 + }, "position": { "x": 1436.7228707197569, "y": 1045.2749109595 @@ -501,7 +501,7 @@ "data": { "description": "Retrieves stored chat messages from Langflow tables or an external memory.", "display_name": "Chat Memory", - "id": "Memory-QarNf", + "id": "Memory-xB9zW", "node": { "base_classes": [ "Data", @@ -728,7 +728,11 @@ }, "dragging": false, "height": 262, - "id": "Memory-QarNf", + "id": "Memory-xB9zW", + "measured": { + "height": 262, + "width": 360 + }, "position": { "x": 1830.6888981898887, "y": 946.1205963195098 @@ -745,7 +749,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", "node": { "base_classes": [ "Message" @@ -971,7 +975,11 @@ }, "dragging": false, "height": 685, - "id": "Prompt-VXWKj", + "id": "Prompt-t7tN0", + "measured": { + "height": 685, + "width": 360 + }, "position": { "x": 2219.5265974825707, "y": 521.6320563271215 @@ -988,7 +996,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-ZCLW2", + "id": "ChatOutput-y7MoT", "node": { "base_classes": [ "Message" @@ -1248,7 +1256,11 @@ }, "dragging": false, "height": 232, - "id": "ChatOutput-ZCLW2", + "id": "ChatOutput-y7MoT", + "measured": { + "height": 232, + "width": 360 + }, "position": { "x": 2947.267779013826, "y": 891.8123698756774 @@ -1263,7 +1275,7 @@ }, { "data": { - "id": "note-lkK06", + "id": "note-T4gpA", "node": { "description": "# Fetch Components code \n\nUsing the URL component we are extracting from Github, the code from a few classes to provide as example to the LLM. \n\nThis ensures we are always up to date with recent information from the codebase.", "display_name": "", @@ -1274,7 +1286,11 @@ }, "dragging": false, "height": 324, - "id": "note-lkK06", + "id": "note-T4gpA", + "measured": { + "height": 324, + "width": 328 + }, "position": { "x": 1430.2014058924922, "y": -19.30392196909918 @@ -1289,7 +1305,7 @@ }, { "data": { - "id": "note-1foCQ", + "id": "note-SQ4yw", "node": { "description": "# 🛠️ Custom Component Generator 🚀\n\nHi! I'm here to help you create custom components for Langflow. Think of me as your technical partner who can help turn your ideas into working components! \n\n## 🎯 How to Work With Me\n\n### 1. 💭 Tell Me What You Want to Build\nSimply describe what you want your component to do in plain English. For example:\n- \"I need a component that sends Slack messages\"\n- \"I want to create a tool that can process CSV files\"\n- \"I need something that can translate text\"\n\n### 2. 📚 Share Any Relevant Information\nIf you're working with a specific:\n- 🔑 API or service (just share the documentation link or main endpoints)\n- 📄 File format\n- 🔄 Data structure\n- 🔧 Existing component you want to modify\n\n### 3. 🎨 Let Me Help Design It\nI'll help by:\n- 📊 Breaking down complex requirements into manageable pieces\n- 💡 Suggesting the best way to structure inputs and outputs\n- ⚙️ Creating the component code\n- 📝 Explaining how to use it\n\n### 4. 🔄 Iterative Refinement\nWe can then:\n- ✅ Test and refine the component\n- ⭐ Add features\n- 🔧 Modify behavior\n- 🛡️ Improve error handling\n- 📖 Add documentation\n\n## 🚀 What I Can Help With\n\nI can help create components that:\n- 📊 Process different file types (CSV, JSON, Excel, etc.)\n- 🔌 Integrate with external APIs\n- 🔄 Transform data\n- 🔀 Route messages\n- 🌐 Handle web requests\n- 🎯 Parse structured data\n- ✨ And much more!\n\n## 💡 Tips for Best Results\n\n1. **Be Specific** 🎯: The more details you provide about what you want to accomplish, the better I can help.\n\n2. **Share Examples** 📋: If you have example data or specific use cases, share them.\n\n3. **Ask Questions** ❓: Don't hesitate to ask for clarification or modifications.\n\nJust start by telling me what kind of component you'd like to create, and I'll guide you through the process! \n\nReady to build something awesome? 🚀 Let's get started!", "display_name": "", @@ -1300,7 +1316,11 @@ }, "dragging": false, "height": 573, - "id": "note-1foCQ", + "id": "note-SQ4yw", + "measured": { + "height": 573, + "width": 328 + }, "position": { "x": 807.6293964045135, "y": 605.6504562080672 @@ -1320,312 +1340,7 @@ }, { "data": { - "id": "AnthropicModel-39lt2", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generate text using Anthropic Chat&Completion LLMs with prefill support.", - "display_name": "Anthropic", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model", - "anthropic_api_key", - "temperature", - "anthropic_api_url", - "prefill", - "output_parser" - ], - "frozen": false, - "icon": "Anthropic", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [ - "api_key" - ], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "Anthropic API Key", - "dynamic": false, - "info": "Your Anthropic API key.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "real_time_refresh": true, - "required": true, - "show": true, - "title_case": false, - "type": "str" - }, - "base_url": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "Anthropic API URL", - "dynamic": false, - "info": "Endpoint of the Anthropic API. Defaults to 'https://api.anthropic.com' if not specified.", - "input_types": [ - "Message" - ], - "list": false, - "list_add_label": "Add More", - "load_from_db": false, - "name": "base_url", - "placeholder": "", - "real_time_refresh": true, - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "https://api.anthropic.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 typing import Any\n\nimport requests\nfrom loguru import logger\n\nfrom langflow.base.models.anthropic_constants import ANTHROPIC_MODELS\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.io import BoolInput, DropdownInput, IntInput, MessageTextInput, SecretStrInput, SliderInput\nfrom langflow.schema.dotdict import dotdict\n\n\nclass AnthropicModelComponent(LCModelComponent):\n display_name = \"Anthropic\"\n description = \"Generate text using Anthropic Chat&Completion LLMs with prefill support.\"\n icon = \"Anthropic\"\n name = \"AnthropicModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n value=4096,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n options=ANTHROPIC_MODELS,\n refresh_button=True,\n value=ANTHROPIC_MODELS[0],\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"Anthropic API Key\",\n info=\"Your Anthropic API key.\",\n value=None,\n required=True,\n real_time_refresh=True,\n ),\n SliderInput(\n name=\"temperature\",\n display_name=\"Temperature\",\n value=0.1,\n info=\"Run inference with this temperature. Must by in the closed interval [0.0, 1.0].\",\n range_spec=RangeSpec(min=0, max=1, step=0.01),\n ),\n MessageTextInput(\n name=\"base_url\",\n display_name=\"Anthropic API URL\",\n info=\"Endpoint of the Anthropic API. Defaults to 'https://api.anthropic.com' if not specified.\",\n value=\"https://api.anthropic.com\",\n real_time_refresh=True,\n ),\n BoolInput(\n name=\"tool_model_enabled\",\n display_name=\"Enable Tool Models\",\n info=(\n \"Select if you want to use models that can work with tools. If yes, only those models will be shown.\"\n ),\n advanced=False,\n value=True,\n real_time_refresh=True,\n ),\n MessageTextInput(\n name=\"prefill\", display_name=\"Prefill\", info=\"Prefill text to guide the model's response.\", advanced=True\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n try:\n from langchain_anthropic.chat_models import ChatAnthropic\n except ImportError as e:\n msg = \"langchain_anthropic is not installed. Please install it with `pip install langchain_anthropic`.\"\n raise ImportError(msg) from e\n try:\n output = ChatAnthropic(\n model=self.model_name,\n anthropic_api_key=self.api_key,\n max_tokens_to_sample=self.max_tokens,\n temperature=self.temperature,\n anthropic_api_url=self.base_url,\n streaming=self.stream,\n )\n except Exception as e:\n msg = \"Could not connect to Anthropic API.\"\n raise ValueError(msg) from e\n\n return output\n\n def get_models(self, tool_model_enabled: bool | None = None) -> list[str]:\n try:\n import anthropic\n\n client = anthropic.Anthropic(api_key=self.api_key)\n models = client.models.list(limit=20).data\n model_ids = [model.id for model in models]\n except (ImportError, ValueError, requests.exceptions.RequestException) as e:\n logger.exception(f\"Error getting model names: {e}\")\n model_ids = ANTHROPIC_MODELS\n if tool_model_enabled:\n try:\n from langchain_anthropic.chat_models import ChatAnthropic\n except ImportError as e:\n msg = \"langchain_anthropic is not installed. Please install it with `pip install langchain_anthropic`.\"\n raise ImportError(msg) from e\n for model in model_ids:\n model_with_tool = ChatAnthropic(\n model=self.model_name,\n anthropic_api_key=self.api_key,\n anthropic_api_url=self.base_url,\n )\n if not self.supports_tool_calling(model_with_tool):\n model_ids.remove(model)\n return model_ids\n\n def _get_exception_message(self, exception: Exception) -> str | None:\n \"\"\"Get a message from an Anthropic exception.\n\n Args:\n exception (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from anthropic import BadRequestError\n except ImportError:\n return None\n if isinstance(exception, BadRequestError):\n message = exception.body.get(\"error\", {}).get(\"message\")\n if message:\n return message\n return None\n\n def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None):\n if field_name in (\"base_url\", \"model_name\", \"tool_model_enabled\", \"api_key\") and field_value:\n try:\n if len(self.api_key) == 0:\n ids = ANTHROPIC_MODELS\n else:\n try:\n ids = self.get_models(tool_model_enabled=self.tool_model_enabled)\n except (ImportError, ValueError, requests.exceptions.RequestException) as e:\n logger.exception(f\"Error getting model names: {e}\")\n ids = ANTHROPIC_MODELS\n build_config[\"model_name\"][\"options\"] = ids\n build_config[\"model_name\"][\"value\"] = ids[0]\n except Exception as e:\n msg = f\"Error getting model names: {e}\"\n raise ValueError(msg) from e\n return build_config\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 4096 - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "claude-3-5-sonnet-latest", - "claude-3-5-haiku-latest", - "claude-3-opus-latest", - "claude-3-5-sonnet-20240620", - "claude-3-5-sonnet-20241022", - "claude-3-5-haiku-20241022", - "claude-3-sonnet-20240229", - "claude-3-haiku-20240307" - ], - "placeholder": "", - "real_time_refresh": true, - "refresh_button": true, - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "prefill": { - "_input_type": "MessageTextInput", - "advanced": true, - "display_name": "Prefill", - "dynamic": false, - "info": "Prefill text to guide the model's response.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "prefill", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "Run inference with this temperature. Must by in the closed interval [0.0, 1.0].", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - }, - "tool_model_enabled": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Enable Tool Models", - "dynamic": false, - "info": "Select if you want to use models that can work with tools. If yes, only those models will be shown.", - "list": false, - "list_add_label": "Add More", - "name": "tool_model_enabled", - "placeholder": "", - "real_time_refresh": true, - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "bool", - "value": true - } - } - }, - "type": "AnthropicModel" - }, - "dragging": false, - "height": 687, - "id": "AnthropicModel-39lt2", - "position": { - "x": 2587.564685535714, - "y": 646.2448246136587 - }, - "positionAbsolute": { - "x": 2587.564685535714, - "y": 646.2448246136587 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "URL-j0mBc", + "id": "URL-vp2La", "node": { "base_classes": [ "Data", @@ -1759,7 +1474,11 @@ }, "dragging": false, "height": 365, - "id": "URL-j0mBc", + "id": "URL-vp2La", + "measured": { + "height": 365, + "width": 360 + }, "position": { "x": 1436.3617127766433, "y": 264.218898085405 @@ -1774,7 +1493,7 @@ }, { "data": { - "id": "URL-ynvHI", + "id": "URL-l7pdF", "node": { "base_classes": [ "Data", @@ -1914,7 +1633,11 @@ }, "dragging": false, "height": 661, - "id": "URL-ynvHI", + "id": "URL-l7pdF", + "measured": { + "height": 661, + "width": 360 + }, "position": { "x": 1831.5895760156684, "y": 245.62940316018893 @@ -1929,7 +1652,7 @@ }, { "data": { - "id": "URL-xqtKG", + "id": "URL-ak8Jx", "node": { "base_classes": [ "Data", @@ -2063,7 +1786,11 @@ }, "dragging": false, "height": 365, - "id": "URL-xqtKG", + "id": "URL-ak8Jx", + "measured": { + "height": 365, + "width": 360 + }, "position": { "x": 1436.982480021523, "y": 651.1409296825055 @@ -2075,12 +1802,345 @@ "selected": false, "type": "genericNode", "width": 320 + }, + { + "data": { + "id": "AnthropicModel-L37Qm", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generate text using Anthropic Chat&Completion LLMs with prefill support.", + "display_name": "Anthropic", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_name", + "api_key", + "temperature", + "base_url", + "tool_model_enabled", + "prefill" + ], + "frozen": false, + "icon": "Anthropic", + "key": "AnthropicModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [ + "api_key" + ], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.0005851173668140926, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "Anthropic API Key", + "dynamic": false, + "info": "Your Anthropic API key.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "real_time_refresh": true, + "required": true, + "show": true, + "title_case": false, + "type": "str", + "value": "" + }, + "base_url": { + "_input_type": "MessageTextInput", + "advanced": false, + "display_name": "Anthropic API URL", + "dynamic": false, + "info": "Endpoint of the Anthropic API. Defaults to 'https://api.anthropic.com' if not specified.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "base_url", + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "https://api.anthropic.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 typing import Any\n\nimport requests\nfrom loguru import logger\n\nfrom langflow.base.models.anthropic_constants import ANTHROPIC_MODELS\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.io import BoolInput, DropdownInput, IntInput, MessageTextInput, SecretStrInput, SliderInput\nfrom langflow.schema.dotdict import dotdict\n\n\nclass AnthropicModelComponent(LCModelComponent):\n display_name = \"Anthropic\"\n description = \"Generate text using Anthropic Chat&Completion LLMs with prefill support.\"\n icon = \"Anthropic\"\n name = \"AnthropicModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n value=4096,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n options=ANTHROPIC_MODELS,\n refresh_button=True,\n value=ANTHROPIC_MODELS[0],\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"Anthropic API Key\",\n info=\"Your Anthropic API key.\",\n value=None,\n required=True,\n real_time_refresh=True,\n ),\n SliderInput(\n name=\"temperature\",\n display_name=\"Temperature\",\n value=0.1,\n info=\"Run inference with this temperature. Must by in the closed interval [0.0, 1.0].\",\n range_spec=RangeSpec(min=0, max=1, step=0.01),\n ),\n MessageTextInput(\n name=\"base_url\",\n display_name=\"Anthropic API URL\",\n info=\"Endpoint of the Anthropic API. Defaults to 'https://api.anthropic.com' if not specified.\",\n value=\"https://api.anthropic.com\",\n real_time_refresh=True,\n ),\n BoolInput(\n name=\"tool_model_enabled\",\n display_name=\"Enable Tool Models\",\n info=(\n \"Select if you want to use models that can work with tools. If yes, only those models will be shown.\"\n ),\n advanced=False,\n value=True,\n real_time_refresh=True,\n ),\n MessageTextInput(\n name=\"prefill\", display_name=\"Prefill\", info=\"Prefill text to guide the model's response.\", advanced=True\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n try:\n from langchain_anthropic.chat_models import ChatAnthropic\n except ImportError as e:\n msg = \"langchain_anthropic is not installed. Please install it with `pip install langchain_anthropic`.\"\n raise ImportError(msg) from e\n try:\n output = ChatAnthropic(\n model=self.model_name,\n anthropic_api_key=self.api_key,\n max_tokens_to_sample=self.max_tokens,\n temperature=self.temperature,\n anthropic_api_url=self.base_url,\n streaming=self.stream,\n )\n except Exception as e:\n msg = \"Could not connect to Anthropic API.\"\n raise ValueError(msg) from e\n\n return output\n\n def get_models(self, tool_model_enabled: bool | None = None) -> list[str]:\n try:\n import anthropic\n\n client = anthropic.Anthropic(api_key=self.api_key)\n models = client.models.list(limit=20).data\n model_ids = [model.id for model in models]\n except (ImportError, ValueError, requests.exceptions.RequestException) as e:\n logger.exception(f\"Error getting model names: {e}\")\n model_ids = ANTHROPIC_MODELS\n if tool_model_enabled:\n try:\n from langchain_anthropic.chat_models import ChatAnthropic\n except ImportError as e:\n msg = \"langchain_anthropic is not installed. Please install it with `pip install langchain_anthropic`.\"\n raise ImportError(msg) from e\n for model in model_ids:\n model_with_tool = ChatAnthropic(\n model=self.model_name,\n anthropic_api_key=self.api_key,\n anthropic_api_url=self.base_url,\n )\n if not self.supports_tool_calling(model_with_tool):\n model_ids.remove(model)\n return model_ids\n\n def _get_exception_message(self, exception: Exception) -> str | None:\n \"\"\"Get a message from an Anthropic exception.\n\n Args:\n exception (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from anthropic import BadRequestError\n except ImportError:\n return None\n if isinstance(exception, BadRequestError):\n message = exception.body.get(\"error\", {}).get(\"message\")\n if message:\n return message\n return None\n\n def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None):\n if field_name in (\"base_url\", \"model_name\", \"tool_model_enabled\", \"api_key\") and field_value:\n try:\n if len(self.api_key) == 0:\n ids = ANTHROPIC_MODELS\n else:\n try:\n ids = self.get_models(tool_model_enabled=self.tool_model_enabled)\n except (ImportError, ValueError, requests.exceptions.RequestException) as e:\n logger.exception(f\"Error getting model names: {e}\")\n ids = ANTHROPIC_MODELS\n build_config[\"model_name\"][\"options\"] = ids\n build_config[\"model_name\"][\"value\"] = ids[0]\n except Exception as e:\n msg = f\"Error getting model names: {e}\"\n raise ValueError(msg) from e\n return build_config\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 4096 + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "claude-3-5-sonnet-latest", + "claude-3-5-haiku-latest", + "claude-3-opus-latest", + "claude-3-5-sonnet-20240620", + "claude-3-5-sonnet-20241022", + "claude-3-5-haiku-20241022", + "claude-3-sonnet-20240229", + "claude-3-haiku-20240307" + ], + "options_metadata": [], + "placeholder": "", + "refresh_button": true, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "claude-3-5-sonnet-latest" + }, + "prefill": { + "_input_type": "MessageTextInput", + "advanced": true, + "display_name": "Prefill", + "dynamic": false, + "info": "Prefill text to guide the model's response.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "prefill", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "Run inference with this temperature. Must by in the closed interval [0.0, 1.0].", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "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, + "type": "slider", + "value": 0.1 + }, + "tool_model_enabled": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Enable Tool Models", + "dynamic": false, + "info": "Select if you want to use models that can work with tools. If yes, only those models will be shown.", + "list": false, + "list_add_label": "Add More", + "name": "tool_model_enabled", + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": true + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "AnthropicModel" + }, + "dragging": false, + "id": "AnthropicModel-L37Qm", + "measured": { + "height": 896, + "width": 360 + }, + "position": { + "x": 2585.5577736139826, + "y": 454.98013556663204 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -1123.4732050518141, - "y": -154.4525805182622, - "zoom": 0.8590630148881792 + "x": -637.4755295542625, + "y": -182.36005379554103, + "zoom": 0.5837207970729746 } }, "description": "Generates well-structured code for custom components following Langflow's specifications.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json b/src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json index 362606c95..a94850bcb 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json @@ -1,66 +1,12 @@ { "data": { "edges": [ - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "ChatInput", - "id": "ChatInput-1lWBj", - "name": "message", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-HIx8w", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-ChatInput-1lWBj{œdataTypeœ:œChatInputœ,œidœ:œChatInput-1lWBjœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-HIx8w{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-HIx8wœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-1lWBj", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-1lWBjœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-HIx8w", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-HIx8wœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-HIx8w", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-hKFON", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-HIx8w{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-HIx8wœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-hKFON{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-hKFONœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-HIx8w", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-HIx8wœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-hKFON", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-hKFONœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, { "className": "", "data": { "sourceHandle": { "dataType": "File", - "id": "File-dlDLp", + "id": "File-wUadf", "name": "data", "output_types": [ "Data" @@ -68,24 +14,25 @@ }, "targetHandle": { "fieldName": "data", - "id": "ParseData-mIiSz", + "id": "ParseData-IJwYj", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "reactflow__edge-File-dlDLp{œdataTypeœ:œFileœ,œidœ:œFile-dlDLpœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-ParseData-mIiSz{œfieldNameœ:œdataœ,œidœ:œParseData-mIiSzœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", - "source": "File-dlDLp", - "sourceHandle": "{œdataTypeœ: œFileœ, œidœ: œFile-dlDLpœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", - "target": "ParseData-mIiSz", - "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-mIiSzœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-File-wUadf{œdataTypeœ:œFileœ,œidœ:œFile-wUadfœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-ParseData-IJwYj{œfieldNameœ:œdataœ,œidœ:œParseData-IJwYjœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "source": "File-wUadf", + "sourceHandle": "{œdataTypeœ: œFileœ, œidœ: œFile-wUadfœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", + "target": "ParseData-IJwYj", + "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-IJwYjœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "ParseData", - "id": "ParseData-mIiSz", + "id": "ParseData-IJwYj", "name": "text", "output_types": [ "Message" @@ -93,7 +40,7 @@ }, "targetHandle": { "fieldName": "Document", - "id": "Prompt-L5CiD", + "id": "Prompt-5ubri", "inputTypes": [ "Message", "Text" @@ -101,17 +48,42 @@ "type": "str" } }, - "id": "reactflow__edge-ParseData-mIiSz{œdataTypeœ:œParseDataœ,œidœ:œParseData-mIiSzœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-L5CiD{œfieldNameœ:œDocumentœ,œidœ:œPrompt-L5CiDœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "ParseData-mIiSz", - "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-mIiSzœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-L5CiD", - "targetHandle": "{œfieldNameœ: œDocumentœ, œidœ: œPrompt-L5CiDœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ParseData-IJwYj{œdataTypeœ:œParseDataœ,œidœ:œParseData-IJwYjœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-5ubri{œfieldNameœ:œDocumentœ,œidœ:œPrompt-5ubriœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "ParseData-IJwYj", + "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-IJwYjœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-5ubri", + "targetHandle": "{œfieldNameœ: œDocumentœ, œidœ: œPrompt-5ubriœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "ChatInput", + "id": "ChatInput-VApZJ", + "name": "message", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-toIc8", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__ChatInput-VApZJ{œdataTypeœ:œChatInputœ,œidœ:œChatInput-VApZJœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-toIc8{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-toIc8œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-VApZJ", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-VApZJœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-toIc8", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-toIc8œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-L5CiD", + "id": "Prompt-5ubri", "name": "prompt", "output_types": [ "Message" @@ -119,18 +91,43 @@ }, "targetHandle": { "fieldName": "system_message", - "id": "OpenAIModel-HIx8w", + "id": "OpenAIModel-toIc8", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-L5CiD{œdataTypeœ:œPromptœ,œidœ:œPrompt-L5CiDœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-HIx8w{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-HIx8wœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-L5CiD", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-L5CiDœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-HIx8w", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-HIx8wœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__Prompt-5ubri{œdataTypeœ:œPromptœ,œidœ:œPrompt-5ubriœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-toIc8{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-toIc8œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-5ubri", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-5ubriœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-toIc8", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-toIc8œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-toIc8", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-8lufz", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-toIc8{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-toIc8œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-8lufz{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-8lufzœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-toIc8", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-toIc8œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-8lufz", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-8lufzœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -138,7 +135,7 @@ "data": { "description": "Get chat inputs from the Playground.", "display_name": "Chat Input", - "id": "ChatInput-1lWBj", + "id": "ChatInput-VApZJ", "node": { "base_classes": [ "Message" @@ -402,7 +399,11 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-1lWBj", + "id": "ChatInput-VApZJ", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 516.7529480335185, "y": 237.04967879541528 @@ -419,7 +420,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-hKFON", + "id": "ChatOutput-8lufz", "node": { "base_classes": [ "Message" @@ -680,7 +681,11 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-hKFON", + "id": "ChatOutput-8lufz", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1631.3766926569258, "y": 136.66509468115308 @@ -697,7 +702,7 @@ "data": { "description": "Convert Data into plain text following a specified template.", "display_name": "Parse Data", - "id": "ParseData-mIiSz", + "id": "ParseData-IJwYj", "node": { "base_classes": [ "Message" @@ -829,7 +834,11 @@ }, "dragging": false, "height": 302, - "id": "ParseData-mIiSz", + "id": "ParseData-IJwYj", + "measured": { + "height": 302, + "width": 360 + }, "position": { "x": 514.8054600415829, "y": -117.1921617826383 @@ -844,7 +853,7 @@ }, { "data": { - "id": "note-Tz3ZY", + "id": "note-bAopU", "node": { "description": "## Get Your OpenAI API Key\n\n**Steps**:\n\n1. **Visit** [OpenAI's API Key Page](https://platform.openai.com/api-keys).\n\n2. **Log In/Sign Up**:\n - Log in or create a new OpenAI account.\n\n3. **Generate API Key**:\n - Click \"Create New Secret Key\" to obtain your key.\n\n4. **Store Your Key Securely**:\n - Note it down as it will only display once.\n\n5. **Enter API Key**:\n - Input your key in the OpenAI API Key field within the component setup.\n\nKeep your key safe and manage it responsibly!", "display_name": "", @@ -857,7 +866,11 @@ }, "dragging": true, "height": 325, - "id": "note-Tz3ZY", + "id": "note-bAopU", + "measured": { + "height": 325, + "width": 328 + }, "position": { "x": 1253.2038187140245, "y": -421.5721019678553 @@ -872,319 +885,7 @@ }, { "data": { - "id": "OpenAIModel-HIx8w", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-HIx8w", - "position": { - "x": 1259.2100978002586, - "y": -88.15692253090975 - }, - "positionAbsolute": { - "x": 1259.2100978002586, - "y": -88.15692253090975 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "note-XGIUa", + "id": "note-XuFcb", "node": { "description": "# Document Q&A\n\n**Purpose:**\nThis flow leverages a language model to answer questions based on content from a loaded document. It's ideal for obtaining quick insights from PDFs or other text files by asking direct questions.\n\n**Components**:\n1. **File Component**: Loads and processes your document in supported formats.\n2. **Parse Data**: Converts the loaded document into text using a specified template for consistent processing.\n3. **Prompt Component**: Forms a structured query by combining the parsed document content with user questions.\n4. **OpenAI Model**: Engages OpenAI's language model to generate responses to queries based on the document context.\n5. **Chat Input/Output**: Facilitates user queries and displays AI-generated answers seamlessly.\n\n**Steps to Use**:\n1. **Upload Document**: Use the \"File\" component to upload a document or text file you want to query.\n2. **Enter Question**: Through the \"Chat Input\" field, type your question related to the document content.\n3. **Run the Flow**: Activate the flow to process the input and generate an answer using the OpenAI model.\n4. **View Response**: Read the generated answer in the \"Chat Output\" field for immediate insights.\n\n**Benefits**:\n- Simplifies the process of extracting information from documents.\n- Provides a user-friendly interface for interactive document exploration using AI.\n", "display_name": "", @@ -1195,7 +896,11 @@ }, "dragging": false, "height": 452, - "id": "note-XGIUa", + "id": "note-XuFcb", + "measured": { + "height": 452, + "width": 328 + }, "position": { "x": -338.7070086205371, "y": -177.11912020709357 @@ -1215,7 +920,7 @@ }, { "data": { - "id": "File-dlDLp", + "id": "File-wUadf", "node": { "base_classes": [ "Data" @@ -1439,16 +1144,20 @@ }, "dragging": false, "height": 232, - "id": "File-dlDLp", + "id": "File-wUadf", + "measured": { + "height": 232, + "width": 360 + }, "position": { - "x": 155.39382083637838, - "y": -82.32805525710685 + "x": 150.6029945346864, + "y": -88.71582365936283 }, "positionAbsolute": { "x": 155.39382083637838, "y": -82.32805525710685 }, - "selected": false, + "selected": true, "type": "genericNode", "width": 320 }, @@ -1456,7 +1165,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-L5CiD", + "id": "Prompt-5ubri", "node": { "base_classes": [ "Message" @@ -1590,10 +1299,14 @@ }, "dragging": false, "height": 347, - "id": "Prompt-L5CiD", + "id": "Prompt-5ubri", + "measured": { + "height": 347, + "width": 360 + }, "position": { - "x": 895.1947781377585, - "y": -59.89409263992732 + "x": 882.4192413332464, + "y": -63.08797684105531 }, "positionAbsolute": { "x": 895.1947781377585, @@ -1602,12 +1315,354 @@ "selected": false, "type": "genericNode", "width": 320 + }, + { + "data": { + "id": "OpenAIModel-toIc8", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-toIc8", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 1257.1422612381514, + "y": -99.92567023810267 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": 262.21464656923195, - "y": 450.3754323717522, - "zoom": 0.5739369419687381 + "x": 285.05178335748246, + "y": 410.84335125276027, + "zoom": 0.6261967792362849 } }, "description": "Integrates PDF reading with a language model to answer document-specific questions. Ideal for small-scale texts, it facilitates direct queries with immediate insights.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Graph Vector Store RAG.json b/src/backend/base/langflow/initial_setup/starter_projects/Graph Vector Store RAG.json index 0a2ed0794..7efb8ced0 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Graph Vector Store RAG.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Graph Vector Store RAG.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "OpenAIEmbeddings", - "id": "OpenAIEmbeddings-8ffog", + "id": "OpenAIEmbeddings-gwVof", "name": "embeddings", "output_types": [ "Embeddings" @@ -15,19 +15,19 @@ }, "targetHandle": { "fieldName": "embedding_model", - "id": "AstraDBGraph-utoVt", + "id": "AstraDBGraph-LdFgZ", "inputTypes": [ "Embeddings" ], "type": "other" } }, - "id": "reactflow__edge-OpenAIEmbeddings-8ffog{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-8ffogœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDBGraph-utoVt{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDBGraph-utoVtœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-OpenAIEmbeddings-gwVof{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-gwVofœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDBGraph-LdFgZ{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDBGraph-LdFgZœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", "selected": false, - "source": "OpenAIEmbeddings-8ffog", - "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-8ffogœ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", - "target": "AstraDBGraph-utoVt", - "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDBGraph-utoVtœ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" + "source": "OpenAIEmbeddings-gwVof", + "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-gwVofœ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", + "target": "AstraDBGraph-LdFgZ", + "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDBGraph-LdFgZœ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -35,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-LeGl1", + "id": "ChatInput-vz6Qy", "name": "message", "output_types": [ "Message" @@ -43,19 +43,19 @@ }, "targetHandle": { "fieldName": "search_query", - "id": "AstraDBGraph-utoVt", + "id": "AstraDBGraph-LdFgZ", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-LeGl1{œdataTypeœ:œChatInputœ,œidœ:œChatInput-LeGl1œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-AstraDBGraph-utoVt{œfieldNameœ:œsearch_queryœ,œidœ:œAstraDBGraph-utoVtœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ChatInput-vz6Qy{œdataTypeœ:œChatInputœ,œidœ:œChatInput-vz6Qyœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-AstraDBGraph-LdFgZ{œfieldNameœ:œsearch_queryœ,œidœ:œAstraDBGraph-LdFgZœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "ChatInput-LeGl1", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-LeGl1œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "AstraDBGraph-utoVt", - "targetHandle": "{œfieldNameœ: œsearch_queryœ, œidœ: œAstraDBGraph-utoVtœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "ChatInput-vz6Qy", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-vz6Qyœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "AstraDBGraph-LdFgZ", + "targetHandle": "{œfieldNameœ: œsearch_queryœ, œidœ: œAstraDBGraph-LdFgZœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -63,7 +63,7 @@ "data": { "sourceHandle": { "dataType": "AstraDBGraph", - "id": "AstraDBGraph-utoVt", + "id": "AstraDBGraph-LdFgZ", "name": "search_results", "output_types": [ "Data" @@ -71,19 +71,19 @@ }, "targetHandle": { "fieldName": "data", - "id": "ParseData-fXybX", + "id": "ParseData-KSu0D", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "reactflow__edge-AstraDBGraph-utoVt{œdataTypeœ:œAstraDBGraphœ,œidœ:œAstraDBGraph-utoVtœ,œnameœ:œsearch_resultsœ,œoutput_typesœ:[œDataœ]}-ParseData-fXybX{œfieldNameœ:œdataœ,œidœ:œParseData-fXybXœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-AstraDBGraph-LdFgZ{œdataTypeœ:œAstraDBGraphœ,œidœ:œAstraDBGraph-LdFgZœ,œnameœ:œsearch_resultsœ,œoutput_typesœ:[œDataœ]}-ParseData-KSu0D{œfieldNameœ:œdataœ,œidœ:œParseData-KSu0Dœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", "selected": false, - "source": "AstraDBGraph-utoVt", - "sourceHandle": "{œdataTypeœ: œAstraDBGraphœ, œidœ: œAstraDBGraph-utoVtœ, œnameœ: œsearch_resultsœ, œoutput_typesœ: [œDataœ]}", - "target": "ParseData-fXybX", - "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-fXybXœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "source": "AstraDBGraph-LdFgZ", + "sourceHandle": "{œdataTypeœ: œAstraDBGraphœ, œidœ: œAstraDBGraph-LdFgZœ, œnameœ: œsearch_resultsœ, œoutput_typesœ: [œDataœ]}", + "target": "ParseData-KSu0D", + "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-KSu0Dœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -91,7 +91,7 @@ "data": { "sourceHandle": { "dataType": "ParseData", - "id": "ParseData-fXybX", + "id": "ParseData-KSu0D", "name": "text", "output_types": [ "Message" @@ -99,7 +99,7 @@ }, "targetHandle": { "fieldName": "context", - "id": "Prompt-5JIrF", + "id": "Prompt-YYjDd", "inputTypes": [ "Message", "Text" @@ -107,12 +107,12 @@ "type": "str" } }, - "id": "reactflow__edge-ParseData-fXybX{œdataTypeœ:œParseDataœ,œidœ:œParseData-fXybXœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-5JIrF{œfieldNameœ:œcontextœ,œidœ:œPrompt-5JIrFœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ParseData-KSu0D{œdataTypeœ:œParseDataœ,œidœ:œParseData-KSu0Dœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-YYjDd{œfieldNameœ:œcontextœ,œidœ:œPrompt-YYjDdœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", "selected": false, - "source": "ParseData-fXybX", - "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-fXybXœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-5JIrF", - "targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-5JIrFœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "source": "ParseData-KSu0D", + "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-KSu0Dœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-YYjDd", + "targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-YYjDdœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -120,7 +120,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-LeGl1", + "id": "ChatInput-vz6Qy", "name": "message", "output_types": [ "Message" @@ -128,7 +128,7 @@ }, "targetHandle": { "fieldName": "question", - "id": "Prompt-5JIrF", + "id": "Prompt-YYjDd", "inputTypes": [ "Message", "Text" @@ -136,12 +136,12 @@ "type": "str" } }, - "id": "reactflow__edge-ChatInput-LeGl1{œdataTypeœ:œChatInputœ,œidœ:œChatInput-LeGl1œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-5JIrF{œfieldNameœ:œquestionœ,œidœ:œPrompt-5JIrFœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ChatInput-vz6Qy{œdataTypeœ:œChatInputœ,œidœ:œChatInput-vz6Qyœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-YYjDd{œfieldNameœ:œquestionœ,œidœ:œPrompt-YYjDdœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", "selected": false, - "source": "ChatInput-LeGl1", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-LeGl1œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-5JIrF", - "targetHandle": "{œfieldNameœ: œquestionœ, œidœ: œPrompt-5JIrFœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "source": "ChatInput-vz6Qy", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-vz6Qyœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-YYjDd", + "targetHandle": "{œfieldNameœ: œquestionœ, œidœ: œPrompt-YYjDdœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -149,7 +149,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-5JIrF", + "id": "Prompt-YYjDd", "name": "prompt", "output_types": [ "Message" @@ -157,19 +157,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-yLcAc", + "id": "OpenAIModel-4odsT", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-5JIrF{œdataTypeœ:œPromptœ,œidœ:œPrompt-5JIrFœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-yLcAc{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-yLcAcœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-Prompt-YYjDd{œdataTypeœ:œPromptœ,œidœ:œPrompt-YYjDdœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-4odsT{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-4odsTœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "Prompt-5JIrF", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-5JIrFœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-yLcAc", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-yLcAcœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "Prompt-YYjDd", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-YYjDdœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-4odsT", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-4odsTœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -177,7 +177,7 @@ "data": { "sourceHandle": { "dataType": "OpenAIModel", - "id": "OpenAIModel-yLcAc", + "id": "OpenAIModel-4odsT", "name": "text_output", "output_types": [ "Message" @@ -185,19 +185,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-uEMmX", + "id": "ChatOutput-7mjeM", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-OpenAIModel-yLcAc{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-yLcAcœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-uEMmX{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-uEMmXœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-OpenAIModel-4odsT{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-4odsTœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-7mjeM{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-7mjeMœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "OpenAIModel-yLcAc", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-yLcAcœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-uEMmX", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-uEMmXœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "OpenAIModel-4odsT", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-4odsTœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-7mjeM", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-7mjeMœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -205,7 +205,7 @@ "data": { "sourceHandle": { "dataType": "URL", - "id": "URL-KqugB", + "id": "URL-jjkEI", "name": "data", "output_types": [ "Data" @@ -213,7 +213,7 @@ }, "targetHandle": { "fieldName": "data_input", - "id": "LanguageRecursiveTextSplitter-SCoy7", + "id": "LanguageRecursiveTextSplitter-wmtIz", "inputTypes": [ "Document", "Data" @@ -221,12 +221,12 @@ "type": "other" } }, - "id": "reactflow__edge-URL-KqugB{œdataTypeœ:œURLœ,œidœ:œURL-KqugBœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-LanguageRecursiveTextSplitter-SCoy7{œfieldNameœ:œdata_inputœ,œidœ:œLanguageRecursiveTextSplitter-SCoy7œ,œinputTypesœ:[œDocumentœ,œDataœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-URL-jjkEI{œdataTypeœ:œURLœ,œidœ:œURL-jjkEIœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-LanguageRecursiveTextSplitter-wmtIz{œfieldNameœ:œdata_inputœ,œidœ:œLanguageRecursiveTextSplitter-wmtIzœ,œinputTypesœ:[œDocumentœ,œDataœ],œtypeœ:œotherœ}", "selected": false, - "source": "URL-KqugB", - "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-KqugBœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", - "target": "LanguageRecursiveTextSplitter-SCoy7", - "targetHandle": "{œfieldNameœ: œdata_inputœ, œidœ: œLanguageRecursiveTextSplitter-SCoy7œ, œinputTypesœ: [œDocumentœ, œDataœ], œtypeœ: œotherœ}" + "source": "URL-jjkEI", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-jjkEIœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", + "target": "LanguageRecursiveTextSplitter-wmtIz", + "targetHandle": "{œfieldNameœ: œdata_inputœ, œidœ: œLanguageRecursiveTextSplitter-wmtIzœ, œinputTypesœ: [œDocumentœ, œDataœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -234,7 +234,7 @@ "data": { "sourceHandle": { "dataType": "LanguageRecursiveTextSplitter", - "id": "LanguageRecursiveTextSplitter-SCoy7", + "id": "LanguageRecursiveTextSplitter-wmtIz", "name": "data", "output_types": [ "Data" @@ -242,7 +242,7 @@ }, "targetHandle": { "fieldName": "data_input", - "id": "HtmlLinkExtractor-mn1rQ", + "id": "HtmlLinkExtractor-MyH7H", "inputTypes": [ "Document", "Data" @@ -250,12 +250,12 @@ "type": "other" } }, - "id": "reactflow__edge-LanguageRecursiveTextSplitter-SCoy7{œdataTypeœ:œLanguageRecursiveTextSplitterœ,œidœ:œLanguageRecursiveTextSplitter-SCoy7œ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-HtmlLinkExtractor-mn1rQ{œfieldNameœ:œdata_inputœ,œidœ:œHtmlLinkExtractor-mn1rQœ,œinputTypesœ:[œDocumentœ,œDataœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-LanguageRecursiveTextSplitter-wmtIz{œdataTypeœ:œLanguageRecursiveTextSplitterœ,œidœ:œLanguageRecursiveTextSplitter-wmtIzœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-HtmlLinkExtractor-MyH7H{œfieldNameœ:œdata_inputœ,œidœ:œHtmlLinkExtractor-MyH7Hœ,œinputTypesœ:[œDocumentœ,œDataœ],œtypeœ:œotherœ}", "selected": false, - "source": "LanguageRecursiveTextSplitter-SCoy7", - "sourceHandle": "{œdataTypeœ: œLanguageRecursiveTextSplitterœ, œidœ: œLanguageRecursiveTextSplitter-SCoy7œ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", - "target": "HtmlLinkExtractor-mn1rQ", - "targetHandle": "{œfieldNameœ: œdata_inputœ, œidœ: œHtmlLinkExtractor-mn1rQœ, œinputTypesœ: [œDocumentœ, œDataœ], œtypeœ: œotherœ}" + "source": "LanguageRecursiveTextSplitter-wmtIz", + "sourceHandle": "{œdataTypeœ: œLanguageRecursiveTextSplitterœ, œidœ: œLanguageRecursiveTextSplitter-wmtIzœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", + "target": "HtmlLinkExtractor-MyH7H", + "targetHandle": "{œfieldNameœ: œdata_inputœ, œidœ: œHtmlLinkExtractor-MyH7Hœ, œinputTypesœ: [œDocumentœ, œDataœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -263,7 +263,7 @@ "data": { "sourceHandle": { "dataType": "HtmlLinkExtractor", - "id": "HtmlLinkExtractor-mn1rQ", + "id": "HtmlLinkExtractor-MyH7H", "name": "data", "output_types": [ "Data" @@ -271,19 +271,19 @@ }, "targetHandle": { "fieldName": "ingest_data", - "id": "AstraDBGraph-AWG0r", + "id": "AstraDBGraph-WPnB7", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "reactflow__edge-HtmlLinkExtractor-mn1rQ{œdataTypeœ:œHtmlLinkExtractorœ,œidœ:œHtmlLinkExtractor-mn1rQœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-AstraDBGraph-AWG0r{œfieldNameœ:œingest_dataœ,œidœ:œAstraDBGraph-AWG0rœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-HtmlLinkExtractor-MyH7H{œdataTypeœ:œHtmlLinkExtractorœ,œidœ:œHtmlLinkExtractor-MyH7Hœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-AstraDBGraph-WPnB7{œfieldNameœ:œingest_dataœ,œidœ:œAstraDBGraph-WPnB7œ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", "selected": false, - "source": "HtmlLinkExtractor-mn1rQ", - "sourceHandle": "{œdataTypeœ: œHtmlLinkExtractorœ, œidœ: œHtmlLinkExtractor-mn1rQœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", - "target": "AstraDBGraph-AWG0r", - "targetHandle": "{œfieldNameœ: œingest_dataœ, œidœ: œAstraDBGraph-AWG0rœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "source": "HtmlLinkExtractor-MyH7H", + "sourceHandle": "{œdataTypeœ: œHtmlLinkExtractorœ, œidœ: œHtmlLinkExtractor-MyH7Hœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", + "target": "AstraDBGraph-WPnB7", + "targetHandle": "{œfieldNameœ: œingest_dataœ, œidœ: œAstraDBGraph-WPnB7œ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -291,7 +291,7 @@ "data": { "sourceHandle": { "dataType": "OpenAIEmbeddings", - "id": "OpenAIEmbeddings-1t24r", + "id": "OpenAIEmbeddings-SoMI2", "name": "embeddings", "output_types": [ "Embeddings" @@ -299,25 +299,25 @@ }, "targetHandle": { "fieldName": "embedding_model", - "id": "AstraDBGraph-AWG0r", + "id": "AstraDBGraph-WPnB7", "inputTypes": [ "Embeddings" ], "type": "other" } }, - "id": "reactflow__edge-OpenAIEmbeddings-1t24r{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-1t24rœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDBGraph-AWG0r{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDBGraph-AWG0rœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-OpenAIEmbeddings-SoMI2{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-SoMI2œ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDBGraph-WPnB7{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDBGraph-WPnB7œ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", "selected": false, - "source": "OpenAIEmbeddings-1t24r", - "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-1t24rœ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", - "target": "AstraDBGraph-AWG0r", - "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDBGraph-AWG0rœ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" + "source": "OpenAIEmbeddings-SoMI2", + "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-SoMI2œ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", + "target": "AstraDBGraph-WPnB7", + "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDBGraph-WPnB7œ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" } ], "nodes": [ { "data": { - "id": "ChatInput-LeGl1", + "id": "ChatInput-vz6Qy", "node": { "base_classes": [ "Message" @@ -598,7 +598,7 @@ }, "dragging": false, "height": 233, - "id": "ChatInput-LeGl1", + "id": "ChatInput-vz6Qy", "measured": { "height": 233, "width": 320 @@ -617,7 +617,7 @@ }, { "data": { - "id": "OpenAIEmbeddings-8ffog", + "id": "OpenAIEmbeddings-gwVof", "node": { "base_classes": [ "Embeddings" @@ -1099,7 +1099,7 @@ }, "dragging": false, "height": 320, - "id": "OpenAIEmbeddings-8ffog", + "id": "OpenAIEmbeddings-gwVof", "measured": { "height": 320, "width": 320 @@ -1120,7 +1120,7 @@ "data": { "description": "Implementation of Graph Vector Store using Astra DB", "display_name": "Astra DB Graph", - "id": "AstraDBGraph-utoVt", + "id": "AstraDBGraph-LdFgZ", "node": { "base_classes": [ "Data" @@ -1638,9 +1638,9 @@ "type": "AstraDBGraph" }, "dragging": false, - "id": "AstraDBGraph-utoVt", + "id": "AstraDBGraph-LdFgZ", "measured": { - "height": 610, + "height": 634, "width": 320 }, "position": { @@ -1654,7 +1654,7 @@ "data": { "description": "Convert Data into plain text following a specified template.", "display_name": "Parse Data", - "id": "ParseData-fXybX", + "id": "ParseData-KSu0D", "node": { "base_classes": [ "Data", @@ -1794,9 +1794,9 @@ "type": "ParseData" }, "dragging": false, - "id": "ParseData-fXybX", + "id": "ParseData-KSu0D", "measured": { - "height": 350, + "height": 342, "width": 320 }, "position": { @@ -1808,7 +1808,7 @@ }, { "data": { - "id": "Prompt-5JIrF", + "id": "Prompt-YYjDd", "node": { "base_classes": [ "Message" @@ -1962,9 +1962,9 @@ "type": "Prompt" }, "dragging": false, - "id": "Prompt-5JIrF", + "id": "Prompt-YYjDd", "measured": { - "height": 433, + "height": 421, "width": 320 }, "position": { @@ -1976,7 +1976,7 @@ }, { "data": { - "id": "OpenAIModel-yLcAc", + "id": "OpenAIModel-4odsT", "node": { "base_classes": [ "LanguageModel", @@ -2281,9 +2281,9 @@ "type": "OpenAIModel" }, "dragging": false, - "id": "OpenAIModel-yLcAc", + "id": "OpenAIModel-4odsT", "measured": { - "height": 688, + "height": 656, "width": 320 }, "position": { @@ -2295,7 +2295,7 @@ }, { "data": { - "id": "ChatOutput-uEMmX", + "id": "ChatOutput-7mjeM", "node": { "base_classes": [ "Message" @@ -2555,9 +2555,9 @@ "type": "ChatOutput" }, "dragging": false, - "id": "ChatOutput-uEMmX", + "id": "ChatOutput-7mjeM", "measured": { - "height": 234, + "height": 230, "width": 320 }, "position": { @@ -2569,7 +2569,7 @@ }, { "data": { - "id": "URL-KqugB", + "id": "URL-jjkEI", "node": { "base_classes": [ "Data", @@ -2720,9 +2720,9 @@ "type": "URL" }, "dragging": false, - "id": "URL-KqugB", + "id": "URL-jjkEI", "measured": { - "height": 1018, + "height": 1066, "width": 320 }, "position": { @@ -2734,7 +2734,7 @@ }, { "data": { - "id": "AstraDBGraph-AWG0r", + "id": "AstraDBGraph-WPnB7", "node": { "base_classes": [ "Data" @@ -3252,9 +3252,9 @@ "type": "AstraDBGraph" }, "dragging": false, - "id": "AstraDBGraph-AWG0r", + "id": "AstraDBGraph-WPnB7", "measured": { - "height": 610, + "height": 634, "width": 320 }, "position": { @@ -3266,7 +3266,7 @@ }, { "data": { - "id": "LanguageRecursiveTextSplitter-SCoy7", + "id": "LanguageRecursiveTextSplitter-wmtIz", "node": { "base_classes": [ "Data" @@ -3438,9 +3438,9 @@ "type": "LanguageRecursiveTextSplitter" }, "dragging": false, - "id": "LanguageRecursiveTextSplitter-SCoy7", + "id": "LanguageRecursiveTextSplitter-wmtIz", "measured": { - "height": 475, + "height": 459, "width": 320 }, "position": { @@ -3452,7 +3452,7 @@ }, { "data": { - "id": "HtmlLinkExtractor-mn1rQ", + "id": "HtmlLinkExtractor-MyH7H", "node": { "base_classes": [ "Data" @@ -3579,9 +3579,9 @@ "type": "HtmlLinkExtractor" }, "dragging": false, - "id": "HtmlLinkExtractor-mn1rQ", + "id": "HtmlLinkExtractor-MyH7H", "measured": { - "height": 329, + "height": 317, "width": 320 }, "position": { @@ -3593,7 +3593,7 @@ }, { "data": { - "id": "OpenAIEmbeddings-1t24r", + "id": "OpenAIEmbeddings-SoMI2", "node": { "base_classes": [ "Embeddings" @@ -4087,9 +4087,9 @@ "type": "OpenAIEmbeddings" }, "dragging": false, - "id": "OpenAIEmbeddings-1t24r", + "id": "OpenAIEmbeddings-SoMI2", "measured": { - "height": 320, + "height": 312, "width": 320 }, "position": { @@ -4098,18 +4098,96 @@ }, "selected": false, "type": "genericNode" + }, + { + "data": { + "id": "note-Nby9n", + "node": { + "description": "## 📖 README\n\nLoad your data into a vector database with the 📚 **Load Data** flow, and then use your data as chat context with the 🐕 **Retriever** flow.\n\n**🚨 Add your OpenAI API key as a global variable to easily add it to all of the OpenAI components in this flow.** \n\n**Quick start**\n1. Run the 📚 **Load Data** flow.\n2. Run the 🐕 **Retriever** flow.\n\n**Next steps** \n\n- Experiment by changing the prompt and the loaded data to see how the bot's responses change. ", + "display_name": "", + "documentation": "", + "template": {} + }, + "type": "note" + }, + "dragging": false, + "height": 695, + "id": "note-Nby9n", + "measured": { + "height": 695, + "width": 325 + }, + "position": { + "x": -2651.9749287591367, + "y": 6278.741596879104 + }, + "resizing": false, + "selected": false, + "type": "noteNode", + "width": 477 + }, + { + "data": { + "id": "note-o96q7", + "node": { + "description": "## 📚 1. Load Data Flow\n\nRun this first! Load data multiple urls, and embed it into the vector database in a graph based format.\n\nClick ▶️ **Run component** on the **Astra DB Graph** component to load your data.\n\n* If you're using OSS Langflow, add your Astra DB Application Token to the Astra DB component.\n\n#### Next steps:\n Experiment by changing the prompt and the contextual data to see how the retrieval flow's responses change.", + "display_name": "", + "documentation": "", + "template": {} + }, + "type": "note" + }, + "dragging": false, + "height": 499, + "id": "note-o96q7", + "measured": { + "height": 499, + "width": 325 + }, + "position": { + "x": -2156.877891666127, + "y": 5887.194729165318 + }, + "resizing": false, + "selected": false, + "type": "noteNode", + "width": 325 + }, + { + "data": { + "id": "note-Svi05", + "node": { + "description": "## 🐕 2. Retriever Flow\n\nThis flow answers your questions with contextual data retrieved from your vector database. using graph RAG.\n\nOpen the **Playground** and ask, \n\n```\nhow to create a function in Haskell ?\n```\n", + "display_name": "", + "documentation": "", + "template": {} + }, + "type": "note" + }, + "dragging": false, + "id": "note-Svi05", + "measured": { + "height": 325, + "width": 325 + }, + "position": { + "x": -2255.4854518934735, + "y": 7190.4854518934735 + }, + "selected": false, + "type": "noteNode" } ], "viewport": { - "x": 739.8038625592436, - "y": -2221.1151988349297, - "zoom": 0.3542438656259266 + "x": 1003.3024895663839, + "y": -1906.154829822026, + "zoom": 0.35536121365456846 } }, "description": "Extracts links from web pages and processes the content using Graph RAG Chain with Maximal Marginal Relevance (MMR) traversal.", "endpoint_name": null, "icon": "chartNetwork", - "id": "d671259c-c29e-466e-9bbf-622b9dccac38", + "id": "73ceae85-141a-42e3-9f41-a0749434ca0e", "is_component": false, "last_tested_version": "1.1.1", "name": "Graph RAG", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json b/src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json index c6b73cf02..09c33f5dc 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "StructuredOutputComponent", - "id": "StructuredOutputComponent-2koen", + "id": "StructuredOutputComponent-a20pA", "name": "structured_output", "output_types": [ "Data" @@ -15,18 +15,18 @@ }, "targetHandle": { "fieldName": "data", - "id": "ParseData-qwHwN", + "id": "ParseData-HAm0G", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "reactflow__edge-StructuredOutputComponent-2koen{œdataTypeœ:œStructuredOutputComponentœ,œidœ:œStructuredOutputComponent-2koenœ,œnameœ:œstructured_outputœ,œoutput_typesœ:[œDataœ]}-ParseData-qwHwN{œfieldNameœ:œdataœ,œidœ:œParseData-qwHwNœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", - "source": "StructuredOutputComponent-2koen", - "sourceHandle": "{œdataTypeœ: œStructuredOutputComponentœ, œidœ: œStructuredOutputComponent-2koenœ, œnameœ: œstructured_outputœ, œoutput_typesœ: [œDataœ]}", - "target": "ParseData-qwHwN", - "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-qwHwNœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-StructuredOutputComponent-a20pA{œdataTypeœ:œStructuredOutputComponentœ,œidœ:œStructuredOutputComponent-a20pAœ,œnameœ:œstructured_outputœ,œoutput_typesœ:[œDataœ]}-ParseData-HAm0G{œfieldNameœ:œdataœ,œidœ:œParseData-HAm0Gœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "source": "StructuredOutputComponent-a20pA", + "sourceHandle": "{œdataTypeœ: œStructuredOutputComponentœ, œidœ: œStructuredOutputComponent-a20pAœ, œnameœ: œstructured_outputœ, œoutput_typesœ: [œDataœ]}", + "target": "ParseData-HAm0G", + "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-HAm0Gœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -34,7 +34,7 @@ "data": { "sourceHandle": { "dataType": "ParseData", - "id": "ParseData-qwHwN", + "id": "ParseData-HAm0G", "name": "text", "output_types": [ "Message" @@ -42,80 +42,24 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-pZKpN", + "id": "ChatOutput-wjprm", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ParseData-qwHwN{œdataTypeœ:œParseDataœ,œidœ:œParseData-qwHwNœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-pZKpN{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-pZKpNœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ParseData-qwHwN", - "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-qwHwNœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-pZKpN", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-pZKpNœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ParseData-HAm0G{œdataTypeœ:œParseDataœ,œidœ:œParseData-HAm0Gœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-wjprm{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-wjprmœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ParseData-HAm0G", + "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-HAm0Gœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-wjprm", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-wjprmœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-9oYd2", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "StructuredOutputComponent-2koen", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-9oYd2{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-9oYd2œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-StructuredOutputComponent-2koen{œfieldNameœ:œinput_valueœ,œidœ:œStructuredOutputComponent-2koenœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-9oYd2", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-9oYd2œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "StructuredOutputComponent-2koen", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œStructuredOutputComponent-2koenœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-9oYd2", - "name": "model_output", - "output_types": [ - "LanguageModel" - ] - }, - "targetHandle": { - "fieldName": "llm", - "id": "StructuredOutputComponent-2koen", - "inputTypes": [ - "LanguageModel" - ], - "type": "other" - } - }, - "id": "reactflow__edge-OpenAIModel-9oYd2{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-9oYd2œ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutputComponent-2koen{œfieldNameœ:œllmœ,œidœ:œStructuredOutputComponent-2koenœ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}", - "source": "OpenAIModel-9oYd2", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-9oYd2œ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}", - "target": "StructuredOutputComponent-2koen", - "targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutputComponent-2koenœ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}" - }, - { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-G7si2", + "id": "ChatInput-ufYDr", "name": "message", "output_types": [ "Message" @@ -123,24 +67,24 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-9oYd2", + "id": "OpenAIModel-i45Zr", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-G7si2{œdataTypeœ:œChatInputœ,œidœ:œChatInput-G7si2œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-9oYd2{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-9oYd2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-G7si2", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-G7si2œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-9oYd2", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-9oYd2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__ChatInput-ufYDr{œdataTypeœ:œChatInputœ,œidœ:œChatInput-ufYDrœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-i45Zr{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-i45Zrœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-ufYDr", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-ufYDrœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-i45Zr", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-i45Zrœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-ySGe4", + "id": "Prompt-aZBZD", "name": "prompt", "output_types": [ "Message" @@ -148,18 +92,68 @@ }, "targetHandle": { "fieldName": "system_message", - "id": "OpenAIModel-9oYd2", + "id": "OpenAIModel-i45Zr", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-ySGe4{œdataTypeœ:œPromptœ,œidœ:œPrompt-ySGe4œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-9oYd2{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-9oYd2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-ySGe4", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-ySGe4œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-9oYd2", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-9oYd2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__Prompt-aZBZD{œdataTypeœ:œPromptœ,œidœ:œPrompt-aZBZDœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-i45Zr{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-i45Zrœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-aZBZD", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-aZBZDœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-i45Zr", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-i45Zrœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-i45Zr", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "StructuredOutputComponent-a20pA", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-i45Zr{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-i45Zrœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-StructuredOutputComponent-a20pA{œfieldNameœ:œinput_valueœ,œidœ:œStructuredOutputComponent-a20pAœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-i45Zr", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-i45Zrœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "StructuredOutputComponent-a20pA", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œStructuredOutputComponent-a20pAœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-i45Zr", + "name": "model_output", + "output_types": [ + "LanguageModel" + ] + }, + "targetHandle": { + "fieldName": "llm", + "id": "StructuredOutputComponent-a20pA", + "inputTypes": [ + "LanguageModel" + ], + "type": "other" + } + }, + "id": "xy-edge__OpenAIModel-i45Zr{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-i45Zrœ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutputComponent-a20pA{œfieldNameœ:œllmœ,œidœ:œStructuredOutputComponent-a20pAœ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}", + "source": "OpenAIModel-i45Zr", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-i45Zrœ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}", + "target": "StructuredOutputComponent-a20pA", + "targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutputComponent-a20pAœ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}" } ], "nodes": [ @@ -167,7 +161,7 @@ "data": { "description": "Get chat inputs from the Playground.", "display_name": "Chat Input", - "id": "ChatInput-G7si2", + "id": "ChatInput-ufYDr", "node": { "base_classes": [ "Message" @@ -448,7 +442,11 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-G7si2", + "id": "ChatInput-ufYDr", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1258.8272095125978, "y": 367.0048451335054 @@ -465,7 +463,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-pZKpN", + "id": "ChatOutput-wjprm", "node": { "base_classes": [ "Message" @@ -726,7 +724,11 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-pZKpN", + "id": "ChatOutput-wjprm", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 2742.72534045604, "y": 681.9098282545469 @@ -741,7 +743,7 @@ }, { "data": { - "id": "note-pSMKi", + "id": "note-QyHO0", "node": { "description": "# Image Sentiment Analysis\nWelcome to the Image Sentiment Classifier - an AI tool for quick image sentiment analysis!\n\n## Instructions\n\n1. **Prepare Your Image**\n - Image should be clear and visible\n\n2. **Upload Options**\n - Open the Playground\n - Click file attachment icon\n - Or drag and drop into playground\n\n3. **Wait for Analysis**\n - System will process the image\n - Uses zero-shot learning\n - Classification happens automatically\n\n4. **Review Results**\n - Get classification: Positive/Negative/Neutral\n - Review confidence level\n - Check reasoning if provided\n\n5. **Expected Classifications**\n - Positive: Happy scenes, smiles, celebrations\n - Negative: Sad scenes, problems, conflicts\n - Neutral: Objects, landscapes, neutral scenes\n\nRemember: The clearer the image, the more accurate the classification! 📸✨", "display_name": "", @@ -752,7 +754,11 @@ }, "dragging": false, "height": 583, - "id": "note-pSMKi", + "id": "note-QyHO0", + "measured": { + "height": 583, + "width": 328 + }, "position": { "x": 791.7294511578832, "y": 340.1333942936967 @@ -774,7 +780,7 @@ "data": { "description": "Transforms LLM responses into **structured data formats**. Ideal for extracting specific information or creating consistent outputs.", "display_name": "Structured Output", - "id": "StructuredOutputComponent-2koen", + "id": "StructuredOutputComponent-a20pA", "node": { "base_classes": [ "Data" @@ -986,7 +992,11 @@ }, "dragging": false, "height": 541, - "id": "StructuredOutputComponent-2koen", + "id": "StructuredOutputComponent-a20pA", + "measured": { + "height": 541, + "width": 360 + }, "position": { "x": 2029.441019694193, "y": 414.7974622616549 @@ -1001,7 +1011,7 @@ }, { "data": { - "id": "ParseData-qwHwN", + "id": "ParseData-HAm0G", "node": { "base_classes": [ "Message" @@ -1139,7 +1149,11 @@ }, "dragging": false, "height": 302, - "id": "ParseData-qwHwN", + "id": "ParseData-HAm0G", + "measured": { + "height": 302, + "width": 360 + }, "position": { "x": 2389.490977317181, "y": 646.9530981549555 @@ -1152,325 +1166,11 @@ "type": "genericNode", "width": 320 }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-9oYd2", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-9oYd2", - "position": { - "x": 1644.460882817477, - "y": 381.35290572159937 - }, - "positionAbsolute": { - "x": 1644.460882817477, - "y": 381.35290572159937 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-ySGe4", + "id": "Prompt-aZBZD", "node": { "base_classes": [ "Message" @@ -1575,7 +1275,11 @@ }, "dragging": false, "height": 260, - "id": "Prompt-ySGe4", + "id": "Prompt-aZBZD", + "measured": { + "height": 260, + "width": 360 + }, "position": { "x": 1262.0179832573751, "y": 632.1360181124842 @@ -1587,12 +1291,354 @@ "selected": false, "type": "genericNode", "width": 320 + }, + { + "data": { + "id": "OpenAIModel-i45Zr", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-i45Zr", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 1638.1662423437713, + "y": 374.7199736704084 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -767.6296307973882, - "y": -46.714664128928234, - "zoom": 0.798427315747602 + "x": -426.91879919031885, + "y": 21.85679755101154, + "zoom": 0.6313688898572775 } }, "description": "Analyzes images and categorizes them as positive, negative, or neutral using zero-shot learning.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json b/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json index f1370ab65..4e394cb08 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-0rzBn", + "id": "TextInput-Uonj7", "name": "text", "output_types": [ "Message" @@ -15,7 +15,7 @@ }, "targetHandle": { "fieldName": "guidelines", - "id": "Prompt-j3woL", + "id": "Prompt-DfQRZ", "inputTypes": [ "Message", "Text" @@ -23,66 +23,11 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-0rzBn{œdataTypeœ:œTextInputœ,œidœ:œTextInput-0rzBnœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-j3woL{œfieldNameœ:œguidelinesœ,œidœ:œPrompt-j3woLœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-0rzBn", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-0rzBnœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-j3woL", - "targetHandle": "{œfieldNameœ: œguidelinesœ, œidœ: œPrompt-j3woLœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-jxXfH", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "post", - "id": "Prompt-lqX5p", - "inputTypes": [ - "Message", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-jxXfH{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-jxXfHœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-lqX5p{œfieldNameœ:œpostœ,œidœ:œPrompt-lqX5pœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-jxXfH", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-jxXfHœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-lqX5p", - "targetHandle": "{œfieldNameœ: œpostœ, œidœ: œPrompt-lqX5pœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-j3woL", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-jxXfH", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-j3woL{œdataTypeœ:œPromptœ,œidœ:œPrompt-j3woLœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-jxXfH{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-jxXfHœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-j3woL", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-j3woLœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-jxXfH", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-jxXfHœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-Uonj7{œdataTypeœ:œTextInputœ,œidœ:œTextInput-Uonj7œ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-DfQRZ{œfieldNameœ:œguidelinesœ,œidœ:œPrompt-DfQRZœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-Uonj7", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-Uonj7œ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-DfQRZ", + "targetHandle": "{œfieldNameœ: œguidelinesœ, œidœ: œPrompt-DfQRZœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -90,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-pvWq5", + "id": "ChatInput-ferrV", "name": "message", "output_types": [ "Message" @@ -98,18 +43,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-TG1G2", + "id": "Agent-pNUOq", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-pvWq5{œdataTypeœ:œChatInputœ,œidœ:œChatInput-pvWq5œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-TG1G2{œfieldNameœ:œinput_valueœ,œidœ:œAgent-TG1G2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-pvWq5", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-pvWq5œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-TG1G2", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-TG1G2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ChatInput-ferrV{œdataTypeœ:œChatInputœ,œidœ:œChatInput-ferrVœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-pNUOq{œfieldNameœ:œinput_valueœ,œidœ:œAgent-pNUOqœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-ferrV", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-ferrVœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-pNUOq", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-pNUOqœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -117,7 +62,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-TG1G2", + "id": "Agent-pNUOq", "name": "response", "output_types": [ "Message" @@ -125,7 +70,7 @@ }, "targetHandle": { "fieldName": "context", - "id": "Prompt-j3woL", + "id": "Prompt-DfQRZ", "inputTypes": [ "Message", "Text" @@ -133,11 +78,11 @@ "type": "str" } }, - "id": "reactflow__edge-Agent-TG1G2{œdataTypeœ:œAgentœ,œidœ:œAgent-TG1G2œ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-j3woL{œfieldNameœ:œcontextœ,œidœ:œPrompt-j3woLœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "Agent-TG1G2", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-TG1G2œ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-j3woL", - "targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-j3woLœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-pNUOq{œdataTypeœ:œAgentœ,œidœ:œAgent-pNUOqœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-DfQRZ{œfieldNameœ:œcontextœ,œidœ:œPrompt-DfQRZœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "Agent-pNUOq", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-pNUOqœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-DfQRZ", + "targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-DfQRZœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -145,7 +90,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-lqX5p", + "id": "Prompt-R9hC2", "name": "prompt", "output_types": [ "Message" @@ -153,107 +98,25 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-Sef2w", + "id": "ChatOutput-hU0Qy", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-lqX5p{œdataTypeœ:œPromptœ,œidœ:œPrompt-lqX5pœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-Sef2w{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-Sef2wœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-lqX5p", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-lqX5pœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-Sef2w", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-Sef2wœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Prompt-R9hC2{œdataTypeœ:œPromptœ,œidœ:œPrompt-R9hC2œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-hU0Qy{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-hU0Qyœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-R9hC2", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-R9hC2œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-hU0Qy", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-hU0Qyœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-jxXfH", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "post", - "id": "Prompt-R2EK8", - "inputTypes": [ - "Message", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-jxXfH{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-jxXfHœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-R2EK8{œfieldNameœ:œpostœ,œidœ:œPrompt-R2EK8œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-jxXfH", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-jxXfHœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-R2EK8", - "targetHandle": "{œfieldNameœ: œpostœ, œidœ: œPrompt-R2EK8œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": true, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-Sef2w", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "image_description", - "id": "Prompt-R2EK8", - "inputTypes": [ - "Message", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-Sef2w{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-Sef2wœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-R2EK8{œfieldNameœ:œimage_descriptionœ,œidœ:œPrompt-R2EK8œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-Sef2w", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-Sef2wœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-R2EK8", - "targetHandle": "{œfieldNameœ: œimage_descriptionœ, œidœ: œPrompt-R2EK8œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-R2EK8", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-CnabR", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-R2EK8{œdataTypeœ:œPromptœ,œidœ:œPrompt-R2EK8œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-CnabR{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-CnabRœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-R2EK8", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-R2EK8œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-CnabR", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-CnabRœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { "data": { "sourceHandle": { "dataType": "TavilySearchComponent", - "id": "TavilySearchComponent-xQwoJ", + "id": "TavilySearchComponent-h8yAo", "name": "component_as_tool", "output_types": [ "Tool" @@ -261,24 +124,157 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-TG1G2", + "id": "Agent-pNUOq", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "xy-edge__TavilySearchComponent-xQwoJ{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-xQwoJœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-TG1G2{œfieldNameœ:œtoolsœ,œidœ:œAgent-TG1G2œ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "TavilySearchComponent-xQwoJ", - "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-xQwoJœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-TG1G2", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-TG1G2œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-TavilySearchComponent-h8yAo{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-h8yAoœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-pNUOq{œfieldNameœ:œtoolsœ,œidœ:œAgent-pNUOqœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "TavilySearchComponent-h8yAo", + "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-h8yAoœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-pNUOq", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-pNUOqœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-DfQRZ", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-N7jW7", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "reactflow__edge-Prompt-DfQRZ{œdataTypeœ:œPromptœ,œidœ:œPrompt-DfQRZœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-N7jW7{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-N7jW7œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-DfQRZ", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-DfQRZœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-N7jW7", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-N7jW7œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-N7jW7", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "post", + "id": "Prompt-OcCWU", + "inputTypes": [ + "Message", + "Text" + ], + "type": "str" + } + }, + "id": "reactflow__edge-OpenAIModel-N7jW7{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-N7jW7œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-OcCWU{œfieldNameœ:œpostœ,œidœ:œPrompt-OcCWUœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-N7jW7", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-N7jW7œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-OcCWU", + "targetHandle": "{œfieldNameœ: œpostœ, œidœ: œPrompt-OcCWUœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-N7jW7", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "post", + "id": "Prompt-R9hC2", + "inputTypes": [ + "Message", + "Text" + ], + "type": "str" + } + }, + "id": "reactflow__edge-OpenAIModel-N7jW7{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-N7jW7œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-R9hC2{œfieldNameœ:œpostœ,œidœ:œPrompt-R9hC2œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-N7jW7", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-N7jW7œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-R9hC2", + "targetHandle": "{œfieldNameœ: œpostœ, œidœ: œPrompt-R9hC2œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-OcCWU", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-DdNth", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "reactflow__edge-Prompt-OcCWU{œdataTypeœ:œPromptœ,œidœ:œPrompt-OcCWUœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-DdNth{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-DdNthœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-OcCWU", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-OcCWUœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-DdNth", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-DdNthœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "className": "", + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-DdNth", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "image_description", + "id": "Prompt-R9hC2", + "inputTypes": [ + "Message", + "Text" + ], + "type": "str" + } + }, + "id": "reactflow__edge-OpenAIModel-DdNth{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-DdNthœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-R9hC2{œfieldNameœ:œimage_descriptionœ,œidœ:œPrompt-R9hC2œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-DdNth", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-DdNthœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-R9hC2", + "targetHandle": "{œfieldNameœ: œimage_descriptionœ, œidœ: œPrompt-R9hC2œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" } ], "nodes": [ { "data": { - "id": "ChatInput-pvWq5", + "id": "ChatInput-ferrV", "node": { "base_classes": [ "Message" @@ -304,7 +300,7 @@ "frozen": false, "icon": "MessagesSquare", "legacy": false, - "lf_version": "1.0.19.post2", + "lf_version": "1.1.1", "metadata": {}, "output_types": [], "outputs": [ @@ -551,10 +547,10 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-pvWq5", + "id": "ChatInput-ferrV", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 5183.264962599111, @@ -572,7 +568,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-j3woL", + "id": "Prompt-DfQRZ", "node": { "base_classes": [ "Message" @@ -726,10 +722,10 @@ }, "dragging": false, "height": 433, - "id": "Prompt-j3woL", + "id": "Prompt-DfQRZ", "measured": { "height": 433, - "width": 320 + "width": 360 }, "position": { "x": 6044.447585613556, @@ -745,7 +741,7 @@ }, { "data": { - "id": "TextInput-0rzBn", + "id": "TextInput-Uonj7", "node": { "base_classes": [ "Message" @@ -829,14 +825,14 @@ }, "dragging": false, "height": 234, - "id": "TextInput-0rzBn", + "id": "TextInput-Uonj7", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { - "x": 5663.277060522892, - "y": 3512.0511890588114 + "x": 5672.768365094557, + "y": 3457.8151629350077 }, "positionAbsolute": { "x": 5671.190001393486, @@ -846,329 +842,11 @@ "type": "genericNode", "width": 320 }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-jxXfH", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": false, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "langflow" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 543, - "id": "OpenAIModel-jxXfH", - "measured": { - "height": 543, - "width": 320 - }, - "position": { - "x": 6427.182886017446, - "y": 2891.554378731566 - }, - "positionAbsolute": { - "x": 6427.182886017446, - "y": 2891.554378731566 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-lqX5p", + "id": "Prompt-OcCWU", "node": { "base_classes": [ "Message" @@ -1298,14 +976,14 @@ }, "dragging": false, "height": 347, - "id": "Prompt-lqX5p", + "id": "Prompt-OcCWU", "measured": { "height": 347, - "width": 320 + "width": 360 }, "position": { - "x": 6822.3853365255445, - "y": 3031.299790790167 + "x": 6818.9410289594325, + "y": 3033.5959958342423 }, "positionAbsolute": { "x": 6786.650693383261, @@ -1319,7 +997,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-CnabR", + "id": "ChatOutput-hU0Qy", "node": { "base_classes": [ "Message" @@ -1579,10 +1257,10 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-CnabR", + "id": "ChatOutput-hU0Qy", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 7980.617825443558, @@ -1600,7 +1278,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Agent", - "id": "Agent-TG1G2", + "id": "Agent-pNUOq", "node": { "base_classes": [ "Message" @@ -1739,7 +1417,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -1747,7 +1425,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -2160,10 +1838,10 @@ }, "dragging": false, "height": 650, - "id": "Agent-TG1G2", + "id": "Agent-pNUOq", "measured": { "height": 650, - "width": 320 + "width": 360 }, "position": { "x": 5665.465212822881, @@ -2177,329 +1855,11 @@ "type": "genericNode", "width": 320 }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-Sef2w", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": false, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 543, - "id": "OpenAIModel-Sef2w", - "measured": { - "height": 543, - "width": 320 - }, - "position": { - "x": 7211.829041441037, - "y": 2938.1023670807563 - }, - "positionAbsolute": { - "x": 7211.829041441037, - "y": 2938.1023670807563 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-R2EK8", + "id": "Prompt-R9hC2", "node": { "base_classes": [ "Message" @@ -2653,10 +2013,10 @@ }, "dragging": false, "height": 433, - "id": "Prompt-R2EK8", + "id": "Prompt-R9hC2", "measured": { "height": 433, - "width": 320 + "width": 360 }, "position": { "x": 7613.837241084599, @@ -2672,7 +2032,7 @@ }, { "data": { - "id": "note-eNaIw", + "id": "note-grPkG", "node": { "description": "# Instagram Copywriter \n\nWelcome to the Instagram Copywriter! This flow helps you create compelling Instagram posts with AI-generated content and image prompts.\n\n## Instructions\n1. Enter Your Topic\n - In the Chat Input, enter a brief description of the topic you want to post about.\n - Example: \"Create a post about meditation and its benefits\"\n\n2. Review the Generated Content\n - The flow will use AI to research your topic and generate a formatted Instagram post.\n - The post will include an opening line, main content, emojis, a call-to-action, and hashtags.\n\n3. Check the Image Prompt\n - The flow will also generate a detailed image prompt based on your post content.\n - This prompt can be used with image generation tools to create a matching visual.\n\n4. Copy the Final Output\n - The Chat Output will display the complete Instagram post text followed by the image generation prompt.\n - Copy this output to use in your Instagram content creation process.\n\n5. Refine if Needed\n - If you're not satisfied with the result, you can adjust the input or modify the OpenAI model settings for different outputs.\n\nRemember: Keep your initial topic input clear and concise for best results! 🎨✨", "display_name": "", @@ -2685,10 +2045,10 @@ }, "dragging": false, "height": 648, - "id": "note-eNaIw", + "id": "note-grPkG", "measured": { "height": 648, - "width": 325 + "width": 328 }, "position": { "x": 4492.051129290571, @@ -2709,7 +2069,7 @@ }, { "data": { - "id": "note-HWvzc", + "id": "note-motsF", "node": { "description": "**Text Input (Guidelines Prompt)**\n - NOTE: \"Contains Instagram post formatting rules. Don't modify this component as it maintains format consistency.\"\n - Maintains fixed guidelines for:\n * Opening structure\n * Main content\n * Emoji usage\n * Call to Action (CTA)\n * Hashtags\n\n4. **First Prompt + OpenAI Sequence**\n - NOTE: \"Generates initial post content following Instagram guidelines\"\n - Settings:\n * Temperature: 0.7 (good balance between creativity and consistency)\n * Input: Receives research context\n * Output: Generates formatted post text\n\n", "display_name": "", @@ -2722,14 +2082,14 @@ }, "dragging": false, "height": 325, - "id": "note-HWvzc", + "id": "note-motsF", "measured": { "height": 325, - "width": 325 + "width": 328 }, "position": { - "x": 5667.476249937603, - "y": 3644.9055828357396 + "x": 5666.120349284508, + "y": 3705.9211122250185 }, "positionAbsolute": { "x": 5667.476249937603, @@ -2742,7 +2102,7 @@ }, { "data": { - "id": "note-A4SZx", + "id": "note-nnYl4", "node": { "description": "**Second Prompt + OpenAI Sequence**\n - NOTE: \"Transforms the generated post into a prompt for image generation\"\n - Settings:\n * Temperature: 0.7\n * Input: Receives generated post\n * Output: Creates detailed description for image generation\n\n", "display_name": "", @@ -2755,10 +2115,10 @@ }, "dragging": false, "height": 325, - "id": "note-A4SZx", + "id": "note-nnYl4", "measured": { "height": 325, - "width": 325 + "width": 328 }, "position": { "x": 6786.375917286389, @@ -2774,7 +2134,7 @@ }, { "data": { - "id": "note-RKey4", + "id": "note-Bw2uq", "node": { "description": "**Final Prompt**\n - NOTE: \"Combines Instagram post with image prompt in a final format\"\n - Structure:\n * First part: Complete Instagram post\n * Second part: Image generation prompt\n * Separator: Uses \"**Prompt:**\" to divide sections\n\n7. **Chat Output (Final Output)**\n - NOTE: \"Presents the combined final result that can be copied and used directly\"\n\nGENERAL USAGE TIPS:\n- Keep initial inputs clear and specific\n- Don't modify pre-defined Instagram guidelines\n- If style adjustments are needed, only modify the OpenAI models' temperature\n- Verify all connections are correct before running\n- Final result will always have two parts: post + image prompt\n\nFLOW CONSIDERATIONS:\n- All tools connect only to the Tool Calling Agent\n- The flow is unidirectional (no loops)\n- Each prompt template maintains specific formatting\n- Temperatures are set for optimal creativity/consistency balance\n\nTROUBLESHOOTING NOTES:\n- If output is too creative: Lower temperature", "display_name": "", @@ -2787,10 +2147,10 @@ }, "dragging": false, "height": 325, - "id": "note-RKey4", + "id": "note-Bw2uq", "measured": { "height": 325, - "width": 325 + "width": 328 }, "position": { "x": 7606.419013912975, @@ -2806,7 +2166,7 @@ }, { "data": { - "id": "note-sMyWp", + "id": "note-wUxWf", "node": { "description": "# 🔑 Tavily AI Search Needs API Key\n\nYou can get 1000 searches/month free [here](https://tavily.com/) ", "display_name": "", @@ -2819,10 +2179,10 @@ }, "dragging": false, "height": 325, - "id": "note-sMyWp", + "id": "note-wUxWf", "measured": { "height": 325, - "width": 325 + "width": 328 }, "position": { "x": 5174.678177457385, @@ -2838,7 +2198,7 @@ }, { "data": { - "id": "TavilySearchComponent-xQwoJ", + "id": "TavilySearchComponent-h8yAo", "node": { "base_classes": [ "Data", @@ -2870,6 +2230,7 @@ "output_types": [], "outputs": [ { + "allows_loop": false, "cache": true, "display_name": "Toolset", "hidden": null, @@ -2896,7 +2257,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -3142,10 +2503,10 @@ "type": "TavilySearchComponent" }, "dragging": false, - "id": "TavilySearchComponent-xQwoJ", + "id": "TavilySearchComponent-h8yAo", "measured": { - "height": 435, - "width": 320 + "height": 489, + "width": 360 }, "position": { "x": 5176.638828210268, @@ -3153,12 +2514,696 @@ }, "selected": false, "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-N7jW7", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-N7jW7", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 6411.984293767987, + "y": 2939.9259924956145 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-DdNth", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-DdNth", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 7206.924894456788, + "y": 2971.632992278429 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -1462.1369874897664, - "y": -557.4373796474765, - "zoom": 0.33990357996173937 + "x": -3779.2997720436124, + "y": -2148.895244030505, + "zoom": 0.7375171608018025 } }, "description": " Create engaging Instagram posts with AI-generated content and image prompts, streamlining social media content creation.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json b/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json index a0c067f4b..83d1bd06e 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json @@ -1,41 +1,13 @@ { "data": { "edges": [ - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-by2Or", - "name": "model_output", - "output_types": [ - "LanguageModel" - ] - }, - "targetHandle": { - "fieldName": "llm", - "id": "StructuredOutputComponent-JpsG1", - "inputTypes": [ - "LanguageModel" - ], - "type": "other" - } - }, - "id": "reactflow__edge-OpenAIModel-by2Or{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-by2Orœ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutputComponent-JpsG1{œfieldNameœ:œllmœ,œidœ:œStructuredOutputComponent-JpsG1œ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}", - "selected": false, - "source": "OpenAIModel-by2Or", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-by2Orœ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}", - "target": "StructuredOutputComponent-JpsG1", - "targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutputComponent-JpsG1œ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}" - }, { "animated": false, "className": "", "data": { "sourceHandle": { "dataType": "StructuredOutputComponent", - "id": "StructuredOutputComponent-JpsG1", + "id": "StructuredOutputComponent-y5YEE", "name": "structured_output", "output_types": [ "Data" @@ -43,19 +15,19 @@ }, "targetHandle": { "fieldName": "data", - "id": "ParseData-pw2fU", + "id": "ParseData-8KK2E", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "reactflow__edge-StructuredOutputComponent-JpsG1{œdataTypeœ:œStructuredOutputComponentœ,œidœ:œStructuredOutputComponent-JpsG1œ,œnameœ:œstructured_outputœ,œoutput_typesœ:[œDataœ]}-ParseData-pw2fU{œfieldNameœ:œdataœ,œidœ:œParseData-pw2fUœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "id": "reactflow__edge-StructuredOutputComponent-y5YEE{œdataTypeœ:œStructuredOutputComponentœ,œidœ:œStructuredOutputComponent-y5YEEœ,œnameœ:œstructured_outputœ,œoutput_typesœ:[œDataœ]}-ParseData-8KK2E{œfieldNameœ:œdataœ,œidœ:œParseData-8KK2Eœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", "selected": false, - "source": "StructuredOutputComponent-JpsG1", - "sourceHandle": "{œdataTypeœ: œStructuredOutputComponentœ, œidœ: œStructuredOutputComponent-JpsG1œ, œnameœ: œstructured_outputœ, œoutput_typesœ: [œDataœ]}", - "target": "ParseData-pw2fU", - "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-pw2fUœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "source": "StructuredOutputComponent-y5YEE", + "sourceHandle": "{œdataTypeœ: œStructuredOutputComponentœ, œidœ: œStructuredOutputComponent-y5YEEœ, œnameœ: œstructured_outputœ, œoutput_typesœ: [œDataœ]}", + "target": "ParseData-8KK2E", + "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-8KK2Eœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -63,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "ParseData", - "id": "ParseData-pw2fU", + "id": "ParseData-8KK2E", "name": "text", "output_types": [ "Message" @@ -71,19 +43,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-fzkT2", + "id": "ChatOutput-gEsYh", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ParseData-pw2fU{œdataTypeœ:œParseDataœ,œidœ:œParseData-pw2fUœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-fzkT2{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-fzkT2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ParseData-8KK2E{œdataTypeœ:œParseDataœ,œidœ:œParseData-8KK2Eœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-gEsYh{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-gEsYhœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "ParseData-pw2fU", - "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-pw2fUœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-fzkT2", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-fzkT2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "ParseData-8KK2E", + "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-8KK2Eœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-gEsYh", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-gEsYhœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -91,7 +63,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-Ifrc6", + "id": "ChatInput-vuvZ4", "name": "message", "output_types": [ "Message" @@ -99,19 +71,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-BFfCq", + "id": "Agent-lyqby", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-Ifrc6{œdataTypeœ:œChatInputœ,œidœ:œChatInput-Ifrc6œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-BFfCq{œfieldNameœ:œinput_valueœ,œidœ:œAgent-BFfCqœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ChatInput-vuvZ4{œdataTypeœ:œChatInputœ,œidœ:œChatInput-vuvZ4œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-lyqby{œfieldNameœ:œinput_valueœ,œidœ:œAgent-lyqbyœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "ChatInput-Ifrc6", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-Ifrc6œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-BFfCq", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-BFfCqœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "ChatInput-vuvZ4", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-vuvZ4œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-lyqby", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-lyqbyœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -119,7 +91,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-BFfCq", + "id": "Agent-lyqby", "name": "response", "output_types": [ "Message" @@ -127,19 +99,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "StructuredOutputComponent-JpsG1", + "id": "StructuredOutputComponent-y5YEE", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-BFfCq{œdataTypeœ:œAgentœ,œidœ:œAgent-BFfCqœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-StructuredOutputComponent-JpsG1{œfieldNameœ:œinput_valueœ,œidœ:œStructuredOutputComponent-JpsG1œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-Agent-lyqby{œdataTypeœ:œAgentœ,œidœ:œAgent-lyqbyœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-StructuredOutputComponent-y5YEE{œfieldNameœ:œinput_valueœ,œidœ:œStructuredOutputComponent-y5YEEœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "Agent-BFfCq", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-BFfCqœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "StructuredOutputComponent-JpsG1", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œStructuredOutputComponent-JpsG1œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "Agent-lyqby", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-lyqbyœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "StructuredOutputComponent-y5YEE", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œStructuredOutputComponent-y5YEEœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -147,7 +119,7 @@ "data": { "sourceHandle": { "dataType": "TavilySearchComponent", - "id": "TavilySearchComponent-3wVdo", + "id": "TavilySearchComponent-Gv4zn", "name": "component_as_tool", "output_types": [ "Tool" @@ -155,18 +127,43 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-BFfCq", + "id": "Agent-lyqby", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "xy-edge__TavilySearchComponent-3wVdo{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-3wVdoœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-BFfCq{œfieldNameœ:œtoolsœ,œidœ:œAgent-BFfCqœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "TavilySearchComponent-3wVdo", - "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-3wVdoœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-BFfCq", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-BFfCqœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-TavilySearchComponent-Gv4zn{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-Gv4znœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-lyqby{œfieldNameœ:œtoolsœ,œidœ:œAgent-lyqbyœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "TavilySearchComponent-Gv4zn", + "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-Gv4znœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-lyqby", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-lyqbyœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-Yo7s2", + "name": "model_output", + "output_types": [ + "LanguageModel" + ] + }, + "targetHandle": { + "fieldName": "llm", + "id": "StructuredOutputComponent-y5YEE", + "inputTypes": [ + "LanguageModel" + ], + "type": "other" + } + }, + "id": "xy-edge__OpenAIModel-Yo7s2{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-Yo7s2œ,œnameœ:œmodel_outputœ,œoutput_typesœ:[œLanguageModelœ]}-StructuredOutputComponent-y5YEE{œfieldNameœ:œllmœ,œidœ:œStructuredOutputComponent-y5YEEœ,œinputTypesœ:[œLanguageModelœ],œtypeœ:œotherœ}", + "source": "OpenAIModel-Yo7s2", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-Yo7s2œ, œnameœ: œmodel_outputœ, œoutput_typesœ: [œLanguageModelœ]}", + "target": "StructuredOutputComponent-y5YEE", + "targetHandle": "{œfieldNameœ: œllmœ, œidœ: œStructuredOutputComponent-y5YEEœ, œinputTypesœ: [œLanguageModelœ], œtypeœ: œotherœ}" } ], "nodes": [ @@ -174,7 +171,7 @@ "data": { "description": "Get chat inputs from the Playground.", "display_name": "Chat Input", - "id": "ChatInput-Ifrc6", + "id": "ChatInput-vuvZ4", "node": { "base_classes": [ "Message" @@ -447,10 +444,10 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-Ifrc6", + "id": "ChatInput-vuvZ4", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 472.38251755471583, @@ -468,7 +465,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-fzkT2", + "id": "ChatOutput-gEsYh", "node": { "base_classes": [ "Message" @@ -729,10 +726,10 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-fzkT2", + "id": "ChatOutput-gEsYh", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 2518.282039019285, @@ -748,7 +745,7 @@ }, { "data": { - "id": "note-3WRHy", + "id": "note-siDHB", "node": { "description": "The StructuredOutputComponent, when utilized with our company information schema, performs the following functions:\n\n1. Accepts an input query regarding a company.\n2. Employs a Language Model (LLM) to analyze the query.\n3. Instructs the LLM to generate a structured response adhering to the predefined schema:\n - Domain\n - LinkedIn URL\n - Cheapest Plan\n - Has Free Trial\n - Has Enterprise Plan\n - Has API\n - Market\n - Pricing Tiers\n - Key Features\n - Target Industries\n\n4. Validates the LLM output against this schema.\n5. Returns a Data object containing the company information structured according to the schema.\n\nIn essence, this component transforms a free-text query about a company into a structured, consistent dataset, facilitating subsequent analysis and application of the information.", "display_name": "", @@ -761,10 +758,10 @@ }, "dragging": false, "height": 403, - "id": "note-3WRHy", + "id": "note-siDHB", "measured": { "height": 403, - "width": 325 + "width": 328 }, "position": { "x": 2089.5869930853464, @@ -785,7 +782,7 @@ }, { "data": { - "id": "note-erQ7I", + "id": "note-gjsCT", "node": { "description": "PURPOSE:\nConverts unstructured company research into standardized JSON format\n\nKEY FUNCTIONS:\n- Extracts specific business data points\n- Validates and formats information\n- Ensures data consistency\n\nINPUT:\n- Raw company research data\n\nOUTPUT:\nStructured JSON with:\n- Domain information\n- Social links\n- Pricing details\n- Feature availability\n- Market classification\n- Product features\n- Industry focus\n\nRULES:\n1. Uses strict boolean values\n2. Standardizes pricing formats\n3. Validates market categories\n4. Handles missing data consistently", "display_name": "", @@ -798,10 +795,10 @@ }, "dragging": false, "height": 382, - "id": "note-erQ7I", + "id": "note-gjsCT", "measured": { "height": 382, - "width": 325 + "width": 328 }, "position": { "x": 1237.6627823432912, @@ -822,7 +819,7 @@ }, { "data": { - "id": "note-Hvebs", + "id": "note-IftyY", "node": { "description": "# Market Research\nThis flow helps you gather comprehensive information about companies for sales and business intelligence purposes.\n\n## Instructions\n\n1. Enter Company Name\n - In the Chat Input node, type the name of the company you want to research\n - Example inputs: \"Salesforce.com\", \"Shopify\", \"Zoom Video Communications\"\n\n2. Initiate Research\n - The Agent will use the Tavily AI Search tool to gather information\n - It will focus on key areas like pricing, features, and market positioning\n\n3. Review Structured Output\n - The flow will generate a structured JSON output with standardized fields\n - This includes domain, LinkedIn URL, pricing details, and key features\n\n4. Examine Formatted Results\n - The Parse Data component will convert the JSON into a readable format\n - You'll see a comprehensive company profile with organized sections\n\n5. Analyze and Use Data\n - Use the generated information for sales prospecting, competitive analysis, or market research\n - The structured format allows for easy comparison between different companies\n\nRemember: Always verify critical information from official sources before making business decisions! 🔍💼", "display_name": "", @@ -835,10 +832,10 @@ }, "dragging": false, "height": 513, - "id": "note-Hvebs", + "id": "note-IftyY", "measured": { "height": 513, - "width": 325 + "width": 328 }, "position": { "x": 244.92297036777086, @@ -861,7 +858,7 @@ "data": { "description": "Transforms LLM responses into **structured data formats**. Ideal for extracting specific information or creating consistent outputs.", "display_name": "Structured Output", - "id": "StructuredOutputComponent-JpsG1", + "id": "StructuredOutputComponent-y5YEE", "node": { "base_classes": [ "Data" @@ -1121,10 +1118,10 @@ }, "dragging": false, "height": 541, - "id": "StructuredOutputComponent-JpsG1", + "id": "StructuredOutputComponent-y5YEE", "measured": { "height": 541, - "width": 320 + "width": 360 }, "position": { "x": 1716.7237308033855, @@ -1140,325 +1137,7 @@ }, { "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-by2Or", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.1.1", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": false, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 543, - "id": "OpenAIModel-by2Or", - "measured": { - "height": 543, - "width": 320 - }, - "position": { - "x": 1696.6021757625274, - "y": 1053.2300549755305 - }, - "positionAbsolute": { - "x": 1631.501592565594, - "y": 1086.5741650125892 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "ParseData-pw2fU", + "id": "ParseData-8KK2E", "node": { "base_classes": [ "Message" @@ -1595,10 +1274,10 @@ }, "dragging": false, "height": 302, - "id": "ParseData-pw2fU", + "id": "ParseData-8KK2E", "measured": { "height": 302, - "width": 320 + "width": 360 }, "position": { "x": 2139.05558520377, @@ -1616,7 +1295,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Agent", - "id": "Agent-BFfCq", + "id": "Agent-lyqby", "node": { "base_classes": [ "Message" @@ -1756,7 +1435,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -1764,7 +1443,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -2177,10 +1856,10 @@ }, "dragging": false, "height": 650, - "id": "Agent-BFfCq", + "id": "Agent-lyqby", "measured": { "height": 650, - "width": 320 + "width": 360 }, "position": { "x": 1287.5681517817056, @@ -2192,7 +1871,7 @@ }, { "data": { - "id": "note-hp7gL", + "id": "note-Z3HC2", "node": { "description": "# 🔑 Tavily AI Search Needs API Key\n\nYou can get 1000 searches/month free [here](https://tavily.com/) ", "display_name": "", @@ -2205,10 +1884,10 @@ }, "dragging": false, "height": 325, - "id": "note-hp7gL", + "id": "note-Z3HC2", "measured": { "height": 325, - "width": 325 + "width": 328 }, "position": { "x": 878.7898510090017, @@ -2224,7 +1903,7 @@ }, { "data": { - "id": "TavilySearchComponent-3wVdo", + "id": "TavilySearchComponent-Gv4zn", "node": { "base_classes": [ "Data", @@ -2257,6 +1936,7 @@ "output_types": [], "outputs": [ { + "allows_loop": false, "cache": true, "display_name": "Toolset", "hidden": null, @@ -2283,7 +1963,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -2475,17 +2155,6 @@ "name": "tags", "sortable": false, "type": "text" - }, - { - "description": "Add commands to the tool. These commands will be used to run the tool. Start all commands with a `/`. You can add multiple commands separated by a comma.\nExample: `/command1`, `/command2`, `/command3`", - "disable_edit": false, - "display_name": "Commands", - "edit_mode": "inline", - "filterable": false, - "formatter": "text", - "name": "commands", - "sortable": false, - "type": "text" } ] }, @@ -2540,10 +2209,10 @@ "type": "TavilySearchComponent" }, "dragging": false, - "id": "TavilySearchComponent-3wVdo", + "id": "TavilySearchComponent-Gv4zn", "measured": { - "height": 437, - "width": 320 + "height": 489, + "width": 360 }, "position": { "x": 875.7686789989679, @@ -2551,12 +2220,354 @@ }, "selected": false, "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-Yo7s2", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-Yo7s2", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 1718.9581068990763, + "y": 1081.137733422722 + }, + "selected": true, + "type": "genericNode" } ], "viewport": { - "x": -272.7790874888751, - "y": 63.44626914733033, - "zoom": 0.4593805108979444 + "x": -84.19731102880883, + "y": -179.36393502789429, + "zoom": 0.5492417618766154 } }, "description": "Researches companies, extracts key business data, and presents structured information for efficient analysis. ", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json b/src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json index 2fef450e7..b4d70a8e1 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json @@ -1,68 +1,12 @@ { "data": { "edges": [ - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-4aid4", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-CL8qC", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-4aid4{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-4aid4œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-CL8qC{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-CL8qCœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "OpenAIModel-4aid4", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-4aid4œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-CL8qC", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-CL8qCœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "ChatInput", - "id": "ChatInput-wnAdG", - "name": "message", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-4aid4", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-ChatInput-wnAdG{œdataTypeœ:œChatInputœ,œidœ:œChatInput-wnAdGœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-4aid4{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-4aid4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "ChatInput-wnAdG", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-wnAdGœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-4aid4", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-4aid4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, { "className": "", "data": { "sourceHandle": { "dataType": "Memory", - "id": "Memory-dsJro", + "id": "Memory-W1a3k", "name": "messages_text", "output_types": [ "Message" @@ -70,7 +14,7 @@ }, "targetHandle": { "fieldName": "memory", - "id": "Prompt-JvUF7", + "id": "Prompt-q8R26", "inputTypes": [ "Message", "Text" @@ -78,18 +22,42 @@ "type": "str" } }, - "id": "reactflow__edge-Memory-dsJro{œdataTypeœ:œMemoryœ,œidœ:œMemory-dsJroœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-JvUF7{œfieldNameœ:œmemoryœ,œidœ:œPrompt-JvUF7œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "Memory-dsJro", - "sourceHandle": "{œdataTypeœ: œMemoryœ, œidœ: œMemory-dsJroœ, œnameœ: œmessages_textœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-JvUF7", - "targetHandle": "{œfieldNameœ: œmemoryœ, œidœ: œPrompt-JvUF7œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Memory-W1a3k{œdataTypeœ:œMemoryœ,œidœ:œMemory-W1a3kœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-q8R26{œfieldNameœ:œmemoryœ,œidœ:œPrompt-q8R26œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "Memory-W1a3k", + "sourceHandle": "{œdataTypeœ: œMemoryœ, œidœ: œMemory-W1a3kœ, œnameœ: œmessages_textœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-q8R26", + "targetHandle": "{œfieldNameœ: œmemoryœ, œidœ: œPrompt-q8R26œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "ChatInput", + "id": "ChatInput-LrPKe", + "name": "message", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-BSFD4", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__ChatInput-LrPKe{œdataTypeœ:œChatInputœ,œidœ:œChatInput-LrPKeœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-BSFD4{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-BSFD4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-LrPKe", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-LrPKeœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-BSFD4", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-BSFD4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "className": "", "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-JvUF7", + "id": "Prompt-q8R26", "name": "prompt", "output_types": [ "Message" @@ -97,24 +65,49 @@ }, "targetHandle": { "fieldName": "system_message", - "id": "OpenAIModel-4aid4", + "id": "OpenAIModel-BSFD4", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-JvUF7{œdataTypeœ:œPromptœ,œidœ:œPrompt-JvUF7œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-4aid4{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-4aid4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-JvUF7", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-JvUF7œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-4aid4", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-4aid4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__Prompt-q8R26{œdataTypeœ:œPromptœ,œidœ:œPrompt-q8R26œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-BSFD4{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-BSFD4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-q8R26", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-q8R26œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-BSFD4", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-BSFD4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-BSFD4", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-Fk6pf", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-BSFD4{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-BSFD4œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-Fk6pf{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-Fk6pfœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-BSFD4", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-BSFD4œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-Fk6pf", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-Fk6pfœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ { "data": { - "id": "ChatInput-wnAdG", + "id": "ChatInput-LrPKe", "node": { "base_classes": [ "Message" @@ -395,7 +388,11 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-wnAdG", + "id": "ChatInput-LrPKe", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 2321.5543981677606, "y": 374.0457826421628 @@ -412,7 +409,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-CL8qC", + "id": "ChatOutput-Fk6pf", "node": { "base_classes": [ "Message" @@ -671,24 +668,28 @@ }, "type": "ChatOutput" }, - "dragging": false, + "dragging": true, "height": 234, - "id": "ChatOutput-CL8qC", + "id": "ChatOutput-Fk6pf", + "measured": { + "height": 234, + "width": 360 + }, "position": { - "x": 3101.965731391458, - "y": 776.4408905693839 + "x": 3113.9880204333917, + "y": 769.7618411016429 }, "positionAbsolute": { "x": 3101.965731391458, "y": 776.4408905693839 }, - "selected": false, + "selected": true, "type": "genericNode", "width": 320 }, { "data": { - "id": "note-4FQUh", + "id": "note-gj6hj", "node": { "description": "# Memory Chatbot\n\nA flexible chatbot implementation featuring advanced conversation memory capabilities. This serves as a foundational tool for building chat experiences with persistent context.\n\n## Core Components\n\n1. **Chat Input**\n - Accepts user messages\n - Configures conversation storage\n - Tracks session identity\n\n2. **Chat Memory**\n - Stores and retrieves up to 100 previous messages\n - Maintains conversation context\n - Tracks separate chat sessions\n - Preserves sender information and message order\n\n3. **Prompt**\n - Creates dynamic prompt templates\n - Integrates memory into conversation flow\n\n4. **OpenAI**\n - Processes user input with context\n - Accesses conversation history\n - Includes options for model configuration and API key setup\n\n5. **Chat Output**\n - Displays formatted responses\n - Maintains conversation flow\n - Syncs with memory storage\n\n## Memory Features\n\n- Stores message history\n- Plans conversation trajectory\n- Differentiates between chat sessions\n- Preserves sender and message metadata\n\n## Quick Start\n\n1. **Initialize** with a clear session ID\n2. **Enter** message in Chat Input\n3. **AI Processes** with context from memory\n4. **Response** appears in Chat Output\n5. Context remains available for follow-ups\n\nThis robust system demonstrates thorough memory integration with minimal complexity. 🧠💬\n", "display_name": "", @@ -699,7 +700,11 @@ }, "dragging": false, "height": 736, - "id": "note-4FQUh", + "id": "note-gj6hj", + "measured": { + "height": 736, + "width": 328 + }, "position": { "x": 1512.8976594415833, "y": 312.9558305744385 @@ -719,7 +724,7 @@ }, { "data": { - "id": "note-5ZvaH", + "id": "note-SQs3p", "node": { "description": "## Get Your OpenAI API Key\n\n**Steps**:\n\n1. **Visit** [OpenAI's API Key Page](https://platform.openai.com/api-keys).\n\n2. **Log In/Sign Up**:\n - Log in or create a new OpenAI account.\n\n3. **Generate API Key**:\n - Click \"Create New Secret Key\" to obtain your key.\n\n4. **Store Your Key Securely**:\n - Note it down as it will only display once.\n\n5. **Enter API Key**:\n - Input your key in the OpenAI API Key field within the component setup.\n\nKeep your key safe and manage it responsibly!", "display_name": "", @@ -732,7 +737,11 @@ }, "dragging": false, "height": 325, - "id": "note-5ZvaH", + "id": "note-SQs3p", + "measured": { + "height": 325, + "width": 328 + }, "position": { "x": 2727.7060397092964, "y": 115.42518754847691 @@ -747,319 +756,7 @@ }, { "data": { - "id": "OpenAIModel-4aid4", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-4aid4", - "position": { - "x": 2730.3374000311414, - "y": 465.98757723618604 - }, - "positionAbsolute": { - "x": 2730.3374000311414, - "y": 465.98757723618604 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "Memory-dsJro", + "id": "Memory-W1a3k", "node": { "base_classes": [ "Data", @@ -1286,7 +983,11 @@ }, "dragging": false, "height": 264, - "id": "Memory-dsJro", + "id": "Memory-W1a3k", + "measured": { + "height": 264, + "width": 360 + }, "position": { "x": 1947.7805399474369, "y": 766.1115984799474 @@ -1301,7 +1002,7 @@ }, { "data": { - "id": "Prompt-JvUF7", + "id": "Prompt-q8R26", "node": { "base_classes": [ "Message" @@ -1436,7 +1137,11 @@ }, "dragging": false, "height": 347, - "id": "Prompt-JvUF7", + "id": "Prompt-q8R26", + "measured": { + "height": 347, + "width": 360 + }, "position": { "x": 2327.422938009026, "y": 675.992123914672 @@ -1448,12 +1153,354 @@ "selected": false, "type": "genericNode", "width": 320 + }, + { + "data": { + "id": "OpenAIModel-BSFD4", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-BSFD4", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 2726.7429097065215, + "y": 460.96432586131795 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -982.1139274661589, - "y": -37.00115573852611, - "zoom": 0.6716071677128489 + "x": -1173.6150415418488, + "y": -168.93756272342318, + "zoom": 0.7486095175892006 } }, "description": "Create a chatbot that saves and references previous messages, enabling the model to maintain context throughout the conversation.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json b/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json index 84d03b674..d3e281a2f 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json @@ -1,70 +1,13 @@ { "data": { "edges": [ - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-gqyjP", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "previous_response", - "id": "Prompt-0I0H4", - "inputTypes": [ - "Message", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-gqyjP{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-gqyjPœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-0I0H4{œfieldNameœ:œprevious_responseœ,œidœ:œPrompt-0I0H4œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "selected": false, - "source": "OpenAIModel-gqyjP", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-gqyjPœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-0I0H4", - "targetHandle": "{œfieldNameœ: œprevious_responseœ, œidœ: œPrompt-0I0H4œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-eSKKr", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-S0zP4", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-eSKKr{œdataTypeœ:œPromptœ,œidœ:œPrompt-eSKKrœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-S0zP4{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-S0zP4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "Prompt-eSKKr", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-eSKKrœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-S0zP4", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-S0zP4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, { "animated": false, "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-NO5CC", + "id": "ChatInput-JfaSH", "name": "message", "output_types": [ "Message" @@ -72,7 +15,7 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Prompt-eSKKr", + "id": "Prompt-QF5LF", "inputTypes": [ "Message", "Text" @@ -80,40 +23,12 @@ "type": "str" } }, - "id": "reactflow__edge-ChatInput-NO5CC{œdataTypeœ:œChatInputœ,œidœ:œChatInput-NO5CCœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-eSKKr{œfieldNameœ:œinput_valueœ,œidœ:œPrompt-eSKKrœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ChatInput-JfaSH{œdataTypeœ:œChatInputœ,œidœ:œChatInput-JfaSHœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-QF5LF{œfieldNameœ:œinput_valueœ,œidœ:œPrompt-QF5LFœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", "selected": false, - "source": "ChatInput-NO5CC", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-NO5CCœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-eSKKr", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œPrompt-eSKKrœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-S0zP4", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-ZN3tc", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-S0zP4{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-S0zP4œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-ZN3tc{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-ZN3tcœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "OpenAIModel-S0zP4", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-S0zP4œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-ZN3tc", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-ZN3tcœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "ChatInput-JfaSH", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-JfaSHœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-QF5LF", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œPrompt-QF5LFœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -121,7 +36,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-0I0H4", + "id": "Prompt-vnTcM", "name": "prompt", "output_types": [ "Message" @@ -129,19 +44,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-YS55M", + "id": "Agent-yGw6Q", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-0I0H4{œdataTypeœ:œPromptœ,œidœ:œPrompt-0I0H4œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-YS55M{œfieldNameœ:œinput_valueœ,œidœ:œAgent-YS55Mœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-Prompt-vnTcM{œdataTypeœ:œPromptœ,œidœ:œPrompt-vnTcMœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-yGw6Q{œfieldNameœ:œinput_valueœ,œidœ:œAgent-yGw6Qœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "Prompt-0I0H4", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-0I0H4œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-YS55M", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-YS55Mœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "Prompt-vnTcM", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-vnTcMœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-yGw6Q", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-yGw6Qœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -149,7 +64,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-YS55M", + "id": "Agent-yGw6Q", "name": "response", "output_types": [ "Message" @@ -157,7 +72,7 @@ }, "targetHandle": { "fieldName": "search_results", - "id": "Prompt-eSKKr", + "id": "Prompt-QF5LF", "inputTypes": [ "Message", "Text" @@ -165,99 +80,19 @@ "type": "str" } }, - "id": "reactflow__edge-Agent-YS55M{œdataTypeœ:œAgentœ,œidœ:œAgent-YS55Mœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-eSKKr{œfieldNameœ:œsearch_resultsœ,œidœ:œPrompt-eSKKrœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-Agent-yGw6Q{œdataTypeœ:œAgentœ,œidœ:œAgent-yGw6Qœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-QF5LF{œfieldNameœ:œsearch_resultsœ,œidœ:œPrompt-QF5LFœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", "selected": false, - "source": "Agent-YS55M", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-YS55Mœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-eSKKr", - "targetHandle": "{œfieldNameœ: œsearch_resultsœ, œidœ: œPrompt-eSKKrœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "source": "Agent-yGw6Q", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-yGw6Qœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-QF5LF", + "targetHandle": "{œfieldNameœ: œsearch_resultsœ, œidœ: œPrompt-QF5LFœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { - "animated": false, "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-CadaL", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "system_message", - "id": "OpenAIModel-gqyjP", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-CadaL{œdataTypeœ:œPromptœ,œidœ:œPrompt-CadaLœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-gqyjP{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-gqyjPœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-CadaL", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-CadaLœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-gqyjP", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-gqyjPœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "ChatInput", - "id": "ChatInput-NO5CC", - "name": "message", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-gqyjP", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-ChatInput-NO5CC{œdataTypeœ:œChatInputœ,œidœ:œChatInput-NO5CCœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-gqyjP{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-gqyjPœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-NO5CC", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-NO5CCœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-gqyjP", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-gqyjPœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-KWWyW", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "system_message", - "id": "OpenAIModel-S0zP4", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-KWWyW{œdataTypeœ:œPromptœ,œidœ:œPrompt-KWWyWœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-S0zP4{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-S0zP4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-KWWyW", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-KWWyWœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-S0zP4", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-S0zP4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { "data": { "sourceHandle": { "dataType": "TavilySearchComponent", - "id": "TavilySearchComponent-KcrPr", + "id": "TavilySearchComponent-ChvwJ", "name": "component_as_tool", "output_types": [ "Tool" @@ -265,18 +100,169 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-YS55M", + "id": "Agent-yGw6Q", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "xy-edge__TavilySearchComponent-KcrPr{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-KcrPrœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-YS55M{œfieldNameœ:œtoolsœ,œidœ:œAgent-YS55Mœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "TavilySearchComponent-KcrPr", - "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-KcrPrœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-YS55M", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-YS55Mœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-TavilySearchComponent-ChvwJ{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-ChvwJœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-yGw6Q{œfieldNameœ:œtoolsœ,œidœ:œAgent-yGw6Qœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "TavilySearchComponent-ChvwJ", + "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-ChvwJœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-yGw6Q", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-yGw6Qœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-D14S9", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "OpenAIModel-FVlqP", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-D14S9{œdataTypeœ:œPromptœ,œidœ:œPrompt-D14S9œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-FVlqP{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-FVlqPœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-D14S9", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-D14S9œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-FVlqP", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-FVlqPœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "ChatInput", + "id": "ChatInput-JfaSH", + "name": "message", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-FVlqP", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__ChatInput-JfaSH{œdataTypeœ:œChatInputœ,œidœ:œChatInput-JfaSHœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-FVlqP{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-FVlqPœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-JfaSH", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-JfaSHœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-FVlqP", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-FVlqPœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-FVlqP", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "previous_response", + "id": "Prompt-vnTcM", + "inputTypes": [ + "Message", + "Text" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-FVlqP{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-FVlqPœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-Prompt-vnTcM{œfieldNameœ:œprevious_responseœ,œidœ:œPrompt-vnTcMœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-FVlqP", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-FVlqPœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-vnTcM", + "targetHandle": "{œfieldNameœ: œprevious_responseœ, œidœ: œPrompt-vnTcMœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-QF5LF", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-MhnGV", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-QF5LF{œdataTypeœ:œPromptœ,œidœ:œPrompt-QF5LFœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-MhnGV{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-MhnGVœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-QF5LF", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-QF5LFœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-MhnGV", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-MhnGVœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-Lqvw5", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "OpenAIModel-MhnGV", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-Lqvw5{œdataTypeœ:œPromptœ,œidœ:œPrompt-Lqvw5œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-MhnGV{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-MhnGVœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-Lqvw5", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-Lqvw5œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-MhnGV", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-MhnGVœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-MhnGV", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-dc1aC", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-MhnGV{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-MhnGVœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-dc1aC{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-dc1aCœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-MhnGV", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-MhnGVœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-dc1aC", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-dc1aCœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -284,7 +270,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-0I0H4", + "id": "Prompt-vnTcM", "node": { "base_classes": [ "Message" @@ -414,7 +400,7 @@ }, "dragging": false, "height": 347, - "id": "Prompt-0I0H4", + "id": "Prompt-vnTcM", "measured": { "height": 347, "width": 360 @@ -433,7 +419,7 @@ }, { "data": { - "id": "ChatInput-NO5CC", + "id": "ChatInput-JfaSH", "node": { "base_classes": [ "Message" @@ -708,7 +694,7 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-NO5CC", + "id": "ChatInput-JfaSH", "measured": { "height": 234, "width": 360 @@ -729,7 +715,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-ZN3tc", + "id": "ChatOutput-dc1aC", "node": { "base_classes": [ "Message" @@ -988,22 +974,22 @@ }, "type": "ChatOutput" }, - "dragging": false, + "dragging": true, "height": 234, - "id": "ChatOutput-ZN3tc", + "id": "ChatOutput-dc1aC", "measured": { "height": 234, "width": 360 }, "position": { - "x": 3200.774558432761, - "y": 853.9881404769172 + "x": 3235.4806463111895, + "y": 851.4173191525891 }, "positionAbsolute": { "x": 3200.774558432761, "y": 853.9881404769172 }, - "selected": false, + "selected": true, "type": "genericNode", "width": 320 }, @@ -1011,7 +997,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-eSKKr", + "id": "Prompt-QF5LF", "node": { "base_classes": [ "Message" @@ -1165,7 +1151,7 @@ }, "dragging": false, "height": 433, - "id": "Prompt-eSKKr", + "id": "Prompt-QF5LF", "measured": { "height": 433, "width": 360 @@ -1184,643 +1170,7 @@ }, { "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-gqyjP", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": false, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-gqyjP", - "measured": { - "height": 630, - "width": 360 - }, - "position": { - "x": 1457.8987895868838, - "y": 543.8838473503562 - }, - "positionAbsolute": { - "x": 1457.8987895868838, - "y": 543.8838473503562 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-S0zP4", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": false, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-S0zP4", - "measured": { - "height": 630, - "width": 360 - }, - "position": { - "x": 2860.2941186979524, - "y": 561.8661152181708 - }, - "positionAbsolute": { - "x": 2860.2941186979524, - "y": 561.8661152181708 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "note-pNJhC", + "id": "note-OmVXD", "node": { "description": "# Research Agent \n\nWelcome to the Research Agent! This flow helps you conduct in-depth research on various topics using AI-powered tools and analysis.\n\n## Instructions\n1. Enter Your Research Query\n - Type your research question or topic into the Chat Input node.\n - Be specific and clear about what you want to investigate.\n\n2. Generate Research Plan\n - The system will create a focused research plan based on your query.\n - This plan includes key search queries and priorities.\n\n3. Conduct Web Search\n - The Tavily AI Search tool will perform web searches using the generated queries.\n - It focuses on finding academic and reliable sources.\n\n4. Analyze and Synthesize\n - The AI agent will review the search results and create a comprehensive synthesis.\n - The report includes an executive summary, methodology, findings, and conclusions.\n\n5. Review the Output\n - Read the final report in the Chat Output node.\n - Use this information as a starting point for further research or decision-making.\n\nRemember: You can refine your initial query for more specific results! 🔍📊", "display_name": "", @@ -1833,7 +1183,7 @@ }, "dragging": false, "height": 765, - "id": "note-pNJhC", + "id": "note-OmVXD", "measured": { "height": 765, "width": 328 @@ -1859,7 +1209,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Agent", - "id": "Agent-YS55M", + "id": "Agent-yGw6Q", "node": { "base_classes": [ "Message" @@ -1999,7 +1349,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -2007,7 +1357,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -2420,7 +1770,7 @@ }, "dragging": false, "height": 658, - "id": "Agent-YS55M", + "id": "Agent-yGw6Q", "measured": { "height": 658, "width": 360 @@ -2441,7 +1791,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-CadaL", + "id": "Prompt-D14S9", "node": { "base_classes": [ "Message" @@ -2546,7 +1896,7 @@ }, "dragging": false, "height": 260, - "id": "Prompt-CadaL", + "id": "Prompt-D14S9", "measured": { "height": 260, "width": 360 @@ -2567,7 +1917,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-KWWyW", + "id": "Prompt-Lqvw5", "node": { "base_classes": [ "Message" @@ -2672,7 +2022,7 @@ }, "dragging": false, "height": 260, - "id": "Prompt-KWWyW", + "id": "Prompt-Lqvw5", "measured": { "height": 260, "width": 360 @@ -2691,7 +2041,7 @@ }, { "data": { - "id": "note-OSBLo", + "id": "note-0mAkP", "node": { "description": "# 🔑 Tavily AI Search Needs API Key\n\nYou can get 1000 searches/month free [here](https://tavily.com/) ", "display_name": "", @@ -2704,7 +2054,7 @@ }, "dragging": false, "height": 325, - "id": "note-OSBLo", + "id": "note-0mAkP", "measured": { "height": 325, "width": 328 @@ -2723,7 +2073,7 @@ }, { "data": { - "id": "TavilySearchComponent-KcrPr", + "id": "TavilySearchComponent-ChvwJ", "node": { "base_classes": [ "Data", @@ -2755,6 +2105,7 @@ "output_types": [], "outputs": [ { + "allows_loop": false, "cache": true, "display_name": "Toolset", "hidden": null, @@ -2781,7 +2132,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -3027,7 +2378,7 @@ "type": "TavilySearchComponent" }, "dragging": false, - "id": "TavilySearchComponent-KcrPr", + "id": "TavilySearchComponent-ChvwJ", "measured": { "height": 489, "width": 360 @@ -3038,12 +2389,696 @@ }, "selected": false, "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-FVlqP", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-FVlqP", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 1455.1912046212385, + "y": 487.41889689444065 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-MhnGV", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-MhnGV", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 2869.8759720421745, + "y": 463.310915040386 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -406.960259959106, - "y": -33.16211370837854, - "zoom": 0.5577809840170954 + "x": -1483.015971938532, + "y": -267.7229964456226, + "zoom": 0.7779614946685405 } }, "description": "Agent that generates focused plans, conducts web searches, and synthesizes findings into comprehensive reports.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json b/src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json index 585512ae8..e0f6d2733 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json @@ -2,40 +2,10 @@ "data": { "edges": [ { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-FXOhu", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-E96kR", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-FXOhu{œdataTypeœ:œPromptœ,œidœ:œPrompt-FXOhuœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-E96kR{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-E96kRœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "Prompt-FXOhu", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-FXOhuœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-E96kR", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-E96kRœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-aMAQ2", + "id": "Prompt-QFfcl", "name": "prompt", "output_types": [ "Message" @@ -43,27 +13,49 @@ }, "targetHandle": { "fieldName": "system_message", - "id": "OpenAIModel-E96kR", + "id": "OpenAIModel-3mbCD", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-aMAQ2{œdataTypeœ:œPromptœ,œidœ:œPrompt-aMAQ2œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-E96kR{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-E96kRœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "Prompt-aMAQ2", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-aMAQ2œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-E96kR", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-E96kRœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__Prompt-QFfcl{œdataTypeœ:œPromptœ,œidœ:œPrompt-QFfclœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-3mbCD{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-3mbCDœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-QFfcl", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-QFfclœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-3mbCD", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-3mbCDœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-RpVoN", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-3mbCD", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-RpVoN{œdataTypeœ:œPromptœ,œidœ:œPrompt-RpVoNœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-3mbCD{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-3mbCDœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-RpVoN", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-RpVoNœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-3mbCD", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-3mbCDœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "OpenAIModel", - "id": "OpenAIModel-E96kR", + "id": "OpenAIModel-3mbCD", "name": "text_output", "output_types": [ "Message" @@ -71,19 +63,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-aCpBy", + "id": "ChatOutput-vBbvi", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-OpenAIModel-E96kR{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-E96kRœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-aCpBy{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-aCpByœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "OpenAIModel-E96kR", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-E96kRœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-aCpBy", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-aCpByœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__OpenAIModel-3mbCD{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-3mbCDœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-vBbvi{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-vBbviœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-3mbCD", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-3mbCDœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-vBbvi", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-vBbviœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -91,7 +82,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-FXOhu", + "id": "Prompt-RpVoN", "node": { "base_classes": [ "Message" @@ -341,7 +332,11 @@ }, "dragging": false, "height": 779, - "id": "Prompt-FXOhu", + "id": "Prompt-RpVoN", + "measured": { + "height": 779, + "width": 360 + }, "position": { "x": 816.9328565352126, "y": 189.70442453076902 @@ -356,7 +351,7 @@ }, { "data": { - "id": "note-5yMAo", + "id": "note-bzlUs", "node": { "description": "# SEO Keyword Generator\nWelcome to the SEO Keywords Generator - an AI tool to create strategic keywords based on your product and audience profile!\n\n## Instructions\n\n1. **Fill Product Information**\n - Enter your product name and description\n - Keep it clear and specific\n - Highlight unique features and benefits\n\n2. **Define Pain Points**\n - List customer problems and challenges\n - Be specific about what frustrations they face\n - Include both practical and emotional pain points\n\n3. **Set Goals & Solutions**\n - Specify customer objectives\n - Detail how they currently solve problems\n - Outline desired outcomes\n\n4. **Target Audience Details**\n - Define demographics and characteristics\n - Include expertise level\n - Describe behavior patterns and preferences\n\n5. **Review Output**\n - Examine generated keywords\n - Check relevance and search intent\n - Use insights for SEO strategy planning\n\nRemember: The more detailed your input, the more targeted and effective your keywords will be! 🎯🔍✨", "display_name": "", @@ -367,7 +362,11 @@ }, "dragging": false, "height": 607, - "id": "note-5yMAo", + "id": "note-bzlUs", + "measured": { + "height": 607, + "width": 328 + }, "position": { "x": 221.74248905040588, "y": 363.5469410934121 @@ -389,7 +388,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-aMAQ2", + "id": "Prompt-QFfcl", "node": { "base_classes": [ "Message" @@ -494,7 +493,11 @@ }, "dragging": false, "height": 260, - "id": "Prompt-aMAQ2", + "id": "Prompt-QFfcl", + "measured": { + "height": 260, + "width": 360 + }, "position": { "x": 813.5727530934735, "y": 991.0702563306074 @@ -511,7 +514,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-aCpBy", + "id": "ChatOutput-vBbvi", "node": { "base_classes": [ "Message" @@ -772,7 +775,11 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-aCpBy", + "id": "ChatOutput-vBbvi", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1598.2529634286327, "y": 623.4799714496987 @@ -787,15 +794,44 @@ }, { "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-E96kR", + "id": "note-BWTHt", + "node": { + "description": "## Make sure to add your OpenAI API key from [platform.openai.com](https://platform.openai.com). ", + "display_name": "", + "documentation": "", + "template": {} + }, + "type": "note" + }, + "dragging": false, + "height": 325, + "id": "note-BWTHt", + "measured": { + "height": 325, + "width": 328 + }, + "position": { + "x": 1207.1996899547116, + "y": 260.0148704431837 + }, + "positionAbsolute": { + "x": 1207.1996899547116, + "y": 260.0148704431837 + }, + "selected": false, + "type": "noteNode", + "width": 325 + }, + { + "data": { + "id": "OpenAIModel-3mbCD", "node": { "base_classes": [ "LanguageModel", "Message" ], "beta": false, + "category": "models", "conditional_paths": [], "custom_fields": {}, "description": "Generates text using OpenAI LLMs.", @@ -809,19 +845,18 @@ "max_tokens", "model_kwargs", "json_mode", - "output_schema", "model_name", "openai_api_base", "api_key", "temperature", - "seed", - "output_parser" + "seed" ], "frozen": false, "icon": "OpenAI", + "key": "OpenAIModel", "legacy": false, - "lf_version": "1.0.19.post2", "metadata": {}, + "minimized": false, "output_types": [], "outputs": [ { @@ -852,6 +887,7 @@ } ], "pinned": false, + "score": 2.220446049250313e-16, "template": { "_type": "Component", "api_key": { @@ -901,12 +937,14 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "input_value", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_input": true, "trace_as_metadata": true, "type": "str", @@ -919,11 +957,13 @@ "dynamic": false, "info": "If True, it will output JSON regardless of passing a schema.", "list": false, + "list_add_label": "Add More", "name": "json_mode", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "bool", "value": false @@ -935,6 +975,7 @@ "dynamic": false, "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", "list": false, + "list_add_label": "Add More", "name": "max_tokens", "placeholder": "", "range_spec": { @@ -946,6 +987,7 @@ "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "int", "value": "" @@ -957,11 +999,13 @@ "dynamic": false, "info": "Additional keyword arguments to pass to the model.", "list": false, + "list_add_label": "Add More", "name": "model_kwargs", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_input": true, "type": "dict", "value": {} @@ -970,6 +1014,7 @@ "_input_type": "DropdownInput", "advanced": false, "combobox": false, + "dialog_inputs": {}, "display_name": "Model Name", "dynamic": false, "info": "", @@ -983,6 +1028,7 @@ "gpt-3.5-turbo", "gpt-3.5-turbo-0125" ], + "options_metadata": [], "placeholder": "", "required": false, "show": true, @@ -999,12 +1045,14 @@ "dynamic": false, "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", "list": false, + "list_add_label": "Add More", "load_from_db": false, "name": "openai_api_base", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "str", "value": "" @@ -1016,11 +1064,13 @@ "dynamic": false, "info": "The seed controls the reproducibility of the job.", "list": false, + "list_add_label": "Add More", "name": "seed", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "int", "value": 1 @@ -1032,17 +1082,19 @@ "dynamic": false, "info": "Stream the response from the model. Streaming works only in Chat.", "list": false, + "list_add_label": "Add More", "name": "stream", "placeholder": "", "required": false, "show": true, "title_case": false, + "tool_mode": false, "trace_as_metadata": true, "type": "bool", "value": false }, "system_message": { - "_input_type": "MessageTextInput", + "_input_type": "MultilineInput", "advanced": false, "display_name": "System Message", "dynamic": false, @@ -1051,7 +1103,9 @@ "Message" ], "list": false, + "list_add_label": "Add More", "load_from_db": false, + "multiline": true, "name": "system_message", "placeholder": "", "required": false, @@ -1064,72 +1118,57 @@ "value": "" }, "temperature": { - "_input_type": "FloatInput", + "_input_type": "SliderInput", "advanced": false, "display_name": "Temperature", "dynamic": false, "info": "", - "list": false, + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", "name": "temperature", "placeholder": "", + "range_spec": { + "max": 2, + "min": 0, + "step": 0.01, + "step_type": "float" + }, "required": false, "show": true, + "slider_buttons": false, + "slider_buttons_options": [], + "slider_input": false, "title_case": false, - "trace_as_metadata": true, - "type": "float", + "tool_mode": false, + "type": "slider", "value": 0.1 } }, "tool_mode": false }, + "showNode": true, "type": "OpenAIModel" }, "dragging": false, - "height": 543, - "id": "OpenAIModel-E96kR", - "position": { - "x": 1207.6180121002271, - "y": 400.34849438035565 + "id": "OpenAIModel-3mbCD", + "measured": { + "height": 734, + "width": 360 }, - "positionAbsolute": { - "x": 1207.6180121002271, - "y": 400.34849438035565 + "position": { + "x": 1211.6745177781336, + "y": 389.1200512413449 }, "selected": false, - "type": "genericNode", - "width": 320 - }, - { - "data": { - "id": "note-qiq3C", - "node": { - "description": "## Make sure to add your OpenAI API key from [platform.openai.com](https://platform.openai.com). ", - "display_name": "", - "documentation": "", - "template": {} - }, - "type": "note" - }, - "dragging": false, - "height": 325, - "id": "note-qiq3C", - "position": { - "x": 1207.1996899547116, - "y": 260.0148704431837 - }, - "positionAbsolute": { - "x": 1207.1996899547116, - "y": 260.0148704431837 - }, - "selected": false, - "type": "noteNode", - "width": 325 + "type": "genericNode" } ], "viewport": { - "x": -106.23719516361678, - "y": -93.96601486484758, - "zoom": 0.7759242611491008 + "x": -34.95262355945238, + "y": -104.978464862529, + "zoom": 0.7683067619311971 } }, "description": "Generates targeted SEO keywords based on product information, pain points, and customer profiles for strategic marketing.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json b/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json index cb9d87383..007867bda 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-LDhCf", + "id": "Agent-wKeIr", "name": "response", "output_types": [ "Message" @@ -15,18 +15,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-YQ7Vi", + "id": "ChatOutput-BabAw", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-LDhCf{œdataTypeœ:œAgentœ,œidœ:œAgent-LDhCfœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-YQ7Vi{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-YQ7Viœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Agent-LDhCf", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-LDhCfœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-YQ7Vi", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-YQ7Viœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-wKeIr{œdataTypeœ:œAgentœ,œidœ:œAgent-wKeIrœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-BabAw{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-BabAwœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Agent-wKeIr", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-wKeIrœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-BabAw", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-BabAwœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -34,7 +34,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-Pe4nO", + "id": "Prompt-TXNvz", "name": "prompt", "output_types": [ "Message" @@ -42,24 +42,25 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-LDhCf", + "id": "Agent-wKeIr", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-Pe4nO{œdataTypeœ:œPromptœ,œidœ:œPrompt-Pe4nOœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-LDhCf{œfieldNameœ:œinput_valueœ,œidœ:œAgent-LDhCfœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-Pe4nO", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-Pe4nOœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-LDhCf", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-LDhCfœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Prompt-TXNvz{œdataTypeœ:œPromptœ,œidœ:œPrompt-TXNvzœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-wKeIr{œfieldNameœ:œinput_valueœ,œidœ:œAgent-wKeIrœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-TXNvz", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-TXNvzœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-wKeIr", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-wKeIrœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "CalculatorComponent", - "id": "CalculatorComponent-unDLj", + "id": "CalculatorComponent-btXJ9", "name": "component_as_tool", "output_types": [ "Tool" @@ -67,18 +68,18 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-LDhCf", + "id": "Agent-wKeIr", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "xy-edge__CalculatorComponent-unDLj{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-unDLjœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-LDhCf{œfieldNameœ:œtoolsœ,œidœ:œAgent-LDhCfœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "CalculatorComponent-unDLj", - "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-unDLjœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-LDhCf", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-LDhCfœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-CalculatorComponent-btXJ9{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-btXJ9œ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-wKeIr{œfieldNameœ:œtoolsœ,œidœ:œAgent-wKeIrœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "CalculatorComponent-btXJ9", + "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-btXJ9œ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-wKeIr", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-wKeIrœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" } ], "nodes": [ @@ -86,7 +87,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-Pe4nO", + "id": "Prompt-TXNvz", "node": { "base_classes": [ "Message" @@ -312,10 +313,10 @@ }, "dragging": false, "height": 693, - "id": "Prompt-Pe4nO", + "id": "Prompt-TXNvz", "measured": { "height": 693, - "width": 320 + "width": 360 }, "position": { "x": 1349.861745038984, @@ -333,7 +334,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-YQ7Vi", + "id": "ChatOutput-BabAw", "node": { "base_classes": [ "Message" @@ -594,10 +595,10 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-YQ7Vi", + "id": "ChatOutput-BabAw", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 2240.3625274769397, @@ -613,7 +614,7 @@ }, { "data": { - "id": "note-o7ebV", + "id": "note-ux8AH", "node": { "description": "# SaaS Pricing Calculator\n\nWelcome to the SaaS Pricing Calculator! This flow helps you determine the optimal monthly subscription price for your software service.\n\n## Instructions\n\n1. Prepare Your Data\n - Gather information on monthly infrastructure costs\n - Calculate customer support expenses\n - Estimate continuous development costs\n - Decide on your desired profit margin\n - Determine the estimated number of subscribers\n\n2. Input Values\n - Enter the gathered data into the respective fields in the Prompt node\n - Double-check the accuracy of your inputs\n\n3. Run the Flow\n - Click the \"Run\" button to start the calculation process\n - The flow will use Chain-of-Thought prompting to guide the AI through the steps\n\n4. Review the Results\n - Examine the output in the Chat Output node\n - The result will show a breakdown of costs and the final subscription price\n\n5. Adjust and Refine\n - If needed, modify your inputs to explore different pricing scenarios\n - Re-run the flow to see how changes affect the final price\n\nRemember: Regularly update your costs and subscriber estimates to keep your pricing model accurate and competitive! 💼📊", "display_name": "", @@ -624,10 +625,10 @@ }, "dragging": false, "height": 800, - "id": "note-o7ebV", + "id": "note-ux8AH", "measured": { "height": 800, - "width": 325 + "width": 328 }, "position": { "x": 689.7659055360411, @@ -650,7 +651,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Agent", - "id": "Agent-LDhCf", + "id": "Agent-wKeIr", "node": { "base_classes": [ "Message" @@ -790,7 +791,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -798,7 +799,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -1211,10 +1212,10 @@ }, "dragging": false, "height": 650, - "id": "Agent-LDhCf", + "id": "Agent-wKeIr", "measured": { "height": 650, - "width": 320 + "width": 360 }, "position": { "x": 1819.2633856623966, @@ -1224,13 +1225,13 @@ "x": 1819.2633856623966, "y": 138.32023808479687 }, - "selected": false, + "selected": true, "type": "genericNode", "width": 320 }, { "data": { - "id": "CalculatorComponent-unDLj", + "id": "CalculatorComponent-btXJ9", "node": { "base_classes": [ "Data" @@ -1255,6 +1256,7 @@ "output_types": [], "outputs": [ { + "allows_loop": false, "cache": true, "display_name": "Toolset", "hidden": null, @@ -1405,23 +1407,23 @@ "type": "CalculatorComponent" }, "dragging": false, - "id": "CalculatorComponent-unDLj", + "id": "CalculatorComponent-btXJ9", "measured": { - "height": 333, - "width": 320 + "height": 374, + "width": 360 }, "position": { "x": 1350.9477037257504, "y": -45.351578570289234 }, - "selected": true, + "selected": false, "type": "genericNode" } ], "viewport": { - "x": -412.6248764419154, - "y": 239.5139629945674, - "zoom": 0.6920494987327928 + "x": -432.45261318505345, + "y": 74.8182374148081, + "zoom": 0.7507017664074155 } }, "description": "Calculate SaaS subscription price based on costs, profit margin, and subscribers using step-by-step method and Chain-of-Thought prompting. ", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json b/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json index f6d89e896..69e3ecb98 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-h73y0", + "id": "Prompt-xirI8", "name": "prompt", "output_types": [ "Message" @@ -15,18 +15,18 @@ }, "targetHandle": { "fieldName": "system_prompt", - "id": "Agent-uuZ76", + "id": "Agent-9YXRo", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-h73y0{œdataTypeœ:œPromptœ,œidœ:œPrompt-h73y0œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-uuZ76{œfieldNameœ:œsystem_promptœ,œidœ:œAgent-uuZ76œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-h73y0", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-h73y0œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-uuZ76", - "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œAgent-uuZ76œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Prompt-xirI8{œdataTypeœ:œPromptœ,œidœ:œPrompt-xirI8œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-9YXRo{œfieldNameœ:œsystem_promptœ,œidœ:œAgent-9YXRoœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-xirI8", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-xirI8œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-9YXRo", + "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œAgent-9YXRoœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -34,7 +34,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-kaNRB", + "id": "Prompt-f4paU", "name": "prompt", "output_types": [ "Message" @@ -42,18 +42,18 @@ }, "targetHandle": { "fieldName": "system_prompt", - "id": "Agent-9kiKa", + "id": "Agent-RmOB2", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-kaNRB{œdataTypeœ:œPromptœ,œidœ:œPrompt-kaNRBœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-9kiKa{œfieldNameœ:œsystem_promptœ,œidœ:œAgent-9kiKaœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-kaNRB", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-kaNRBœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-9kiKa", - "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œAgent-9kiKaœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Prompt-f4paU{œdataTypeœ:œPromptœ,œidœ:œPrompt-f4paUœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-RmOB2{œfieldNameœ:œsystem_promptœ,œidœ:œAgent-RmOB2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-f4paU", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-f4paUœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-RmOB2", + "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œAgent-RmOB2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -61,7 +61,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-uuZ76", + "id": "Agent-9YXRo", "name": "response", "output_types": [ "Message" @@ -69,18 +69,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-r9E97", + "id": "ChatOutput-DqyyQ", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-uuZ76{œdataTypeœ:œAgentœ,œidœ:œAgent-uuZ76œ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-r9E97{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-r9E97œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Agent-uuZ76", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-uuZ76œ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-r9E97", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-r9E97œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-9YXRo{œdataTypeœ:œAgentœ,œidœ:œAgent-9YXRoœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-DqyyQ{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-DqyyQœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Agent-9YXRo", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-9YXRoœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-DqyyQ", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-DqyyQœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -88,7 +88,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-9kiKa", + "id": "Agent-RmOB2", "name": "response", "output_types": [ "Message" @@ -96,7 +96,7 @@ }, "targetHandle": { "fieldName": "finance_agent_output", - "id": "Prompt-h73y0", + "id": "Prompt-xirI8", "inputTypes": [ "Message", "Text" @@ -104,11 +104,11 @@ "type": "str" } }, - "id": "reactflow__edge-Agent-9kiKa{œdataTypeœ:œAgentœ,œidœ:œAgent-9kiKaœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-h73y0{œfieldNameœ:œfinance_agent_outputœ,œidœ:œPrompt-h73y0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "Agent-9kiKa", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-9kiKaœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-h73y0", - "targetHandle": "{œfieldNameœ: œfinance_agent_outputœ, œidœ: œPrompt-h73y0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-RmOB2{œdataTypeœ:œAgentœ,œidœ:œAgent-RmOB2œ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-xirI8{œfieldNameœ:œfinance_agent_outputœ,œidœ:œPrompt-xirI8œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "Agent-RmOB2", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-RmOB2œ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-xirI8", + "targetHandle": "{œfieldNameœ: œfinance_agent_outputœ, œidœ: œPrompt-xirI8œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -116,7 +116,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-udfr5", + "id": "ChatInput-TQ1li", "name": "message", "output_types": [ "Message" @@ -124,18 +124,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-udfr5{œdataTypeœ:œChatInputœ,œidœ:œChatInput-udfr5œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-i5i7H{œfieldNameœ:œinput_valueœ,œidœ:œAgent-i5i7Hœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-udfr5", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-udfr5œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-i5i7H", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-i5i7Hœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ChatInput-TQ1li{œdataTypeœ:œChatInputœ,œidœ:œChatInput-TQ1liœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-TmQ5O{œfieldNameœ:œinput_valueœ,œidœ:œAgent-TmQ5Oœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-TQ1li", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-TQ1liœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-TmQ5O", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-TmQ5Oœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -143,7 +143,7 @@ "data": { "sourceHandle": { "dataType": "Prompt", - "id": "Prompt-62kjh", + "id": "Prompt-3fyqW", "name": "prompt", "output_types": [ "Message" @@ -151,18 +151,18 @@ }, "targetHandle": { "fieldName": "system_prompt", - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Prompt-62kjh{œdataTypeœ:œPromptœ,œidœ:œPrompt-62kjhœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-i5i7H{œfieldNameœ:œsystem_promptœ,œidœ:œAgent-i5i7Hœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-62kjh", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-62kjhœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-i5i7H", - "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œAgent-i5i7Hœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Prompt-3fyqW{œdataTypeœ:œPromptœ,œidœ:œPrompt-3fyqWœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-TmQ5O{œfieldNameœ:œsystem_promptœ,œidœ:œAgent-TmQ5Oœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-3fyqW", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-3fyqWœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-TmQ5O", + "targetHandle": "{œfieldNameœ: œsystem_promptœ, œidœ: œAgent-TmQ5Oœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -170,7 +170,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "name": "response", "output_types": [ "Message" @@ -178,18 +178,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-9kiKa", + "id": "Agent-RmOB2", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-i5i7H{œdataTypeœ:œAgentœ,œidœ:œAgent-i5i7Hœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Agent-9kiKa{œfieldNameœ:œinput_valueœ,œidœ:œAgent-9kiKaœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Agent-i5i7H", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-i5i7Hœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-9kiKa", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-9kiKaœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-TmQ5O{œdataTypeœ:œAgentœ,œidœ:œAgent-TmQ5Oœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Agent-RmOB2{œfieldNameœ:œinput_valueœ,œidœ:œAgent-RmOB2œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Agent-TmQ5O", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-TmQ5Oœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-RmOB2", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-RmOB2œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -197,7 +197,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "name": "response", "output_types": [ "Message" @@ -205,7 +205,7 @@ }, "targetHandle": { "fieldName": "research_agent_output", - "id": "Prompt-h73y0", + "id": "Prompt-xirI8", "inputTypes": [ "Message", "Text" @@ -213,18 +213,18 @@ "type": "str" } }, - "id": "reactflow__edge-Agent-i5i7H{œdataTypeœ:œAgentœ,œidœ:œAgent-i5i7Hœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-h73y0{œfieldNameœ:œresearch_agent_outputœ,œidœ:œPrompt-h73y0œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "Agent-i5i7H", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-i5i7Hœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-h73y0", - "targetHandle": "{œfieldNameœ: œresearch_agent_outputœ, œidœ: œPrompt-h73y0œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-TmQ5O{œdataTypeœ:œAgentœ,œidœ:œAgent-TmQ5Oœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Prompt-xirI8{œfieldNameœ:œresearch_agent_outputœ,œidœ:œPrompt-xirI8œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "Agent-TmQ5O", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-TmQ5Oœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-xirI8", + "targetHandle": "{œfieldNameœ: œresearch_agent_outputœ, œidœ: œPrompt-xirI8œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "className": "", "data": { "sourceHandle": { "dataType": "CalculatorComponent", - "id": "CalculatorComponent-RNHql", + "id": "CalculatorComponent-82dCo", "name": "component_as_tool", "output_types": [ "Tool" @@ -232,25 +232,25 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-uuZ76", + "id": "Agent-9YXRo", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "reactflow__edge-CalculatorComponent-RNHql{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-RNHqlœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-uuZ76{œfieldNameœ:œtoolsœ,œidœ:œAgent-uuZ76œ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "CalculatorComponent-RNHql", - "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-RNHqlœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-uuZ76", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-uuZ76œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-CalculatorComponent-82dCo{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-82dCoœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-9YXRo{œfieldNameœ:œtoolsœ,œidœ:œAgent-9YXRoœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "CalculatorComponent-82dCo", + "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-82dCoœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-9YXRo", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-9YXRoœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "className": "", "data": { "sourceHandle": { "dataType": "YfinanceComponent", - "id": "YfinanceComponent-FS7QO", + "id": "YfinanceComponent-P0VBm", "name": "component_as_tool", "output_types": [ "Tool" @@ -258,24 +258,25 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-9kiKa", + "id": "Agent-RmOB2", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "reactflow__edge-YfinanceComponent-FS7QO{œdataTypeœ:œYfinanceComponentœ,œidœ:œYfinanceComponent-FS7QOœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-9kiKa{œfieldNameœ:œtoolsœ,œidœ:œAgent-9kiKaœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "YfinanceComponent-FS7QO", - "sourceHandle": "{œdataTypeœ: œYfinanceComponentœ, œidœ: œYfinanceComponent-FS7QOœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-9kiKa", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-9kiKaœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-YfinanceComponent-P0VBm{œdataTypeœ:œYfinanceComponentœ,œidœ:œYfinanceComponent-P0VBmœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-RmOB2{œfieldNameœ:œtoolsœ,œidœ:œAgent-RmOB2œ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "YfinanceComponent-P0VBm", + "sourceHandle": "{œdataTypeœ: œYfinanceComponentœ, œidœ: œYfinanceComponent-P0VBmœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-RmOB2", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-RmOB2œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "TavilySearchComponent", - "id": "TavilySearchComponent-uLUDV", + "id": "TavilySearchComponent-ZgS55", "name": "component_as_tool", "output_types": [ "Tool" @@ -283,18 +284,18 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "xy-edge__TavilySearchComponent-uLUDV{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-uLUDVœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-i5i7H{œfieldNameœ:œtoolsœ,œidœ:œAgent-i5i7Hœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "TavilySearchComponent-uLUDV", - "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-uLUDVœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-i5i7H", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-i5i7Hœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-TavilySearchComponent-ZgS55{œdataTypeœ:œTavilySearchComponentœ,œidœ:œTavilySearchComponent-ZgS55œ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-TmQ5O{œfieldNameœ:œtoolsœ,œidœ:œAgent-TmQ5Oœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "TavilySearchComponent-ZgS55", + "sourceHandle": "{œdataTypeœ: œTavilySearchComponentœ, œidœ: œTavilySearchComponent-ZgS55œ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-TmQ5O", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-TmQ5Oœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" } ], "nodes": [ @@ -302,7 +303,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-r9E97", + "id": "ChatOutput-DqyyQ", "node": { "base_classes": [ "Message" @@ -563,7 +564,7 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-r9E97", + "id": "ChatOutput-DqyyQ", "measured": { "height": 234, "width": 360 @@ -584,7 +585,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Finance Agent", - "id": "Agent-9kiKa", + "id": "Agent-RmOB2", "node": { "base_classes": [ "Message" @@ -724,7 +725,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -732,7 +733,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -1145,7 +1146,7 @@ }, "dragging": false, "height": 650, - "id": "Agent-9kiKa", + "id": "Agent-RmOB2", "measured": { "height": 650, "width": 360 @@ -1166,7 +1167,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Analysis & Editor Agent", - "id": "Agent-uuZ76", + "id": "Agent-9YXRo", "node": { "base_classes": [ "Message" @@ -1306,7 +1307,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -1314,7 +1315,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -1727,7 +1728,7 @@ }, "dragging": false, "height": 650, - "id": "Agent-uuZ76", + "id": "Agent-9YXRo", "measured": { "height": 650, "width": 360 @@ -1748,7 +1749,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-62kjh", + "id": "Prompt-3fyqW", "node": { "base_classes": [ "Message" @@ -1859,7 +1860,7 @@ }, "dragging": false, "height": 260, - "id": "Prompt-62kjh", + "id": "Prompt-3fyqW", "measured": { "height": 260, "width": 360 @@ -1880,7 +1881,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-kaNRB", + "id": "Prompt-f4paU", "node": { "base_classes": [ "Message" @@ -1991,7 +1992,7 @@ }, "dragging": false, "height": 260, - "id": "Prompt-kaNRB", + "id": "Prompt-f4paU", "measured": { "height": 260, "width": 360 @@ -2012,7 +2013,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-h73y0", + "id": "Prompt-xirI8", "node": { "base_classes": [ "Message" @@ -2172,7 +2173,7 @@ }, "dragging": false, "height": 433, - "id": "Prompt-h73y0", + "id": "Prompt-xirI8", "measured": { "height": 433, "width": 360 @@ -2191,7 +2192,7 @@ }, { "data": { - "id": "ChatInput-udfr5", + "id": "ChatInput-TQ1li", "node": { "base_classes": [ "Message" @@ -2472,7 +2473,7 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-udfr5", + "id": "ChatInput-TQ1li", "measured": { "height": 234, "width": 360 @@ -2491,7 +2492,7 @@ }, { "data": { - "id": "note-rwLko", + "id": "note-j0zav", "node": { "description": "# Sequential Tasks Agents\n\n## Overview\nThis flow demonstrates how to chain multiple AI agents for comprehensive research and analysis. Each agent specializes in different aspects of the research process, building upon the previous agent's work.\n\n## How to Use the Flow\n\n1. **Input Your Query** 🎯\n - Be specific and clear\n - Include key aspects you want analyzed\n - Examples:\n ```\n Good: \"Should I invest in Tesla (TSLA)? Focus on AI development impact\"\n Bad: \"Tell me about Tesla\"\n ```\n\n2. **Research Agent Process** 🔍\n - Utilizes Tavily Search for comprehensive research\n\n\n3. **Specialized Analysis** 📊\n - Each agent adds unique value:\n ```\n Research Agent → Deep Research & Context\n ↓\n Finance Agent → Data Analysis & Metrics\n ↓\n Editor Agent → Final Synthesis & Report\n ```\n\n4. **Output Format** 📝\n - Structured report\n - Embedded images and charts\n - Data-backed insights\n - Clear recommendations\n\n## Pro Tips\n\n### Query Construction\n- Include specific points of interest\n- Mention required metrics or data points\n- Specify time frames if relevant\n\n### Flow Customization\n- Modify agent prompts for different use cases\n- Add or remove tools as needed\n\n## Common Applications\n- Investment Research\n- Market Analysis\n- Competitive Intelligence\n- Industry Reports\n- Technology Impact Studies\n\n⚡ **Best Practice**: Start with a test query to understand the flow's capabilities before running complex analyses.\n\n---\n*Note: This flow template uses financial analysis as an example but can be adapted for any research-intensive task requiring multiple perspectives and data sources.*", "display_name": "", @@ -2502,7 +2503,7 @@ }, "dragging": false, "height": 800, - "id": "note-rwLko", + "id": "note-j0zav", "measured": { "height": 800, "width": 328 @@ -2526,7 +2527,7 @@ }, { "data": { - "id": "note-f0wVd", + "id": "note-pUC9D", "node": { "description": "## What Are Sequential Task Agents?\nA system where multiple AI agents work in sequence, each specializing in specific tasks and passing their output to the next agent in the chain. Think of it as an assembly line where each agent adds value to the final result.\n\n## How It Works\n1. **First Agent** → **Second Agent** → **Third Agent** → **Final Output**\n - Each agent receives input from the previous one\n - Processes and enhances the information\n - Passes refined output forward\n\n## Key Benefits\n- **Specialization**: Each agent focuses on specific tasks\n- **Progressive Refinement**: Information gets enhanced at each step\n- **Structured Output**: Final result combines multiple perspectives\n- **Quality Control**: Each agent validates and improves previous work\n\n## Building Your Own Sequence\n1. **Plan Your Chain**\n - Identify distinct tasks\n - Determine logical order\n - Define input/output requirements\n\n2. **Configure Agents**\n - Give each agent clear instructions\n - Ensure compatible outputs/inputs\n - Set appropriate tools for each agent\n\n3. **Connect the Flow**\n - Link agents in proper order\n - Test data flow between agents\n - Verify final output format\n\n## Example Applications\n- Research → Analysis → Report Writing\n- Data Collection → Processing → Visualization\n- Content Research → Writing → Editing\n- Market Analysis → Financial Review → Investment Advice\n\n⭐ **Pro Tip**: The strength of sequential agents comes from how well they complement each other's capabilities.\n\nThis template uses financial analysis as an example, but you can adapt it for any multi-step process requiring different expertise at each stage.", "display_name": "", @@ -2539,7 +2540,7 @@ }, "dragging": false, "height": 800, - "id": "note-f0wVd", + "id": "note-pUC9D", "measured": { "height": 800, "width": 328 @@ -2565,7 +2566,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Researcher Agent", - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "node": { "base_classes": [ "Message" @@ -2705,7 +2706,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -2713,7 +2714,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -3126,7 +3127,7 @@ }, "dragging": false, "height": 650, - "id": "Agent-i5i7H", + "id": "Agent-TmQ5O", "measured": { "height": 650, "width": 360 @@ -3145,7 +3146,7 @@ }, { "data": { - "id": "note-MGiP3", + "id": "note-NgTrE", "node": { "description": "## Get your API key at [https://tavily.com](https://tavily.com)\n", "display_name": "", @@ -3158,7 +3159,7 @@ }, "dragging": false, "height": 324, - "id": "note-MGiP3", + "id": "note-NgTrE", "measured": { "height": 324, "width": 328 @@ -3182,7 +3183,7 @@ }, { "data": { - "id": "note-Luc39", + "id": "note-7I7gz", "node": { "description": "## Configure the agent by obtaining your OpenAI API key from [platform.openai.com](https://platform.openai.com). Under \"Model Provider\", choose:\n- OpenAI: Default, requires only API key\n- Anthropic/Azure/Groq/NVIDIA: Each requires their own API keys\n- Custom: Use your own model endpoint + authentication\n\nSelect model and input API key before running the flow.", "display_name": "", @@ -3195,7 +3196,7 @@ }, "dragging": false, "height": 324, - "id": "note-Luc39", + "id": "note-7I7gz", "measured": { "height": 324, "width": 328 @@ -3219,7 +3220,7 @@ }, { "data": { - "id": "YfinanceComponent-FS7QO", + "id": "YfinanceComponent-P0VBm", "node": { "base_classes": [ "Data", @@ -3466,7 +3467,7 @@ "type": "YfinanceComponent" }, "dragging": true, - "id": "YfinanceComponent-FS7QO", + "id": "YfinanceComponent-P0VBm", "measured": { "height": 581, "width": 360 @@ -3480,7 +3481,7 @@ }, { "data": { - "id": "CalculatorComponent-RNHql", + "id": "CalculatorComponent-82dCo", "node": { "base_classes": [ "Data" @@ -3655,7 +3656,7 @@ "type": "CalculatorComponent" }, "dragging": false, - "id": "CalculatorComponent-RNHql", + "id": "CalculatorComponent-82dCo", "measured": { "height": 374, "width": 360 @@ -3669,7 +3670,7 @@ }, { "data": { - "id": "TavilySearchComponent-uLUDV", + "id": "TavilySearchComponent-ZgS55", "node": { "base_classes": [ "Data", @@ -3701,6 +3702,7 @@ "output_types": [], "outputs": [ { + "allows_loop": false, "cache": true, "display_name": "Toolset", "hidden": null, @@ -3727,7 +3729,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -3973,7 +3975,7 @@ "type": "TavilySearchComponent" }, "dragging": false, - "id": "TavilySearchComponent-uLUDV", + "id": "TavilySearchComponent-ZgS55", "measured": { "height": 489, "width": 360 @@ -3987,9 +3989,9 @@ } ], "viewport": { - "x": 1043.611076363603, - "y": 930.7679466669072, - "zoom": 0.5467702171368981 + "x": 905.1150074113123, + "y": 872.5950106358109, + "zoom": 0.3920220111611041 } }, "description": "This Agent is designed to systematically execute a series of tasks following a meticulously predefined sequence. By adhering to this structured order, the Agent ensures that each task is completed efficiently and effectively, optimizing overall performance and maintaining a high level of accuracy.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json b/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json index 1b3ae8348..2b9192aa1 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-GnVa9", + "id": "ChatInput-Kdh0W", "name": "message", "output_types": [ "Message" @@ -15,19 +15,19 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-3ilRg", + "id": "Agent-3NhNI", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-GnVa9{œdataTypeœ:œChatInputœ,œidœ:œChatInput-GnVa9œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-3ilRg{œfieldNameœ:œinput_valueœ,œidœ:œAgent-3ilRgœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-ChatInput-Kdh0W{œdataTypeœ:œChatInputœ,œidœ:œChatInput-Kdh0Wœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-3NhNI{œfieldNameœ:œinput_valueœ,œidœ:œAgent-3NhNIœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "ChatInput-GnVa9", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-GnVa9œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-3ilRg", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-3ilRgœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "ChatInput-Kdh0W", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-Kdh0Wœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-3NhNI", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-3NhNIœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -35,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-3ilRg", + "id": "Agent-3NhNI", "name": "response", "output_types": [ "Message" @@ -43,26 +43,26 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-KeRVx", + "id": "ChatOutput-SzD3j", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-3ilRg{œdataTypeœ:œAgentœ,œidœ:œAgent-3ilRgœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-KeRVx{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-KeRVxœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "id": "reactflow__edge-Agent-3NhNI{œdataTypeœ:œAgentœ,œidœ:œAgent-3NhNIœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-SzD3j{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-SzD3jœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", "selected": false, - "source": "Agent-3ilRg", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-3ilRgœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-KeRVx", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-KeRVxœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "source": "Agent-3NhNI", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-3NhNIœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-SzD3j", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-SzD3jœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "className": "", "data": { "sourceHandle": { "dataType": "CalculatorComponent", - "id": "CalculatorComponent-sh2uy", + "id": "CalculatorComponent-F89Ck", "name": "component_as_tool", "output_types": [ "Tool" @@ -70,24 +70,25 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-3ilRg", + "id": "Agent-3NhNI", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "reactflow__edge-CalculatorComponent-sh2uy{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-sh2uyœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-3ilRg{œfieldNameœ:œtoolsœ,œidœ:œAgent-3ilRgœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "CalculatorComponent-sh2uy", - "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-sh2uyœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-3ilRg", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-3ilRgœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-CalculatorComponent-F89Ck{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-F89Ckœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-3NhNI{œfieldNameœ:œtoolsœ,œidœ:œAgent-3NhNIœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "CalculatorComponent-F89Ck", + "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-F89Ckœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-3NhNI", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-3NhNIœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "URL", - "id": "URL-fbsLh", + "id": "URL-4Q2PI", "name": "component_as_tool", "output_types": [ "Tool" @@ -95,18 +96,18 @@ }, "targetHandle": { "fieldName": "tools", - "id": "Agent-3ilRg", + "id": "Agent-3NhNI", "inputTypes": [ "Tool" ], "type": "other" } }, - "id": "xy-edge__URL-fbsLh{œdataTypeœ:œURLœ,œidœ:œURL-fbsLhœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-3ilRg{œfieldNameœ:œtoolsœ,œidœ:œAgent-3ilRgœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "URL-fbsLh", - "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-fbsLhœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-3ilRg", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-3ilRgœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-URL-4Q2PI{œdataTypeœ:œURLœ,œidœ:œURL-4Q2PIœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-3NhNI{œfieldNameœ:œtoolsœ,œidœ:œAgent-3NhNIœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "URL-4Q2PI", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-4Q2PIœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-3NhNI", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-3NhNIœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" } ], "nodes": [ @@ -114,7 +115,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Agent", - "id": "Agent-3ilRg", + "id": "Agent-3NhNI", "node": { "base_classes": [ "Message" @@ -254,7 +255,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -262,7 +263,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -674,7 +675,7 @@ "type": "Agent" }, "dragging": false, - "id": "Agent-3ilRg", + "id": "Agent-3NhNI", "measured": { "height": 698, "width": 360 @@ -683,12 +684,12 @@ "x": 1652.2479633316434, "y": 297.9085084144251 }, - "selected": false, + "selected": true, "type": "genericNode" }, { "data": { - "id": "ChatInput-GnVa9", + "id": "ChatInput-Kdh0W", "node": { "base_classes": [ "Message" @@ -968,7 +969,7 @@ "type": "ChatInput" }, "dragging": false, - "id": "ChatInput-GnVa9", + "id": "ChatInput-Kdh0W", "measured": { "height": 257, "width": 360 @@ -984,7 +985,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-KeRVx", + "id": "ChatOutput-SzD3j", "node": { "base_classes": [ "Message" @@ -1243,7 +1244,7 @@ }, "type": "ChatOutput" }, - "id": "ChatOutput-KeRVx", + "id": "ChatOutput-SzD3j", "measured": { "height": 257, "width": 360 @@ -1259,7 +1260,7 @@ "data": { "description": "Load and retrive data from specified URLs.", "display_name": "URL", - "id": "URL-fbsLh", + "id": "URL-4Q2PI", "node": { "base_classes": [ "Data", @@ -1468,7 +1469,7 @@ "type": "URL" }, "dragging": false, - "id": "URL-fbsLh", + "id": "URL-4Q2PI", "measured": { "height": 453, "width": 360 @@ -1482,7 +1483,7 @@ }, { "data": { - "id": "note-159PR", + "id": "note-MeseW", "node": { "description": "# 📖 README\nRun an Agent with URL and Calculator tools available for its use. \nThe Agent decides which tool to use to solve a problem.\n## Quick start\n\n1. Add your OpenAI API key to the Agent.\n2. Open the Playground and chat with the Agent. Request some information about a recipe, and then ask to add two numbers together. In the responses, the Agent will use different tools to solve different problems.\n\n## Next steps\nConnect more tools to the Agent to create your perfect assistant.\n\nFor more, see the [Langflow docs](https://docs.langflow.org/agents-tool-calling-agent-component).", "display_name": "", @@ -1494,7 +1495,7 @@ "type": "note" }, "dragging": false, - "id": "note-159PR", + "id": "note-MeseW", "measured": { "height": 328, "width": 328 @@ -1508,7 +1509,7 @@ }, { "data": { - "id": "note-ELRXf", + "id": "note-yfpyo", "node": { "description": "### 💡 Add your OpenAI API key here👇", "display_name": "", @@ -1519,7 +1520,7 @@ }, "type": "note" }, - "id": "note-ELRXf", + "id": "note-yfpyo", "measured": { "height": 326, "width": 326 @@ -1533,7 +1534,7 @@ }, { "data": { - "id": "CalculatorComponent-sh2uy", + "id": "CalculatorComponent-F89Ck", "node": { "base_classes": [ "Data" @@ -1559,6 +1560,7 @@ "output_types": [], "outputs": [ { + "allows_loop": false, "cache": true, "display_name": "Toolset", "hidden": null, @@ -1709,7 +1711,7 @@ "type": "CalculatorComponent" }, "dragging": false, - "id": "CalculatorComponent-sh2uy", + "id": "CalculatorComponent-F89Ck", "measured": { "height": 374, "width": 360 diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json b/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json index b047b76f5..a378da65a 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-AiQA7", + "id": "Agent-txo0a", "name": "response", "output_types": [ "Message" @@ -15,18 +15,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "ChatOutput-UWiDB", + "id": "ChatOutput-bHF59", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-AiQA7{œdataTypeœ:œAgentœ,œidœ:œAgent-AiQA7œ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-UWiDB{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-UWiDBœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Agent-AiQA7", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-AiQA7œ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-UWiDB", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-UWiDBœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-txo0a{œdataTypeœ:œAgentœ,œidœ:œAgent-txo0aœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-bHF59{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-bHF59œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Agent-txo0a", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-txo0aœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-bHF59", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-bHF59œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -34,7 +34,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-ArtN4", + "id": "Agent-xeg6y", "name": "response", "output_types": [ "Message" @@ -42,18 +42,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-AiQA7", + "id": "Agent-txo0a", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-ArtN4{œdataTypeœ:œAgentœ,œidœ:œAgent-ArtN4œ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Agent-AiQA7{œfieldNameœ:œinput_valueœ,œidœ:œAgent-AiQA7œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Agent-ArtN4", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-ArtN4œ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-AiQA7", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-AiQA7œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-Agent-xeg6y{œdataTypeœ:œAgentœ,œidœ:œAgent-xeg6yœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Agent-txo0a{œfieldNameœ:œinput_valueœ,œidœ:œAgent-txo0aœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Agent-xeg6y", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-xeg6yœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-txo0a", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-txo0aœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -61,7 +61,7 @@ "data": { "sourceHandle": { "dataType": "Agent", - "id": "Agent-ZZ1QV", + "id": "Agent-Bsq4j", "name": "response", "output_types": [ "Message" @@ -69,99 +69,18 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-ArtN4", + "id": "Agent-xeg6y", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-Agent-ZZ1QV{œdataTypeœ:œAgentœ,œidœ:œAgent-ZZ1QVœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Agent-ArtN4{œfieldNameœ:œinput_valueœ,œidœ:œAgent-ArtN4œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Agent-ZZ1QV", - "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-ZZ1QVœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-ArtN4", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-ArtN4œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "SearchAPI", - "id": "SearchAPI-KMYDO", - "name": "api_build_tool", - "output_types": [ - "Tool" - ] - }, - "targetHandle": { - "fieldName": "tools", - "id": "Agent-ZZ1QV", - "inputTypes": [ - "Tool" - ], - "type": "other" - } - }, - "id": "reactflow__edge-SearchAPI-KMYDO{œdataTypeœ:œSearchAPIœ,œidœ:œSearchAPI-KMYDOœ,œnameœ:œapi_build_toolœ,œoutput_typesœ:[œToolœ]}-Agent-ZZ1QV{œfieldNameœ:œtoolsœ,œidœ:œAgent-ZZ1QVœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "SearchAPI-KMYDO", - "sourceHandle": "{œdataTypeœ: œSearchAPIœ, œidœ: œSearchAPI-KMYDOœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-ZZ1QV", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-ZZ1QVœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "url_content_fetcher", - "id": "url_content_fetcher-vZFfk", - "name": "api_build_tool", - "output_types": [ - "Tool" - ] - }, - "targetHandle": { - "fieldName": "tools", - "id": "Agent-ArtN4", - "inputTypes": [ - "Tool" - ], - "type": "other" - } - }, - "id": "reactflow__edge-url_content_fetcher-vZFfk{œdataTypeœ:œurl_content_fetcherœ,œidœ:œurl_content_fetcher-vZFfkœ,œnameœ:œapi_build_toolœ,œoutput_typesœ:[œToolœ]}-Agent-ArtN4{œfieldNameœ:œtoolsœ,œidœ:œAgent-ArtN4œ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "url_content_fetcher-vZFfk", - "sourceHandle": "{œdataTypeœ: œurl_content_fetcherœ, œidœ: œurl_content_fetcher-vZFfkœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-ArtN4", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-ArtN4œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "CalculatorTool", - "id": "CalculatorTool-LJZFv", - "name": "api_build_tool", - "output_types": [ - "Tool" - ] - }, - "targetHandle": { - "fieldName": "tools", - "id": "Agent-AiQA7", - "inputTypes": [ - "Tool" - ], - "type": "other" - } - }, - "id": "reactflow__edge-CalculatorTool-LJZFv{œdataTypeœ:œCalculatorToolœ,œidœ:œCalculatorTool-LJZFvœ,œnameœ:œapi_build_toolœ,œoutput_typesœ:[œToolœ]}-Agent-AiQA7{œfieldNameœ:œtoolsœ,œidœ:œAgent-AiQA7œ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", - "source": "CalculatorTool-LJZFv", - "sourceHandle": "{œdataTypeœ: œCalculatorToolœ, œidœ: œCalculatorTool-LJZFvœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", - "target": "Agent-AiQA7", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-AiQA7œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-Agent-Bsq4j{œdataTypeœ:œAgentœ,œidœ:œAgent-Bsq4jœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-Agent-xeg6y{œfieldNameœ:œinput_valueœ,œidœ:œAgent-xeg6yœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Agent-Bsq4j", + "sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-Bsq4jœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-xeg6y", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-xeg6yœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -169,7 +88,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-onw3j", + "id": "ChatInput-VKkd5", "name": "message", "output_types": [ "Message" @@ -177,24 +96,105 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "Agent-ZZ1QV", + "id": "Agent-Bsq4j", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-onw3j{œdataTypeœ:œChatInputœ,œidœ:œChatInput-onw3jœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-ZZ1QV{œfieldNameœ:œinput_valueœ,œidœ:œAgent-ZZ1QVœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-onw3j", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-onw3jœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Agent-ZZ1QV", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-ZZ1QVœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ChatInput-VKkd5{œdataTypeœ:œChatInputœ,œidœ:œChatInput-VKkd5œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-Bsq4j{œfieldNameœ:œinput_valueœ,œidœ:œAgent-Bsq4jœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-VKkd5", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-VKkd5œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Agent-Bsq4j", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-Bsq4jœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "animated": false, + "className": "", + "data": { + "sourceHandle": { + "dataType": "URL", + "id": "URL-VCoZD", + "name": "component_as_tool", + "output_types": [ + "Tool" + ] + }, + "targetHandle": { + "fieldName": "tools", + "id": "Agent-xeg6y", + "inputTypes": [ + "Tool" + ], + "type": "other" + } + }, + "id": "xy-edge__URL-VCoZD{œdataTypeœ:œURLœ,œidœ:œURL-VCoZDœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-xeg6y{œfieldNameœ:œtoolsœ,œidœ:œAgent-xeg6yœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "URL-VCoZD", + "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-VCoZDœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-xeg6y", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-xeg6yœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + }, + { + "animated": false, + "className": "", + "data": { + "sourceHandle": { + "dataType": "CalculatorComponent", + "id": "CalculatorComponent-pSb5r", + "name": "component_as_tool", + "output_types": [ + "Tool" + ] + }, + "targetHandle": { + "fieldName": "tools", + "id": "Agent-txo0a", + "inputTypes": [ + "Tool" + ], + "type": "other" + } + }, + "id": "xy-edge__CalculatorComponent-pSb5r{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-pSb5rœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-txo0a{œfieldNameœ:œtoolsœ,œidœ:œAgent-txo0aœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "CalculatorComponent-pSb5r", + "sourceHandle": "{œdataTypeœ: œCalculatorComponentœ, œidœ: œCalculatorComponent-pSb5rœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-txo0a", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-txo0aœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" + }, + { + "animated": false, + "className": "", + "data": { + "sourceHandle": { + "dataType": "SearchComponent", + "id": "SearchComponent-BSabY", + "name": "component_as_tool", + "output_types": [ + "Tool" + ] + }, + "targetHandle": { + "fieldName": "tools", + "id": "Agent-Bsq4j", + "inputTypes": [ + "Tool" + ], + "type": "other" + } + }, + "id": "xy-edge__SearchComponent-BSabY{œdataTypeœ:œSearchComponentœ,œidœ:œSearchComponent-BSabYœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-Bsq4j{œfieldNameœ:œtoolsœ,œidœ:œAgent-Bsq4jœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}", + "source": "SearchComponent-BSabY", + "sourceHandle": "{œdataTypeœ: œSearchComponentœ, œidœ: œSearchComponent-BSabYœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", + "target": "Agent-Bsq4j", + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-Bsq4jœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" } ], "nodes": [ { "data": { - "id": "ChatInput-onw3j", + "id": "ChatInput-VKkd5", "node": { "base_classes": [ "Message" @@ -217,7 +217,7 @@ "frozen": false, "icon": "MessagesSquare", "legacy": false, - "lf_version": "1.0.19.post2", + "lf_version": "1.1.1", "metadata": {}, "output_types": [], "outputs": [ @@ -464,10 +464,10 @@ }, "dragging": false, "height": 262, - "id": "ChatInput-onw3j", + "id": "ChatInput-VKkd5", "measured": { "height": 262, - "width": 320 + "width": 360 }, "position": { "x": 1756.77096149088, @@ -485,7 +485,7 @@ "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-UWiDB", + "id": "ChatOutput-bHF59", "node": { "base_classes": [ "Message" @@ -511,7 +511,7 @@ "frozen": false, "icon": "MessagesSquare", "legacy": false, - "lf_version": "1.0.19.post2", + "lf_version": "1.1.1", "metadata": {}, "output_types": [], "outputs": [ @@ -746,10 +746,10 @@ }, "dragging": false, "height": 262, - "id": "ChatOutput-UWiDB", + "id": "ChatOutput-bHF59", "measured": { "height": 262, - "width": 320 + "width": 360 }, "position": { "x": 4349.229697347143, @@ -763,489 +763,11 @@ "type": "genericNode", "width": 360 }, - { - "data": { - "description": "Call the searchapi.io API with result limiting", - "display_name": "Search API [DEPRECATED]", - "id": "SearchAPI-KMYDO", - "node": { - "base_classes": [ - "Data", - "Tool" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Call the searchapi.io API with result limiting", - "display_name": "Search API [DEPRECATED]", - "documentation": "https://www.searchapi.io/docs/google", - "edited": false, - "field_order": [ - "engine", - "api_key", - "input_value", - "search_params", - "max_results", - "max_snippet_length" - ], - "frozen": false, - "icon": "SearchAPI", - "legacy": true, - "metadata": {}, - "minimized": false, - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Data", - "method": "run_model", - "name": "api_run_model", - "required_inputs": [ - "api_key" - ], - "selected": "Data", - "types": [ - "Data" - ], - "value": "__UNDEFINED__" - }, - { - "cache": true, - "display_name": "Tool", - "method": "build_tool", - "name": "api_build_tool", - "required_inputs": [ - "api_key" - ], - "selected": "Tool", - "types": [ - "Tool" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "SearchAPI API Key", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "load_from_db": false, - "name": "api_key", - "password": true, - "placeholder": "", - "required": true, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "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 typing import Any\n\nfrom langchain.tools import StructuredTool\nfrom langchain_community.utilities.searchapi import SearchApiAPIWrapper\nfrom pydantic import BaseModel, Field\n\nfrom langflow.base.langchain_utilities.model import LCToolComponent\nfrom langflow.field_typing import Tool\nfrom langflow.inputs import DictInput, IntInput, MessageTextInput, MultilineInput, SecretStrInput\nfrom langflow.schema import Data\n\n\nclass SearchAPIComponent(LCToolComponent):\n display_name: str = \"Search API [DEPRECATED]\"\n description: str = \"Call the searchapi.io API with result limiting\"\n name = \"SearchAPI\"\n documentation: str = \"https://www.searchapi.io/docs/google\"\n icon = \"SearchAPI\"\n legacy = True\n\n inputs = [\n MessageTextInput(name=\"engine\", display_name=\"Engine\", value=\"google\"),\n SecretStrInput(name=\"api_key\", display_name=\"SearchAPI API Key\", required=True),\n MultilineInput(\n name=\"input_value\",\n display_name=\"Input\",\n ),\n DictInput(name=\"search_params\", display_name=\"Search parameters\", advanced=True, is_list=True),\n IntInput(name=\"max_results\", display_name=\"Max Results\", value=5, advanced=True),\n IntInput(name=\"max_snippet_length\", display_name=\"Max Snippet Length\", value=100, advanced=True),\n ]\n\n class SearchAPISchema(BaseModel):\n query: str = Field(..., description=\"The search query\")\n params: dict[str, Any] = Field(default_factory=dict, description=\"Additional search parameters\")\n max_results: int = Field(5, description=\"Maximum number of results to return\")\n max_snippet_length: int = Field(100, description=\"Maximum length of each result snippet\")\n\n def _build_wrapper(self):\n return SearchApiAPIWrapper(engine=self.engine, searchapi_api_key=self.api_key)\n\n def build_tool(self) -> Tool:\n wrapper = self._build_wrapper()\n\n def search_func(\n query: str, params: dict[str, Any] | None = None, max_results: int = 5, max_snippet_length: int = 100\n ) -> list[dict[str, Any]]:\n params = params or {}\n full_results = wrapper.results(query=query, **params)\n organic_results = full_results.get(\"organic_results\", [])[:max_results]\n\n limited_results = []\n for result in organic_results:\n limited_result = {\n \"title\": result.get(\"title\", \"\")[:max_snippet_length],\n \"link\": result.get(\"link\", \"\"),\n \"snippet\": result.get(\"snippet\", \"\")[:max_snippet_length],\n }\n limited_results.append(limited_result)\n\n return limited_results\n\n tool = StructuredTool.from_function(\n name=\"search_api\",\n description=\"Search for recent results using searchapi.io with result limiting\",\n func=search_func,\n args_schema=self.SearchAPISchema,\n )\n\n self.status = f\"Search API Tool created with engine: {self.engine}\"\n return tool\n\n def run_model(self) -> list[Data]:\n tool = self.build_tool()\n results = tool.run(\n {\n \"query\": self.input_value,\n \"params\": self.search_params or {},\n \"max_results\": self.max_results,\n \"max_snippet_length\": self.max_snippet_length,\n }\n )\n\n data_list = [Data(data=result, text=result.get(\"snippet\", \"\")) for result in results]\n\n self.status = data_list\n return data_list\n" - }, - "engine": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "Engine", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "list_add_label": "Add More", - "load_from_db": false, - "name": "engine", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "google" - }, - "input_value": { - "_input_type": "MultilineInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "list_add_label": "Add More", - "load_from_db": false, - "multiline": true, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "langflow docs" - }, - "max_results": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Results", - "dynamic": false, - "info": "", - "list": false, - "list_add_label": "Add More", - "name": "max_results", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "int", - "value": 5 - }, - "max_snippet_length": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Snippet Length", - "dynamic": false, - "info": "", - "list": false, - "list_add_label": "Add More", - "name": "max_snippet_length", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "int", - "value": 100 - }, - "search_params": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Search parameters", - "dynamic": false, - "info": "", - "list": true, - "list_add_label": "Add More", - "name": "search_params", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "type": "dict", - "value": {} - } - }, - "tool_mode": false - }, - "type": "SearchAPI" - }, - "dragging": false, - "height": 509, - "id": "SearchAPI-KMYDO", - "measured": { - "height": 509, - "width": 320 - }, - "position": { - "x": 2101.519951743063, - "y": 949.7032293566349 - }, - "positionAbsolute": { - "x": 2101.519951743063, - "y": 949.7032293566349 - }, - "selected": false, - "type": "genericNode", - "width": 360 - }, - { - "data": { - "id": "url_content_fetcher-vZFfk", - "node": { - "base_classes": [ - "Data", - "list", - "Tool" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Fetch content from a single URL.", - "display_name": "URL Content Fetcher", - "documentation": "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/web_base", - "edited": true, - "field_order": [ - "url", - "fetch_params" - ], - "frozen": false, - "icon": "globe", - "lf_version": "1.0.19.post2", - "official": false, - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Data", - "hidden": true, - "method": "run_model", - "name": "api_run_model", - "selected": "Data", - "types": [ - "Data", - "list" - ], - "value": "__UNDEFINED__" - }, - { - "cache": true, - "display_name": "Tool", - "method": "build_tool", - "name": "api_build_tool", - "selected": "Tool", - "types": [ - "Tool" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "code": { - "advanced": true, - "dynamic": true, - "fileTypes": [], - "file_path": "", - "info": "", - "list": false, - "load_from_db": false, - "multiline": true, - "name": "code", - "password": false, - "placeholder": "", - "required": true, - "show": true, - "title_case": false, - "type": "code", - "value": "from typing import Union, Optional\r\nfrom langchain_community.document_loaders.web_base import WebBaseLoader\r\nfrom langflow.base.langchain_utilities.model import LCToolComponent\r\nfrom langflow.inputs import MessageTextInput, DictInput\r\nfrom langflow.schema import Data\r\nfrom langflow.field_typing import Tool\r\nfrom langchain.tools import StructuredTool\r\nfrom pydantic import BaseModel, Field\r\n\r\nclass URLToolComponent(LCToolComponent):\r\n display_name: str = \"URL Content Fetcher\"\r\n description: str = \"Fetch content from a single URL.\"\r\n name = \"url_content_fetcher\"\r\n documentation: str = \"https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/web_base\"\r\n icon=\"globe\"\r\n \r\n inputs = [\r\n MessageTextInput(\r\n name=\"url\",\r\n display_name=\"URL\",\r\n info=\"Enter a single URL to fetch content from.\",\r\n ),\r\n DictInput(name=\"fetch_params\", display_name=\"Fetch parameters\", advanced=True, is_list=True),\r\n ]\r\n\r\n class URLContentFetcherSchema(BaseModel):\r\n url: str = Field(..., description=\"The URL to fetch content from\")\r\n fetch_params: Optional[dict] = Field(default=None, description=\"Additional parameters for fetching\")\r\n\r\n def run_model(self) -> Union[Data, list[Data]]:\r\n wrapper = self._build_wrapper()\r\n content = wrapper.load()[0]\r\n data = Data(data={\"content\": content.page_content, \"metadata\": content.metadata}, \r\n text=content.page_content[:500])\r\n self.status = data\r\n return data\r\n\r\n def build_tool(self) -> Tool:\r\n return StructuredTool.from_function(\r\n name=\"url_content_fetcher\",\r\n description=\"Fetch content from a single URL. Input should be a URL string only.\",\r\n func=self._fetch_url_content,\r\n args_schema=self.URLContentFetcherSchema,\r\n )\r\n\r\n def _build_wrapper(self):\r\n return WebBaseLoader(web_paths=[self.url], encoding=\"utf-8\", **self.fetch_params or {})\r\n\r\n def _fetch_url_content(self, url: str, fetch_params: Optional[dict] = None) -> dict:\r\n loader = WebBaseLoader(web_paths=[url], encoding=\"utf-8\", **(fetch_params or {}))\r\n content = loader.load()[0]\r\n return {\r\n \"content\": content.page_content,\r\n \"metadata\": content.metadata\r\n }" - }, - "fetch_params": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Fetch parameters", - "dynamic": false, - "info": "", - "list": true, - "name": "fetch_params", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "url": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "URL", - "dynamic": false, - "info": "Enter a single URL to fetch content from.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "url", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - } - } - }, - "type": "url_content_fetcher" - }, - "dragging": false, - "height": 262, - "id": "url_content_fetcher-vZFfk", - "measured": { - "height": 262, - "width": 320 - }, - "position": { - "x": 2834.525991812012, - "y": 939.6518333549263 - }, - "positionAbsolute": { - "x": 2834.525991812012, - "y": 939.6518333549263 - }, - "selected": false, - "type": "genericNode", - "width": 360 - }, - { - "data": { - "description": "Perform basic arithmetic operations on a given expression.", - "display_name": "Calculator [DEPRECATED]", - "id": "CalculatorTool-LJZFv", - "node": { - "base_classes": [ - "Data", - "Tool" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Perform basic arithmetic operations on a given expression.", - "display_name": "Calculator [DEPRECATED]", - "documentation": "", - "edited": false, - "field_order": [ - "expression" - ], - "frozen": false, - "icon": "calculator", - "legacy": true, - "metadata": {}, - "minimized": false, - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Data", - "method": "run_model", - "name": "api_run_model", - "required_inputs": [], - "selected": "Data", - "types": [ - "Data" - ], - "value": "__UNDEFINED__" - }, - { - "cache": true, - "display_name": "Tool", - "method": "build_tool", - "name": "api_build_tool", - "required_inputs": [], - "selected": "Tool", - "types": [ - "Tool" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "code": { - "advanced": true, - "dynamic": true, - "fileTypes": [], - "file_path": "", - "info": "", - "list": false, - "load_from_db": false, - "multiline": true, - "name": "code", - "password": false, - "placeholder": "", - "required": true, - "show": true, - "title_case": false, - "type": "code", - "value": "import ast\nimport operator\n\nfrom langchain.tools import StructuredTool\nfrom langchain_core.tools import ToolException\nfrom loguru import logger\nfrom pydantic import BaseModel, Field\n\nfrom langflow.base.langchain_utilities.model import LCToolComponent\nfrom langflow.field_typing import Tool\nfrom langflow.inputs import MessageTextInput\nfrom langflow.schema import Data\n\n\nclass CalculatorToolComponent(LCToolComponent):\n display_name = \"Calculator [DEPRECATED]\"\n description = \"Perform basic arithmetic operations on a given expression.\"\n icon = \"calculator\"\n name = \"CalculatorTool\"\n legacy = True\n\n inputs = [\n MessageTextInput(\n name=\"expression\",\n display_name=\"Expression\",\n info=\"The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').\",\n ),\n ]\n\n class CalculatorToolSchema(BaseModel):\n expression: str = Field(..., description=\"The arithmetic expression to evaluate.\")\n\n def run_model(self) -> list[Data]:\n return self._evaluate_expression(self.expression)\n\n def build_tool(self) -> Tool:\n return StructuredTool.from_function(\n name=\"calculator\",\n description=\"Evaluate basic arithmetic expressions. Input should be a string containing the expression.\",\n func=self._eval_expr_with_error,\n args_schema=self.CalculatorToolSchema,\n )\n\n def _eval_expr(self, node):\n if isinstance(node, ast.Num):\n return node.n\n if isinstance(node, ast.BinOp):\n left_val = self._eval_expr(node.left)\n right_val = self._eval_expr(node.right)\n return self.operators[type(node.op)](left_val, right_val)\n if isinstance(node, ast.UnaryOp):\n operand_val = self._eval_expr(node.operand)\n return self.operators[type(node.op)](operand_val)\n if isinstance(node, ast.Call):\n msg = (\n \"Function calls like sqrt(), sin(), cos() etc. are not supported. \"\n \"Only basic arithmetic operations (+, -, *, /, **) are allowed.\"\n )\n raise TypeError(msg)\n msg = f\"Unsupported operation or expression type: {type(node).__name__}\"\n raise TypeError(msg)\n\n def _eval_expr_with_error(self, expression: str) -> list[Data]:\n try:\n return self._evaluate_expression(expression)\n except Exception as e:\n raise ToolException(str(e)) from e\n\n def _evaluate_expression(self, expression: str) -> list[Data]:\n try:\n # Parse the expression and evaluate it\n tree = ast.parse(expression, mode=\"eval\")\n result = self._eval_expr(tree.body)\n\n # Format the result to a reasonable number of decimal places\n formatted_result = f\"{result:.6f}\".rstrip(\"0\").rstrip(\".\")\n\n self.status = formatted_result\n return [Data(data={\"result\": formatted_result})]\n\n except (SyntaxError, TypeError, KeyError) as e:\n error_message = f\"Invalid expression: {e}\"\n self.status = error_message\n return [Data(data={\"error\": error_message, \"input\": expression})]\n except ZeroDivisionError:\n error_message = \"Error: Division by zero\"\n self.status = error_message\n return [Data(data={\"error\": error_message, \"input\": expression})]\n except Exception as e: # noqa: BLE001\n logger.opt(exception=True).debug(\"Error evaluating expression\")\n error_message = f\"Error: {e}\"\n self.status = error_message\n return [Data(data={\"error\": error_message, \"input\": expression})]\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.operators = {\n ast.Add: operator.add,\n ast.Sub: operator.sub,\n ast.Mult: operator.mul,\n ast.Div: operator.truediv,\n ast.Pow: operator.pow,\n }\n" - }, - "expression": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "Expression", - "dynamic": false, - "info": "The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').", - "input_types": [ - "Message" - ], - "list": false, - "list_add_label": "Add More", - "load_from_db": false, - "name": "expression", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "2+2" - } - }, - "tool_mode": false - }, - "type": "CalculatorTool" - }, - "dragging": false, - "height": 338, - "id": "CalculatorTool-LJZFv", - "measured": { - "height": 338, - "width": 320 - }, - "position": { - "x": 3546.599894399727, - "y": 972.1522299506486 - }, - "positionAbsolute": { - "x": 3546.599894399727, - "y": 972.1522299506486 - }, - "selected": true, - "type": "genericNode", - "width": 360 - }, { "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "City Selection Agent", - "id": "Agent-ZZ1QV", + "id": "Agent-Bsq4j", "node": { "base_classes": [ "Message" @@ -1288,7 +810,7 @@ "frozen": false, "icon": "bot", "legacy": false, - "lf_version": "1.0.19.post2", + "lf_version": "1.1.1", "metadata": {}, "output_types": [], "outputs": [ @@ -1385,7 +907,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -1393,7 +915,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -1806,10 +1328,10 @@ }, "dragging": true, "height": 725, - "id": "Agent-ZZ1QV", + "id": "Agent-Bsq4j", "measured": { "height": 725, - "width": 320 + "width": 360 }, "position": { "x": 2472.7748760933105, @@ -1827,7 +1349,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Local Expert Agent", - "id": "Agent-ArtN4", + "id": "Agent-xeg6y", "node": { "base_classes": [ "Message" @@ -1870,7 +1392,7 @@ "frozen": false, "icon": "bot", "legacy": false, - "lf_version": "1.0.19.post2", + "lf_version": "1.1.1", "metadata": {}, "output_types": [], "outputs": [ @@ -1967,7 +1489,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -1975,7 +1497,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -2388,10 +1910,10 @@ }, "dragging": false, "height": 725, - "id": "Agent-ArtN4", + "id": "Agent-xeg6y", "measured": { "height": 725, - "width": 320 + "width": 360 }, "position": { "x": 3185.66991544494, @@ -2409,7 +1931,7 @@ "data": { "description": "Define the agent's instructions, then enter a task to complete using tools.", "display_name": "Travel Concierge Agent", - "id": "Agent-AiQA7", + "id": "Agent-txo0a", "node": { "base_classes": [ "Message" @@ -2452,7 +1974,7 @@ "frozen": false, "icon": "bot", "legacy": false, - "lf_version": "1.0.19.post2", + "lf_version": "1.1.1", "metadata": {}, "output_types": [], "outputs": [ @@ -2549,7 +2071,7 @@ "input_types": [ "Message" ], - "load_from_db": false, + "load_from_db": true, "name": "api_key", "password": true, "placeholder": "", @@ -2557,7 +2079,7 @@ "show": true, "title_case": false, "type": "str", - "value": "" + "value": "OPENAI_API_KEY" }, "code": { "advanced": true, @@ -2970,10 +2492,10 @@ }, "dragging": false, "height": 725, - "id": "Agent-AiQA7", + "id": "Agent-txo0a", "measured": { "height": 725, - "width": 320 + "width": 360 }, "position": { "x": 3889.695953842898, @@ -2989,7 +2511,7 @@ }, { "data": { - "id": "note-K6vDt", + "id": "note-5Rl5S", "node": { "description": "# Travel Planning Agents \n\nThe travel planning system is a smart setup that uses several specialized \"agents\" to help plan incredible trips. Imagine each agent as a travel expert focusing on a part of your journey. Here's how it works:\n\n- **User-Friendly Start:** You start by telling the system about your travel needs—where you want to go and what you love to do.\n\n- **Data Collection:** The agents uses its tools to gather current info about various destinations, like the best travel times, weather, and costs.\n\n- **Three Key Agents:**\n - **City Selection Agent:** Picks the best places to visit based on your likes and current data.\n - **Local Expert Agent:** Gathers interesting details about what to do and see in the chosen city.\n - **Travel Concierge Agent:** Builds a day-by-day plan that includes where to stay, eat, and explore!\n\n- **Tools and Data:** Each agent uses tools to find and organize the latest information so you get recommendations that are both accurate and exciting.\n\n- **Final Plan:** Once everything is put together, you receive a complete, easy-to-follow travel itinerary, perfect for your adventure!\n", "display_name": "", @@ -3000,10 +2522,10 @@ }, "dragging": false, "height": 636, - "id": "note-K6vDt", + "id": "note-5Rl5S", "measured": { "height": 636, - "width": 325 + "width": 328 }, "position": { "x": 1076.3710803600266, @@ -3024,7 +2546,7 @@ }, { "data": { - "id": "note-kj8YE", + "id": "note-mOX7K", "node": { "description": "# **City Selection Agent**\n - **Purpose:** This agent evaluates potential travel destinations based on user input and external data sources.\n - **Core Functions:** Analyzes factors such as weather, local events, and travel costs to recommend optimal cities.\n - **Tools Utilized:** Employs APIs and data-fetching tools to gather real-time information for decision-making.\n", "display_name": "", @@ -3037,10 +2559,10 @@ }, "dragging": false, "height": 362, - "id": "note-kj8YE", + "id": "note-mOX7K", "measured": { "height": 362, - "width": 325 + "width": 328 }, "position": { "x": 2122.4146132377227, @@ -3061,7 +2583,7 @@ }, { "data": { - "id": "note-523ch", + "id": "note-q4oVX", "node": { "description": "# **Local Expert Agent**\n - **Purpose:** Focused on gathering and providing an in-depth guide to the selected city.\n - **Core Functions:** Compiles insights into cultural attractions, local customs, and unique experiences.\n - **Tools Utilized:** Uses web content fetchers and data APIs to collect detailed local insights and enhance the user understanding with hidden gems.\n", "display_name": "", @@ -3074,10 +2596,10 @@ }, "dragging": false, "height": 366, - "id": "note-523ch", + "id": "note-q4oVX", "measured": { "height": 366, - "width": 325 + "width": 328 }, "position": { "x": 2827.660803823376, @@ -3098,7 +2620,7 @@ }, { "data": { - "id": "note-6RsAX", + "id": "note-uhNHM", "node": { "description": "# **Travel Concierge Agent**\n - **Purpose:** Crafts detailed travel itineraries that are customized to the traveler's interests and needs.\n - **Core Functions:** Offers a comprehensive daily schedule, including accommodations, dining spots, and activities.\n - **Tools Utilized:** Integrates calculators and data tools for accurate budget planning and itinerary logistics.", "display_name": "", @@ -3111,10 +2633,10 @@ }, "dragging": false, "height": 344, - "id": "note-6RsAX", + "id": "note-uhNHM", "measured": { "height": 344, - "width": 325 + "width": 328 }, "position": { "x": 3536.084279543714, @@ -3135,7 +2657,7 @@ }, { "data": { - "id": "note-KT4sJ", + "id": "note-XHn2w", "node": { "description": "## Configure the agent by obtaining your OpenAI API key from [platform.openai.com](https://platform.openai.com). Under \"Model Provider\", choose:\n- OpenAI: Default, requires only API key\n- Anthropic/Azure/Groq/NVIDIA: Each requires their own API keys\n- Custom: Use your own model endpoint + authentication\n\nSelect model and input API key before running the flow.", "display_name": "", @@ -3148,10 +2670,10 @@ }, "dragging": false, "height": 328, - "id": "note-KT4sJ", + "id": "note-XHn2w", "measured": { "height": 328, - "width": 325 + "width": 328 }, "position": { "x": 2463.3881993480218, @@ -3164,12 +2686,736 @@ "selected": false, "type": "noteNode", "width": 328 + }, + { + "data": { + "id": "URL-VCoZD", + "node": { + "base_classes": [ + "Data", + "DataFrame", + "Message" + ], + "beta": false, + "category": "data", + "conditional_paths": [], + "custom_fields": {}, + "description": "Load and retrive data from specified URLs.", + "display_name": "URL", + "documentation": "", + "edited": false, + "field_order": [ + "urls", + "format" + ], + "frozen": false, + "icon": "layout-template", + "key": "URL", + "legacy": false, + "lf_version": "1.1.1", + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Toolset", + "hidden": null, + "method": "to_toolkit", + "name": "component_as_tool", + "required_inputs": null, + "selected": "Tool", + "types": [ + "Tool" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 2.220446049250313e-16, + "template": { + "_type": "Component", + "code": { + "advanced": true, + "dynamic": true, + "fileTypes": [], + "file_path": "", + "info": "", + "list": false, + "load_from_db": false, + "multiline": true, + "name": "code", + "password": false, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "code", + "value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.dataframe import DataFrame\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Load and retrive data from specified URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n is_list=True,\n tool_mode=True,\n placeholder=\"Enter a URL...\",\n list_add_label=\"Add URL\",\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Message\", name=\"text\", method=\"fetch_content_text\"),\n Output(display_name=\"DataFrame\", name=\"dataframe\", method=\"as_dataframe\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n\n def as_dataframe(self) -> DataFrame:\n return DataFrame(self.fetch_content())\n" + }, + "format": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Output Format", + "dynamic": false, + "info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.", + "name": "format", + "options": [ + "Text", + "Raw HTML" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "Text" + }, + "tools_metadata": { + "_input_type": "TableInput", + "advanced": false, + "display_name": "Edit tools", + "dynamic": false, + "info": "", + "is_list": true, + "list_add_label": "Add More", + "name": "tools_metadata", + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "table_icon": "Hammer", + "table_options": { + "block_add": true, + "block_delete": true, + "block_edit": true, + "block_filter": true, + "block_hide": true, + "block_select": true, + "block_sort": true, + "description": "Modify tool names and descriptions to help agents understand when to use each tool.", + "field_parsers": { + "commands": "commands", + "name": [ + "snake_case", + "no_blank" + ] + }, + "hide_options": true + }, + "table_schema": { + "columns": [ + { + "description": "Specify the name of the tool.", + "disable_edit": false, + "display_name": "Tool Name", + "edit_mode": "inline", + "filterable": false, + "formatter": "text", + "name": "name", + "sortable": false, + "type": "text" + }, + { + "description": "Describe the purpose of the tool.", + "disable_edit": false, + "display_name": "Tool Description", + "edit_mode": "popover", + "filterable": false, + "formatter": "text", + "name": "description", + "sortable": false, + "type": "text" + }, + { + "description": "The default identifiers for the tools and cannot be changed.", + "disable_edit": true, + "display_name": "Tool Identifiers", + "edit_mode": "inline", + "filterable": false, + "formatter": "text", + "name": "tags", + "sortable": false, + "type": "text" + } + ] + }, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "trigger_icon": "Hammer", + "trigger_text": "", + "type": "table", + "value": [ + { + "description": "fetch_content() - Load and retrive data from specified URLs.", + "name": "URL-fetch_content", + "tags": [ + "URL-fetch_content" + ] + }, + { + "description": "fetch_content_text() - Load and retrive data from specified URLs.", + "name": "URL-fetch_content_text", + "tags": [ + "URL-fetch_content_text" + ] + }, + { + "description": "as_dataframe() - Load and retrive data from specified URLs.", + "name": "URL-as_dataframe", + "tags": [ + "URL-as_dataframe" + ] + } + ] + }, + "urls": { + "_input_type": "MessageTextInput", + "advanced": false, + "display_name": "URLs", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": true, + "list_add_label": "Add URL", + "load_from_db": false, + "name": "urls", + "placeholder": "Enter a URL...", + "required": false, + "show": true, + "title_case": false, + "tool_mode": true, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + } + }, + "tool_mode": true + }, + "showNode": true, + "type": "URL" + }, + "dragging": false, + "id": "URL-VCoZD", + "measured": { + "height": 453, + "width": 360 + }, + "position": { + "x": 2829.4526852839367, + "y": 956.7694697088367 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "CalculatorComponent-pSb5r", + "node": { + "base_classes": [ + "Data" + ], + "beta": false, + "category": "tools", + "conditional_paths": [], + "custom_fields": {}, + "description": "Perform basic arithmetic operations on a given expression.", + "display_name": "Calculator", + "documentation": "", + "edited": false, + "field_order": [ + "expression" + ], + "frozen": false, + "icon": "calculator", + "key": "CalculatorComponent", + "legacy": false, + "lf_version": "1.1.1", + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Toolset", + "hidden": null, + "method": "to_toolkit", + "name": "component_as_tool", + "required_inputs": null, + "selected": "Tool", + "types": [ + "Tool" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.001, + "template": { + "_type": "Component", + "code": { + "advanced": true, + "dynamic": true, + "fileTypes": [], + "file_path": "", + "info": "", + "list": false, + "load_from_db": false, + "multiline": true, + "name": "code", + "password": false, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "code", + "value": "import ast\nimport operator\nfrom collections.abc import Callable\n\nfrom langflow.custom import Component\nfrom langflow.inputs import MessageTextInput\nfrom langflow.io import Output\nfrom langflow.schema import Data\n\n\nclass CalculatorComponent(Component):\n display_name = \"Calculator\"\n description = \"Perform basic arithmetic operations on a given expression.\"\n icon = \"calculator\"\n\n # Cache operators dictionary as a class variable\n OPERATORS: dict[type[ast.operator], Callable] = {\n ast.Add: operator.add,\n ast.Sub: operator.sub,\n ast.Mult: operator.mul,\n ast.Div: operator.truediv,\n ast.Pow: operator.pow,\n }\n\n inputs = [\n MessageTextInput(\n name=\"expression\",\n display_name=\"Expression\",\n info=\"The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').\",\n tool_mode=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"result\", type_=Data, method=\"evaluate_expression\"),\n ]\n\n def _eval_expr(self, node: ast.AST) -> float:\n \"\"\"Evaluate an AST node recursively.\"\"\"\n if isinstance(node, ast.Constant):\n if isinstance(node.value, int | float):\n return float(node.value)\n error_msg = f\"Unsupported constant type: {type(node.value).__name__}\"\n raise TypeError(error_msg)\n if isinstance(node, ast.Num): # For backwards compatibility\n if isinstance(node.n, int | float):\n return float(node.n)\n error_msg = f\"Unsupported number type: {type(node.n).__name__}\"\n raise TypeError(error_msg)\n\n if isinstance(node, ast.BinOp):\n op_type = type(node.op)\n if op_type not in self.OPERATORS:\n error_msg = f\"Unsupported binary operator: {op_type.__name__}\"\n raise TypeError(error_msg)\n\n left = self._eval_expr(node.left)\n right = self._eval_expr(node.right)\n return self.OPERATORS[op_type](left, right)\n\n error_msg = f\"Unsupported operation or expression type: {type(node).__name__}\"\n raise TypeError(error_msg)\n\n def evaluate_expression(self) -> Data:\n \"\"\"Evaluate the mathematical expression and return the result.\"\"\"\n try:\n tree = ast.parse(self.expression, mode=\"eval\")\n result = self._eval_expr(tree.body)\n\n formatted_result = f\"{float(result):.6f}\".rstrip(\"0\").rstrip(\".\")\n self.log(f\"Calculation result: {formatted_result}\")\n\n self.status = formatted_result\n return Data(data={\"result\": formatted_result})\n\n except ZeroDivisionError:\n error_message = \"Error: Division by zero\"\n self.status = error_message\n return Data(data={\"error\": error_message, \"input\": self.expression})\n\n except (SyntaxError, TypeError, KeyError, ValueError, AttributeError, OverflowError) as e:\n error_message = f\"Invalid expression: {e!s}\"\n self.status = error_message\n return Data(data={\"error\": error_message, \"input\": self.expression})\n\n def build(self):\n \"\"\"Return the main evaluation function.\"\"\"\n return self.evaluate_expression\n" + }, + "expression": { + "_input_type": "MessageTextInput", + "advanced": false, + "display_name": "Expression", + "dynamic": false, + "info": "The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "expression", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": true, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "tools_metadata": { + "_input_type": "TableInput", + "advanced": false, + "display_name": "Edit tools", + "dynamic": false, + "info": "", + "is_list": true, + "list_add_label": "Add More", + "name": "tools_metadata", + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "table_icon": "Hammer", + "table_options": { + "block_add": true, + "block_delete": true, + "block_edit": true, + "block_filter": true, + "block_hide": true, + "block_select": true, + "block_sort": true, + "description": "Modify tool names and descriptions to help agents understand when to use each tool.", + "field_parsers": { + "commands": "commands", + "name": [ + "snake_case", + "no_blank" + ] + }, + "hide_options": true + }, + "table_schema": { + "columns": [ + { + "description": "Specify the name of the tool.", + "disable_edit": false, + "display_name": "Tool Name", + "edit_mode": "inline", + "filterable": false, + "formatter": "text", + "name": "name", + "sortable": false, + "type": "text" + }, + { + "description": "Describe the purpose of the tool.", + "disable_edit": false, + "display_name": "Tool Description", + "edit_mode": "popover", + "filterable": false, + "formatter": "text", + "name": "description", + "sortable": false, + "type": "text" + }, + { + "description": "The default identifiers for the tools and cannot be changed.", + "disable_edit": true, + "display_name": "Tool Identifiers", + "edit_mode": "inline", + "filterable": false, + "formatter": "text", + "name": "tags", + "sortable": false, + "type": "text" + } + ] + }, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "trigger_icon": "Hammer", + "trigger_text": "", + "type": "table", + "value": [ + { + "description": "evaluate_expression() - Perform basic arithmetic operations on a given expression.", + "name": "CalculatorComponent-evaluate_expression", + "tags": [ + "CalculatorComponent-evaluate_expression" + ] + } + ] + } + }, + "tool_mode": true + }, + "showNode": true, + "type": "CalculatorComponent" + }, + "dragging": false, + "id": "CalculatorComponent-pSb5r", + "measured": { + "height": 374, + "width": 360 + }, + "position": { + "x": 3540.356346381247, + "y": 989.3563951826354 + }, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "SearchComponent-BSabY", + "node": { + "base_classes": [ + "Data", + "Message" + ], + "beta": false, + "category": "tools", + "conditional_paths": [], + "custom_fields": {}, + "description": "Call the searchapi.io API with result limiting", + "display_name": "Search API", + "documentation": "https://www.searchapi.io/docs/google", + "edited": false, + "field_order": [ + "engine", + "api_key", + "input_value", + "search_params", + "max_results", + "max_snippet_length" + ], + "frozen": false, + "icon": "SearchAPI", + "key": "SearchComponent", + "legacy": false, + "lf_version": "1.1.1", + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Toolset", + "hidden": null, + "method": "to_toolkit", + "name": "component_as_tool", + "required_inputs": null, + "selected": "Tool", + "types": [ + "Tool" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.0030458160338519237, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "SearchAPI API Key", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": true, + "show": true, + "title_case": false, + "type": "str", + "value": "" + }, + "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 typing import Any\n\nfrom langchain_community.utilities.searchapi import SearchApiAPIWrapper\n\nfrom langflow.custom import Component\nfrom langflow.inputs import DictInput, DropdownInput, IntInput, MultilineInput, SecretStrInput\nfrom langflow.io import Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass SearchComponent(Component):\n display_name: str = \"Search API\"\n description: str = \"Call the searchapi.io API with result limiting\"\n documentation: str = \"https://www.searchapi.io/docs/google\"\n icon = \"SearchAPI\"\n\n inputs = [\n DropdownInput(name=\"engine\", display_name=\"Engine\", value=\"google\", options=[\"google\", \"bing\", \"duckduckgo\"]),\n SecretStrInput(name=\"api_key\", display_name=\"SearchAPI API Key\", required=True),\n MultilineInput(\n name=\"input_value\",\n display_name=\"Input\",\n tool_mode=True,\n ),\n DictInput(name=\"search_params\", display_name=\"Search parameters\", advanced=True, is_list=True),\n IntInput(name=\"max_results\", display_name=\"Max Results\", value=5, advanced=True),\n IntInput(name=\"max_snippet_length\", display_name=\"Max Snippet Length\", value=100, advanced=True),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def _build_wrapper(self):\n return SearchApiAPIWrapper(engine=self.engine, searchapi_api_key=self.api_key)\n\n def run_model(self) -> list[Data]:\n return self.fetch_content()\n\n def fetch_content(self) -> list[Data]:\n wrapper = self._build_wrapper()\n\n def search_func(\n query: str, params: dict[str, Any] | None = None, max_results: int = 5, max_snippet_length: int = 100\n ) -> list[Data]:\n params = params or {}\n full_results = wrapper.results(query=query, **params)\n organic_results = full_results.get(\"organic_results\", [])[:max_results]\n\n return [\n Data(\n text=result.get(\"snippet\", \"\"),\n data={\n \"title\": result.get(\"title\", \"\")[:max_snippet_length],\n \"link\": result.get(\"link\", \"\"),\n \"snippet\": result.get(\"snippet\", \"\")[:max_snippet_length],\n },\n )\n for result in organic_results\n ]\n\n results = search_func(\n self.input_value,\n self.search_params or {},\n self.max_results,\n self.max_snippet_length,\n )\n self.status = results\n return results\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n result_string = \"\"\n for item in data:\n result_string += item.text + \"\\n\"\n self.status = result_string\n return Message(text=result_string)\n" + }, + "engine": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Engine", + "dynamic": false, + "info": "", + "name": "engine", + "options": [ + "google", + "bing", + "duckduckgo" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "google" + }, + "input_value": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": true, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "max_results": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Results", + "dynamic": false, + "info": "", + "list": false, + "list_add_label": "Add More", + "name": "max_results", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 5 + }, + "max_snippet_length": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Snippet Length", + "dynamic": false, + "info": "", + "list": false, + "list_add_label": "Add More", + "name": "max_snippet_length", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 100 + }, + "search_params": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Search parameters", + "dynamic": false, + "info": "", + "list": true, + "list_add_label": "Add More", + "name": "search_params", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "tools_metadata": { + "_input_type": "TableInput", + "advanced": false, + "display_name": "Edit tools", + "dynamic": false, + "info": "", + "is_list": true, + "list_add_label": "Add More", + "name": "tools_metadata", + "placeholder": "", + "real_time_refresh": true, + "required": false, + "show": true, + "table_icon": "Hammer", + "table_options": { + "block_add": true, + "block_delete": true, + "block_edit": true, + "block_filter": true, + "block_hide": true, + "block_select": true, + "block_sort": true, + "description": "Modify tool names and descriptions to help agents understand when to use each tool.", + "field_parsers": { + "commands": "commands", + "name": [ + "snake_case", + "no_blank" + ] + }, + "hide_options": true + }, + "table_schema": { + "columns": [ + { + "description": "Specify the name of the tool.", + "disable_edit": false, + "display_name": "Tool Name", + "edit_mode": "inline", + "filterable": false, + "formatter": "text", + "name": "name", + "sortable": false, + "type": "text" + }, + { + "description": "Describe the purpose of the tool.", + "disable_edit": false, + "display_name": "Tool Description", + "edit_mode": "popover", + "filterable": false, + "formatter": "text", + "name": "description", + "sortable": false, + "type": "text" + }, + { + "description": "The default identifiers for the tools and cannot be changed.", + "disable_edit": true, + "display_name": "Tool Identifiers", + "edit_mode": "inline", + "filterable": false, + "formatter": "text", + "name": "tags", + "sortable": false, + "type": "text" + } + ] + }, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "trigger_icon": "Hammer", + "trigger_text": "", + "type": "table", + "value": [ + { + "description": "fetch_content(api_key: Message) - Call the searchapi.io API with result limiting", + "name": "SearchComponent-fetch_content", + "tags": [ + "SearchComponent-fetch_content" + ] + }, + { + "description": "fetch_content_text(api_key: Message) - Call the searchapi.io API with result limiting", + "name": "SearchComponent-fetch_content_text", + "tags": [ + "SearchComponent-fetch_content_text" + ] + } + ] + } + }, + "tool_mode": true + }, + "showNode": true, + "type": "SearchComponent" + }, + "dragging": false, + "id": "SearchComponent-BSabY", + "measured": { + "height": 536, + "width": 360 + }, + "position": { + "x": 2089.0393126914205, + "y": 864.3967489854795 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -1847.2791353675912, - "y": -230.9870437908569, - "zoom": 0.7659453992379711 + "x": -725.9163351506193, + "y": 43.25864447430234, + "zoom": 0.4743305032399001 } }, "description": "Create a travel planning chatbot that uses specialized agents to craft personalized trip itineraries.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json b/src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json index 2abfe0bf3..cff8b6224 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json @@ -1,41 +1,13 @@ { "data": { "edges": [ - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-t1to9", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-n8Wmg", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-t1to9{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-t1to9œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-n8Wmg{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-n8Wmgœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "selected": false, - "source": "OpenAIModel-t1to9", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-t1to9œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-n8Wmg", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-n8Wmgœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, { "animated": false, "className": "", "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-0yHbX", + "id": "TextInput-Bg8zz", "name": "text", "output_types": [ "Message" @@ -43,7 +15,7 @@ }, "targetHandle": { "fieldName": "CONTENT_GUIDELINES", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "inputTypes": [ "Message", "Text" @@ -51,11 +23,11 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-0yHbX{œdataTypeœ:œTextInputœ,œidœ:œTextInput-0yHbXœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-nDs5I{œfieldNameœ:œCONTENT_GUIDELINESœ,œidœ:œPrompt-nDs5Iœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-0yHbX", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-0yHbXœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-nDs5I", - "targetHandle": "{œfieldNameœ: œCONTENT_GUIDELINESœ, œidœ: œPrompt-nDs5Iœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-Bg8zz{œdataTypeœ:œTextInputœ,œidœ:œTextInput-Bg8zzœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-atb3f{œfieldNameœ:œCONTENT_GUIDELINESœ,œidœ:œPrompt-atb3fœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-Bg8zz", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-Bg8zzœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-atb3f", + "targetHandle": "{œfieldNameœ: œCONTENT_GUIDELINESœ, œidœ: œPrompt-atb3fœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -63,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-HVGJ1", + "id": "TextInput-00Lsi", "name": "text", "output_types": [ "Message" @@ -71,7 +43,7 @@ }, "targetHandle": { "fieldName": "OUTPUT_FORMAT", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "inputTypes": [ "Message", "Text" @@ -79,11 +51,11 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-HVGJ1{œdataTypeœ:œTextInputœ,œidœ:œTextInput-HVGJ1œ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-nDs5I{œfieldNameœ:œOUTPUT_FORMATœ,œidœ:œPrompt-nDs5Iœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-HVGJ1", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-HVGJ1œ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-nDs5I", - "targetHandle": "{œfieldNameœ: œOUTPUT_FORMATœ, œidœ: œPrompt-nDs5Iœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-00Lsi{œdataTypeœ:œTextInputœ,œidœ:œTextInput-00Lsiœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-atb3f{œfieldNameœ:œOUTPUT_FORMATœ,œidœ:œPrompt-atb3fœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-00Lsi", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-00Lsiœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-atb3f", + "targetHandle": "{œfieldNameœ: œOUTPUT_FORMATœ, œidœ: œPrompt-atb3fœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -91,7 +63,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-0s9hL", + "id": "TextInput-rmIDO", "name": "text", "output_types": [ "Message" @@ -99,7 +71,7 @@ }, "targetHandle": { "fieldName": "OUTPUT_LANGUAGE", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "inputTypes": [ "Message", "Text" @@ -107,11 +79,11 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-0s9hL{œdataTypeœ:œTextInputœ,œidœ:œTextInput-0s9hLœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-nDs5I{œfieldNameœ:œOUTPUT_LANGUAGEœ,œidœ:œPrompt-nDs5Iœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-0s9hL", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-0s9hLœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-nDs5I", - "targetHandle": "{œfieldNameœ: œOUTPUT_LANGUAGEœ, œidœ: œPrompt-nDs5Iœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-rmIDO{œdataTypeœ:œTextInputœ,œidœ:œTextInput-rmIDOœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-atb3f{œfieldNameœ:œOUTPUT_LANGUAGEœ,œidœ:œPrompt-atb3fœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-rmIDO", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-rmIDOœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-atb3f", + "targetHandle": "{œfieldNameœ: œOUTPUT_LANGUAGEœ, œidœ: œPrompt-atb3fœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -119,7 +91,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-ZUCJB", + "id": "TextInput-7RHoM", "name": "text", "output_types": [ "Message" @@ -127,7 +99,7 @@ }, "targetHandle": { "fieldName": "PROFILE_DETAILS", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "inputTypes": [ "Message", "Text" @@ -135,11 +107,11 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-ZUCJB{œdataTypeœ:œTextInputœ,œidœ:œTextInput-ZUCJBœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-nDs5I{œfieldNameœ:œPROFILE_DETAILSœ,œidœ:œPrompt-nDs5Iœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-ZUCJB", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-ZUCJBœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-nDs5I", - "targetHandle": "{œfieldNameœ: œPROFILE_DETAILSœ, œidœ: œPrompt-nDs5Iœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-7RHoM{œdataTypeœ:œTextInputœ,œidœ:œTextInput-7RHoMœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-atb3f{œfieldNameœ:œPROFILE_DETAILSœ,œidœ:œPrompt-atb3fœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-7RHoM", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-7RHoMœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-atb3f", + "targetHandle": "{œfieldNameœ: œPROFILE_DETAILSœ, œidœ: œPrompt-atb3fœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -147,7 +119,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-b4m4C", + "id": "TextInput-qidre", "name": "text", "output_types": [ "Message" @@ -155,7 +127,7 @@ }, "targetHandle": { "fieldName": "PROFILE_TYPE", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "inputTypes": [ "Message", "Text" @@ -163,11 +135,11 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-b4m4C{œdataTypeœ:œTextInputœ,œidœ:œTextInput-b4m4Cœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-nDs5I{œfieldNameœ:œPROFILE_TYPEœ,œidœ:œPrompt-nDs5Iœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-b4m4C", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-b4m4Cœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-nDs5I", - "targetHandle": "{œfieldNameœ: œPROFILE_TYPEœ, œidœ: œPrompt-nDs5Iœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-qidre{œdataTypeœ:œTextInputœ,œidœ:œTextInput-qidreœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-atb3f{œfieldNameœ:œPROFILE_TYPEœ,œidœ:œPrompt-atb3fœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-qidre", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-qidreœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-atb3f", + "targetHandle": "{œfieldNameœ: œPROFILE_TYPEœ, œidœ: œPrompt-atb3fœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -175,7 +147,7 @@ "data": { "sourceHandle": { "dataType": "TextInput", - "id": "TextInput-hSMuv", + "id": "TextInput-pf6qC", "name": "text", "output_types": [ "Message" @@ -183,7 +155,7 @@ }, "targetHandle": { "fieldName": "TONE_AND_STYLE", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "inputTypes": [ "Message", "Text" @@ -191,46 +163,17 @@ "type": "str" } }, - "id": "reactflow__edge-TextInput-hSMuv{œdataTypeœ:œTextInputœ,œidœ:œTextInput-hSMuvœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-nDs5I{œfieldNameœ:œTONE_AND_STYLEœ,œidœ:œPrompt-nDs5Iœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-hSMuv", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-hSMuvœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-nDs5I", - "targetHandle": "{œfieldNameœ: œTONE_AND_STYLEœ, œidœ: œPrompt-nDs5Iœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-TextInput-pf6qC{œdataTypeœ:œTextInputœ,œidœ:œTextInput-pf6qCœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-atb3f{œfieldNameœ:œTONE_AND_STYLEœ,œidœ:œPrompt-atb3fœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "TextInput-pf6qC", + "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-pf6qCœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-atb3f", + "targetHandle": "{œfieldNameœ: œTONE_AND_STYLEœ, œidœ: œPrompt-atb3fœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-nDs5I", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "system_message", - "id": "OpenAIModel-t1to9", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-nDs5I{œdataTypeœ:œPromptœ,œidœ:œPrompt-nDs5Iœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-t1to9{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-t1to9œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-nDs5I", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-nDs5Iœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-t1to9", - "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-t1to9œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-tE8u3", + "id": "ChatInput-AQpbG", "name": "message", "output_types": [ "Message" @@ -238,24 +181,74 @@ }, "targetHandle": { "fieldName": "input_value", - "id": "OpenAIModel-t1to9", + "id": "OpenAIModel-RvdWl", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "reactflow__edge-ChatInput-tE8u3{œdataTypeœ:œChatInputœ,œidœ:œChatInput-tE8u3œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-t1to9{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-t1to9œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-tE8u3", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-tE8u3œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-t1to9", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-t1to9œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "xy-edge__ChatInput-AQpbG{œdataTypeœ:œChatInputœ,œidœ:œChatInput-AQpbGœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-RvdWl{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-RvdWlœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-AQpbG", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-AQpbGœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-RvdWl", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-RvdWlœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-atb3f", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "system_message", + "id": "OpenAIModel-RvdWl", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-atb3f{œdataTypeœ:œPromptœ,œidœ:œPrompt-atb3fœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-RvdWl{œfieldNameœ:œsystem_messageœ,œidœ:œOpenAIModel-RvdWlœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-atb3f", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-atb3fœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-RvdWl", + "targetHandle": "{œfieldNameœ: œsystem_messageœ, œidœ: œOpenAIModel-RvdWlœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-RvdWl", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-17n9v", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-RvdWl{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-RvdWlœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-17n9v{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-17n9vœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-RvdWl", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-RvdWlœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-17n9v", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-17n9vœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ { "data": { - "id": "ChatInput-tE8u3", + "id": "ChatInput-AQpbG", "node": { "base_classes": [ "Message" @@ -528,7 +521,11 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-tE8u3", + "id": "ChatInput-AQpbG", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 863.3241377184722, "y": 1053.9324095084933 @@ -543,7 +540,7 @@ }, { "data": { - "id": "TextInput-0yHbX", + "id": "TextInput-Bg8zz", "node": { "base_classes": [ "Message" @@ -627,7 +624,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-0yHbX", + "id": "TextInput-Bg8zz", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1300.291760633212, "y": 417.7819626108867 @@ -640,325 +641,11 @@ "type": "genericNode", "width": 320 }, - { - "data": { - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "id": "OpenAIModel-t1to9", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.0.19.post2", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 630, - "id": "OpenAIModel-t1to9", - "position": { - "x": 2072.0401998064262, - "y": 828.7738120746212 - }, - "positionAbsolute": { - "x": 2072.0401998064262, - "y": 828.7738120746212 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-n8Wmg", + "id": "ChatOutput-17n9v", "node": { "base_classes": [ "Message" @@ -1217,24 +904,28 @@ }, "type": "ChatOutput" }, - "dragging": false, + "dragging": true, "height": 234, - "id": "ChatOutput-n8Wmg", + "id": "ChatOutput-17n9v", + "measured": { + "height": 234, + "width": 360 + }, "position": { - "x": 2470.223353127597, - "y": 1055.4039338762416 + "x": 2451.4525968502526, + "y": 1049.1470151171268 }, "positionAbsolute": { "x": 2470.223353127597, "y": 1055.4039338762416 }, - "selected": false, + "selected": true, "type": "genericNode", "width": 320 }, { "data": { - "id": "TextInput-HVGJ1", + "id": "TextInput-00Lsi", "node": { "base_classes": [ "Message" @@ -1318,7 +1009,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-HVGJ1", + "id": "TextInput-00Lsi", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1300.639277084099, "y": 665.0274048594538 @@ -1333,7 +1028,7 @@ }, { "data": { - "id": "TextInput-0s9hL", + "id": "TextInput-rmIDO", "node": { "base_classes": [ "Message" @@ -1417,7 +1112,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-0s9hL", + "id": "TextInput-rmIDO", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1302.1321888373375, "y": 910.3592488005739 @@ -1432,7 +1131,7 @@ }, { "data": { - "id": "TextInput-ZUCJB", + "id": "TextInput-7RHoM", "node": { "base_classes": [ "Message" @@ -1516,7 +1215,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-ZUCJB", + "id": "TextInput-7RHoM", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1302.0774628387737, "y": 1167.3244357663511 @@ -1531,7 +1234,7 @@ }, { "data": { - "id": "TextInput-hSMuv", + "id": "TextInput-pf6qC", "node": { "base_classes": [ "Message" @@ -1615,7 +1318,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-hSMuv", + "id": "TextInput-pf6qC", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1301.68182643676, "y": 1699.978793221378 @@ -1630,7 +1337,7 @@ }, { "data": { - "id": "TextInput-b4m4C", + "id": "TextInput-qidre", "node": { "base_classes": [ "Message" @@ -1714,7 +1421,11 @@ }, "dragging": false, "height": 234, - "id": "TextInput-b4m4C", + "id": "TextInput-qidre", + "measured": { + "height": 234, + "width": 360 + }, "position": { "x": 1301.4778537945892, "y": 1428.1749742780207 @@ -1729,7 +1440,7 @@ }, { "data": { - "id": "note-oQQCJ", + "id": "note-dplZB", "node": { "description": "# Twitter Thread Generator\n\nWelcome to the Twitter Thread Generator! This flow helps you create compelling Twitter threads by transforming your structured inputs into engaging content.\n\n## Instructions\n\n1. Prepare Your Inputs\n - Fill in the \"Context\" with your main message or story\n - Define \"Content Guidelines\" for thread structure and style\n - Specify \"Profile Type\" and \"Profile Details\" to reflect your brand identity\n - Set \"Tone and Style\" to guide the communication approach\n - Choose \"Output Format\" (thread) and desired language\n\n2. Configure the Prompt\n - The flow uses a specialized prompt template to generate content\n - Ensure all input fields are connected to the prompt node\n\n3. Run the Generation\n - Execute the flow to process your inputs\n - The OpenAI model will create the thread based on your specifications\n\n4. Review and Refine\n - Examine the output in the Chat Output node\n - If needed, adjust your inputs and re-run for better results\n\n5. Finalize and Post\n - Once satisfied, copy the generated thread\n - Post to Twitter, maintaining the structure and flow\n\nRemember: Be specific in your context and guidelines for the best results! 🚀\n", "display_name": "", @@ -1742,7 +1453,11 @@ }, "dragging": false, "height": 800, - "id": "note-oQQCJ", + "id": "note-dplZB", + "measured": { + "height": 800, + "width": 328 + }, "position": { "x": 675.0099418843004, "y": 233.23451233469402 @@ -1764,7 +1479,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", "node": { "base_classes": [ "Message" @@ -2014,7 +1729,11 @@ }, "dragging": false, "height": 779, - "id": "Prompt-nDs5I", + "id": "Prompt-atb3f", + "measured": { + "height": 779, + "width": 360 + }, "position": { "x": 1697.1682096049744, "y": 675.4022940880462 @@ -2026,12 +1745,354 @@ "selected": false, "type": "genericNode", "width": 320 + }, + { + "data": { + "id": "OpenAIModel-RvdWl", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-RvdWl", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 2077.6929601219513, + "y": 749.5994771046013 + }, + "selected": false, + "type": "genericNode" } ], "viewport": { - "x": -137.29857182316698, - "y": -73.67014598946389, - "zoom": 0.49710856297206957 + "x": -37.82574897322547, + "y": -72.05604403499899, + "zoom": 0.47946922686660903 } }, "description": "Transform structured inputs into engaging Twitter threads with this prompt-based flow, maintaining brand voice and technical accuracy.", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json b/src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json index 4956b8b47..6d8a97e4d 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json @@ -7,7 +7,7 @@ "data": { "sourceHandle": { "dataType": "ParseData", - "id": "ParseData-UH7tX", + "id": "ParseData-JV2Ry", "name": "text", "output_types": [ "Message" @@ -15,7 +15,7 @@ }, "targetHandle": { "fieldName": "context", - "id": "Prompt-sF0Mn", + "id": "Prompt-WhGNl", "inputTypes": [ "Message", "Text" @@ -23,65 +23,11 @@ "type": "str" } }, - "id": "reactflow__edge-ParseData-UH7tX{œdataTypeœ:œParseDataœ,œidœ:œParseData-UH7tXœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-sF0Mn{œfieldNameœ:œcontextœ,œidœ:œPrompt-sF0Mnœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "ParseData-UH7tX", - "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-UH7tXœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-sF0Mn", - "targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-sF0Mnœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-sF0Mn", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-RkTA1", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-sF0Mn{œdataTypeœ:œPromptœ,œidœ:œPrompt-sF0Mnœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-RkTA1{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-RkTA1œ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "Prompt-sF0Mn", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-sF0Mnœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "target": "OpenAIModel-RkTA1", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-RkTA1œ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "animated": false, - "className": "", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-RkTA1", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-0SENC", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-RkTA1{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-RkTA1œ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-0SENC{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-0SENCœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-RkTA1", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-RkTA1œ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "target": "ChatOutput-0SENC", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-0SENCœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ParseData-JV2Ry{œdataTypeœ:œParseDataœ,œidœ:œParseData-JV2Ryœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-WhGNl{œfieldNameœ:œcontextœ,œidœ:œPrompt-WhGNlœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "ParseData-JV2Ry", + "sourceHandle": "{œdataTypeœ: œParseDataœ, œidœ: œParseData-JV2Ryœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-WhGNl", + "targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-WhGNlœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -89,7 +35,7 @@ "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-J1eN6", + "id": "ChatInput-xWTbO", "name": "message", "output_types": [ "Message" @@ -97,7 +43,7 @@ }, "targetHandle": { "fieldName": "question", - "id": "Prompt-sF0Mn", + "id": "Prompt-WhGNl", "inputTypes": [ "Message", "Text" @@ -105,11 +51,11 @@ "type": "str" } }, - "id": "reactflow__edge-ChatInput-J1eN6{œdataTypeœ:œChatInputœ,œidœ:œChatInput-J1eN6œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-sF0Mn{œfieldNameœ:œquestionœ,œidœ:œPrompt-sF0Mnœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", - "source": "ChatInput-J1eN6", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-J1eN6œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "Prompt-sF0Mn", - "targetHandle": "{œfieldNameœ: œquestionœ, œidœ: œPrompt-sF0Mnœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ChatInput-xWTbO{œdataTypeœ:œChatInputœ,œidœ:œChatInput-xWTbOœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-WhGNl{œfieldNameœ:œquestionœ,œidœ:œPrompt-WhGNlœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}", + "source": "ChatInput-xWTbO", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-xWTbOœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "Prompt-WhGNl", + "targetHandle": "{œfieldNameœ: œquestionœ, œidœ: œPrompt-WhGNlœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}" }, { "animated": false, @@ -117,7 +63,7 @@ "data": { "sourceHandle": { "dataType": "File", - "id": "File-6bzAm", + "id": "File-zHNC8", "name": "data", "output_types": [ "Data" @@ -125,24 +71,25 @@ }, "targetHandle": { "fieldName": "data_inputs", - "id": "SplitText-Sayuz", + "id": "SplitText-TfND9", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "reactflow__edge-File-6bzAm{œdataTypeœ:œFileœ,œidœ:œFile-6bzAmœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-SplitText-Sayuz{œfieldNameœ:œdata_inputsœ,œidœ:œSplitText-Sayuzœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", - "source": "File-6bzAm", - "sourceHandle": "{œdataTypeœ: œFileœ, œidœ: œFile-6bzAmœ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", - "target": "SplitText-Sayuz", - "targetHandle": "{œfieldNameœ: œdata_inputsœ, œidœ: œSplitText-Sayuzœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-File-zHNC8{œdataTypeœ:œFileœ,œidœ:œFile-zHNC8œ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-SplitText-TfND9{œfieldNameœ:œdata_inputsœ,œidœ:œSplitText-TfND9œ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "source": "File-zHNC8", + "sourceHandle": "{œdataTypeœ: œFileœ, œidœ: œFile-zHNC8œ, œnameœ: œdataœ, œoutput_typesœ: [œDataœ]}", + "target": "SplitText-TfND9", + "targetHandle": "{œfieldNameœ: œdata_inputsœ, œidœ: œSplitText-TfND9œ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "OpenAIEmbeddings", - "id": "OpenAIEmbeddings-2DOEZ", + "id": "OpenAIEmbeddings-RXyh4", "name": "embeddings", "output_types": [ "Embeddings" @@ -150,24 +97,25 @@ }, "targetHandle": { "fieldName": "embedding_model", - "id": "AstraDB-O0rq2", + "id": "AstraDB-eCpm7", "inputTypes": [ "Embeddings" ], "type": "other" } }, - "id": "xy-edge__OpenAIEmbeddings-2DOEZ{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-2DOEZœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDB-O0rq2{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDB-O0rq2œ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", - "source": "OpenAIEmbeddings-2DOEZ", - "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-2DOEZœ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", - "target": "AstraDB-O0rq2", - "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDB-O0rq2œ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-OpenAIEmbeddings-RXyh4{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-RXyh4œ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDB-eCpm7{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDB-eCpm7œ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", + "source": "OpenAIEmbeddings-RXyh4", + "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-RXyh4œ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", + "target": "AstraDB-eCpm7", + "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDB-eCpm7œ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "SplitText", - "id": "SplitText-Sayuz", + "id": "SplitText-TfND9", "name": "chunks", "output_types": [ "Data" @@ -175,24 +123,25 @@ }, "targetHandle": { "fieldName": "ingest_data", - "id": "AstraDB-O0rq2", + "id": "AstraDB-eCpm7", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "xy-edge__SplitText-Sayuz{œdataTypeœ:œSplitTextœ,œidœ:œSplitText-Sayuzœ,œnameœ:œchunksœ,œoutput_typesœ:[œDataœ]}-AstraDB-O0rq2{œfieldNameœ:œingest_dataœ,œidœ:œAstraDB-O0rq2œ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", - "source": "SplitText-Sayuz", - "sourceHandle": "{œdataTypeœ: œSplitTextœ, œidœ: œSplitText-Sayuzœ, œnameœ: œchunksœ, œoutput_typesœ: [œDataœ]}", - "target": "AstraDB-O0rq2", - "targetHandle": "{œfieldNameœ: œingest_dataœ, œidœ: œAstraDB-O0rq2œ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-SplitText-TfND9{œdataTypeœ:œSplitTextœ,œidœ:œSplitText-TfND9œ,œnameœ:œchunksœ,œoutput_typesœ:[œDataœ]}-AstraDB-eCpm7{œfieldNameœ:œingest_dataœ,œidœ:œAstraDB-eCpm7œ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "source": "SplitText-TfND9", + "sourceHandle": "{œdataTypeœ: œSplitTextœ, œidœ: œSplitText-TfND9œ, œnameœ: œchunksœ, œoutput_typesœ: [œDataœ]}", + "target": "AstraDB-eCpm7", + "targetHandle": "{œfieldNameœ: œingest_dataœ, œidœ: œAstraDB-eCpm7œ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "ChatInput", - "id": "ChatInput-J1eN6", + "id": "ChatInput-xWTbO", "name": "message", "output_types": [ "Message" @@ -200,24 +149,25 @@ }, "targetHandle": { "fieldName": "search_query", - "id": "AstraDB-KN0Mp", + "id": "AstraDB-2ETzC", "inputTypes": [ "Message" ], "type": "str" } }, - "id": "xy-edge__ChatInput-J1eN6{œdataTypeœ:œChatInputœ,œidœ:œChatInput-J1eN6œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-AstraDB-KN0Mp{œfieldNameœ:œsearch_queryœ,œidœ:œAstraDB-KN0Mpœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", - "source": "ChatInput-J1eN6", - "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-J1eN6œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", - "target": "AstraDB-KN0Mp", - "targetHandle": "{œfieldNameœ: œsearch_queryœ, œidœ: œAstraDB-KN0Mpœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + "id": "reactflow__edge-ChatInput-xWTbO{œdataTypeœ:œChatInputœ,œidœ:œChatInput-xWTbOœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-AstraDB-2ETzC{œfieldNameœ:œsearch_queryœ,œidœ:œAstraDB-2ETzCœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "ChatInput-xWTbO", + "sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-xWTbOœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}", + "target": "AstraDB-2ETzC", + "targetHandle": "{œfieldNameœ: œsearch_queryœ, œidœ: œAstraDB-2ETzCœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "AstraDB", - "id": "AstraDB-KN0Mp", + "id": "AstraDB-2ETzC", "name": "search_results", "output_types": [ "Data" @@ -225,24 +175,25 @@ }, "targetHandle": { "fieldName": "data", - "id": "ParseData-UH7tX", + "id": "ParseData-JV2Ry", "inputTypes": [ "Data" ], "type": "other" } }, - "id": "xy-edge__AstraDB-KN0Mp{œdataTypeœ:œAstraDBœ,œidœ:œAstraDB-KN0Mpœ,œnameœ:œsearch_resultsœ,œoutput_typesœ:[œDataœ]}-ParseData-UH7tX{œfieldNameœ:œdataœ,œidœ:œParseData-UH7tXœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", - "source": "AstraDB-KN0Mp", - "sourceHandle": "{œdataTypeœ: œAstraDBœ, œidœ: œAstraDB-KN0Mpœ, œnameœ: œsearch_resultsœ, œoutput_typesœ: [œDataœ]}", - "target": "ParseData-UH7tX", - "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-UH7tXœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-AstraDB-2ETzC{œdataTypeœ:œAstraDBœ,œidœ:œAstraDB-2ETzCœ,œnameœ:œsearch_resultsœ,œoutput_typesœ:[œDataœ]}-ParseData-JV2Ry{œfieldNameœ:œdataœ,œidœ:œParseData-JV2Ryœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}", + "source": "AstraDB-2ETzC", + "sourceHandle": "{œdataTypeœ: œAstraDBœ, œidœ: œAstraDB-2ETzCœ, œnameœ: œsearch_resultsœ, œoutput_typesœ: [œDataœ]}", + "target": "ParseData-JV2Ry", + "targetHandle": "{œfieldNameœ: œdataœ, œidœ: œParseData-JV2Ryœ, œinputTypesœ: [œDataœ], œtypeœ: œotherœ}" }, { + "className": "", "data": { "sourceHandle": { "dataType": "OpenAIEmbeddings", - "id": "OpenAIEmbeddings-bgQ2k", + "id": "OpenAIEmbeddings-RcSEE", "name": "embeddings", "output_types": [ "Embeddings" @@ -250,18 +201,68 @@ }, "targetHandle": { "fieldName": "embedding_model", - "id": "AstraDB-KN0Mp", + "id": "AstraDB-2ETzC", "inputTypes": [ "Embeddings" ], "type": "other" } }, - "id": "xy-edge__OpenAIEmbeddings-bgQ2k{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-bgQ2kœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDB-KN0Mp{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDB-KN0Mpœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", - "source": "OpenAIEmbeddings-bgQ2k", - "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-bgQ2kœ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", - "target": "AstraDB-KN0Mp", - "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDB-KN0Mpœ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" + "id": "reactflow__edge-OpenAIEmbeddings-RcSEE{œdataTypeœ:œOpenAIEmbeddingsœ,œidœ:œOpenAIEmbeddings-RcSEEœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-AstraDB-2ETzC{œfieldNameœ:œembedding_modelœ,œidœ:œAstraDB-2ETzCœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}", + "source": "OpenAIEmbeddings-RcSEE", + "sourceHandle": "{œdataTypeœ: œOpenAIEmbeddingsœ, œidœ: œOpenAIEmbeddings-RcSEEœ, œnameœ: œembeddingsœ, œoutput_typesœ: [œEmbeddingsœ]}", + "target": "AstraDB-2ETzC", + "targetHandle": "{œfieldNameœ: œembedding_modelœ, œidœ: œAstraDB-2ETzCœ, œinputTypesœ: [œEmbeddingsœ], œtypeœ: œotherœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "Prompt", + "id": "Prompt-WhGNl", + "name": "prompt", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "OpenAIModel-IqFJR", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__Prompt-WhGNl{œdataTypeœ:œPromptœ,œidœ:œPrompt-WhGNlœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-IqFJR{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-IqFJRœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "Prompt-WhGNl", + "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-WhGNlœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", + "target": "OpenAIModel-IqFJR", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-IqFJRœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" + }, + { + "data": { + "sourceHandle": { + "dataType": "OpenAIModel", + "id": "OpenAIModel-IqFJR", + "name": "text_output", + "output_types": [ + "Message" + ] + }, + "targetHandle": { + "fieldName": "input_value", + "id": "ChatOutput-zeZUc", + "inputTypes": [ + "Message" + ], + "type": "str" + } + }, + "id": "xy-edge__OpenAIModel-IqFJR{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-IqFJRœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-zeZUc{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-zeZUcœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}", + "source": "OpenAIModel-IqFJR", + "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-IqFJRœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", + "target": "ChatOutput-zeZUc", + "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-zeZUcœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" } ], "nodes": [ @@ -269,7 +270,7 @@ "data": { "description": "Get chat inputs from the Playground.", "display_name": "Chat Input", - "id": "ChatInput-J1eN6", + "id": "ChatInput-xWTbO", "node": { "base_classes": [ "Message" @@ -532,10 +533,10 @@ }, "dragging": false, "height": 234, - "id": "ChatInput-J1eN6", + "id": "ChatInput-xWTbO", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { "x": 743.9745420290319, @@ -553,7 +554,7 @@ "data": { "description": "Convert Data into plain text following a specified template.", "display_name": "Parse Data", - "id": "ParseData-UH7tX", + "id": "ParseData-JV2Ry", "node": { "base_classes": [ "Message" @@ -685,10 +686,10 @@ }, "dragging": false, "height": 350, - "id": "ParseData-UH7tX", + "id": "ParseData-JV2Ry", "measured": { "height": 350, - "width": 320 + "width": 360 }, "position": { "x": 1606.0595305373527, @@ -706,7 +707,7 @@ "data": { "description": "Create a prompt template with dynamic variables.", "display_name": "Prompt", - "id": "Prompt-sF0Mn", + "id": "Prompt-WhGNl", "node": { "base_classes": [ "Message" @@ -864,10 +865,10 @@ }, "dragging": false, "height": 433, - "id": "Prompt-sF0Mn", + "id": "Prompt-WhGNl", "measured": { "height": 433, - "width": 320 + "width": 360 }, "position": { "x": 1977.9097981422992, @@ -885,7 +886,7 @@ "data": { "description": "Split text into chunks based on specified criteria.", "display_name": "Split Text", - "id": "SplitText-Sayuz", + "id": "SplitText-TfND9", "node": { "base_classes": [ "Data" @@ -1030,10 +1031,10 @@ }, "dragging": false, "height": 475, - "id": "SplitText-Sayuz", + "id": "SplitText-TfND9", "measured": { "height": 475, - "width": 320 + "width": 360 }, "position": { "x": 1683.4543896546102, @@ -1049,7 +1050,7 @@ }, { "data": { - "id": "note-zVbcF", + "id": "note-Dv6pY", "node": { "description": "## 🐕 2. Retriever Flow\n\nThis flow answers your questions with contextual data retrieved from your vector database.\n\nOpen the **Playground** and ask, \n\n```\nWhat is this document about?\n```\n", "display_name": "", @@ -1062,10 +1063,10 @@ }, "dragging": false, "height": 324, - "id": "note-zVbcF", + "id": "note-Dv6pY", "measured": { "height": 324, - "width": 325 + "width": 328 }, "position": { "x": 374.388314931542, @@ -1086,7 +1087,7 @@ }, { "data": { - "id": "note-v1fqj", + "id": "note-Ln4xi", "node": { "description": "## 📖 README\n\nLoad your data into a vector database with the 📚 **Load Data** flow, and then use your data as chat context with the 🐕 **Retriever** flow.\n\n**🚨 Add your OpenAI API key as a global variable to easily add it to all of the OpenAI components in this flow.** \n\n**Quick start**\n1. Run the 📚 **Load Data** flow.\n2. Run the 🐕 **Retriever** flow.\n\n**Next steps** \n\n- Experiment by changing the prompt and the loaded data to see how the bot's responses change. \n\nFor more info, see the [Langflow docs](https://docs.langflow.org/starter-projects-vector-store-rag).", "display_name": "Read Me", @@ -1099,10 +1100,10 @@ }, "dragging": false, "height": 527, - "id": "note-v1fqj", + "id": "note-Ln4xi", "measured": { "height": 527, - "width": 325 + "width": 328 }, "position": { "x": 94.28986613312418, @@ -1121,327 +1122,11 @@ "type": "noteNode", "width": 600 }, - { - "data": { - "id": "OpenAIModel-RkTA1", - "node": { - "base_classes": [ - "LanguageModel", - "Message" - ], - "beta": false, - "conditional_paths": [], - "custom_fields": {}, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "edited": false, - "field_order": [ - "input_value", - "system_message", - "stream", - "max_tokens", - "model_kwargs", - "json_mode", - "output_schema", - "model_name", - "openai_api_base", - "api_key", - "temperature", - "seed", - "output_parser" - ], - "frozen": false, - "icon": "OpenAI", - "legacy": false, - "lf_version": "1.1.1", - "metadata": {}, - "output_types": [], - "outputs": [ - { - "allows_loop": false, - "cache": true, - "display_name": "Message", - "method": "text_response", - "name": "text_output", - "required_inputs": [], - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "allows_loop": false, - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "required_inputs": [], - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "pinned": false, - "template": { - "_type": "Component", - "api_key": { - "_input_type": "SecretStrInput", - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [ - "Message" - ], - "load_from_db": true, - "name": "api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" - }, - "input_value": { - "_input_type": "MessageInput", - "advanced": false, - "display_name": "Input", - "dynamic": false, - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "input_value", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "json_mode": { - "_input_type": "BoolInput", - "advanced": true, - "display_name": "JSON Mode", - "dynamic": false, - "info": "If True, it will output JSON regardless of passing a schema.", - "list": false, - "name": "json_mode", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "max_tokens": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "list": false, - "name": "max_tokens", - "placeholder": "", - "range_spec": { - "max": 128000, - "min": 0, - "step": 0.1, - "step_type": "float" - }, - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": "" - }, - "model_kwargs": { - "_input_type": "DictInput", - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "info": "Additional keyword arguments to pass to the model.", - "list": false, - "name": "model_kwargs", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_input": true, - "type": "dict", - "value": {} - }, - "model_name": { - "_input_type": "DropdownInput", - "advanced": false, - "combobox": false, - "display_name": "Model Name", - "dynamic": false, - "info": "", - "name": "model_name", - "options": [ - "gpt-4o-mini", - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-4", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_metadata": true, - "type": "str", - "value": "gpt-4o-mini" - }, - "openai_api_base": { - "_input_type": "StrInput", - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", - "list": false, - "load_from_db": false, - "name": "openai_api_base", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "seed": { - "_input_type": "IntInput", - "advanced": true, - "display_name": "Seed", - "dynamic": false, - "info": "The seed controls the reproducibility of the job.", - "list": false, - "name": "seed", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "int", - "value": 1 - }, - "stream": { - "_input_type": "BoolInput", - "advanced": false, - "display_name": "Stream", - "dynamic": false, - "info": "Stream the response from the model. Streaming works only in Chat.", - "list": false, - "name": "stream", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "bool", - "value": false - }, - "system_message": { - "_input_type": "MessageTextInput", - "advanced": false, - "display_name": "System Message", - "dynamic": false, - "info": "System message to pass to the model.", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "name": "system_message", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "tool_mode": false, - "trace_as_input": true, - "trace_as_metadata": true, - "type": "str", - "value": "" - }, - "temperature": { - "_input_type": "FloatInput", - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "info": "", - "list": false, - "name": "temperature", - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "trace_as_metadata": true, - "type": "float", - "value": 0.1 - } - }, - "tool_mode": false - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 674, - "id": "OpenAIModel-RkTA1", - "measured": { - "height": 674, - "width": 320 - }, - "position": { - "x": 2360.1432368563187, - "y": 571.6712358167248 - }, - "positionAbsolute": { - "x": 2360.1432368563187, - "y": 571.6712358167248 - }, - "selected": false, - "type": "genericNode", - "width": 320 - }, { "data": { "description": "Display a chat message in the Playground.", "display_name": "Chat Output", - "id": "ChatOutput-0SENC", + "id": "ChatOutput-zeZUc", "node": { "base_classes": [ "Message" @@ -1702,14 +1387,14 @@ }, "dragging": false, "height": 234, - "id": "ChatOutput-0SENC", + "id": "ChatOutput-zeZUc", "measured": { "height": 234, - "width": 320 + "width": 360 }, "position": { - "x": 2734.385670401691, - "y": 810.6079786425926 + "x": 2738.611008351098, + "y": 829.6219994149209 }, "positionAbsolute": { "x": 2734.385670401691, @@ -1721,7 +1406,7 @@ }, { "data": { - "id": "OpenAIEmbeddings-bgQ2k", + "id": "OpenAIEmbeddings-RcSEE", "node": { "base_classes": [ "Embeddings" @@ -2200,10 +1885,10 @@ }, "dragging": false, "height": 320, - "id": "OpenAIEmbeddings-bgQ2k", + "id": "OpenAIEmbeddings-RcSEE", "measured": { "height": 320, - "width": 320 + "width": 360 }, "position": { "x": 825.435626932521, @@ -2219,7 +1904,7 @@ }, { "data": { - "id": "note-qal12", + "id": "note-vRlKb", "node": { "description": "## 📚 1. Load Data Flow\n\nRun this first! Load data from a local file and embed it into the vector database.\n\nSelect a Database and a Collection, or create new ones. \n\nClick ▶️ **Run component** on the **Astra DB** component to load your data.\n\n* If you're using OSS Langflow, add your Astra DB Application Token to the Astra DB component.\n\n#### Next steps:\n Experiment by changing the prompt and the contextual data to see how the retrieval flow's responses change.", "display_name": "", @@ -2232,10 +1917,10 @@ }, "dragging": false, "height": 50, - "id": "note-qal12", + "id": "note-vRlKb", "measured": { "height": 50, - "width": 325 + "width": 328 }, "position": { "x": 955.3277857006676, @@ -2255,7 +1940,7 @@ }, { "data": { - "id": "OpenAIEmbeddings-2DOEZ", + "id": "OpenAIEmbeddings-RXyh4", "node": { "base_classes": [ "Embeddings" @@ -2734,10 +2419,10 @@ }, "dragging": false, "height": 320, - "id": "OpenAIEmbeddings-2DOEZ", + "id": "OpenAIEmbeddings-RXyh4", "measured": { "height": 320, - "width": 320 + "width": 360 }, "position": { "x": 1690.9220896443658, @@ -2753,7 +2438,7 @@ }, { "data": { - "id": "File-6bzAm", + "id": "File-zHNC8", "node": { "base_classes": [ "Data" @@ -2978,10 +2663,10 @@ }, "dragging": false, "height": 367, - "id": "File-6bzAm", + "id": "File-zHNC8", "measured": { "height": 367, - "width": 320 + "width": 360 }, "position": { "x": 1318.9043936921921, @@ -2997,7 +2682,7 @@ }, { "data": { - "id": "note-Y8Yfz", + "id": "note-Sfs1f", "node": { "description": "### 💡 Add your OpenAI API key here 👇", "display_name": "", @@ -3010,10 +2695,10 @@ }, "dragging": false, "height": 324, - "id": "note-Y8Yfz", + "id": "note-Sfs1f", "measured": { "height": 324, - "width": 324 + "width": 326 }, "position": { "x": 1692.2322233423606, @@ -3029,7 +2714,7 @@ }, { "data": { - "id": "note-f6zyT", + "id": "note-CWV0c", "node": { "description": "### 💡 Add your OpenAI API key here 👇", "display_name": "", @@ -3042,10 +2727,10 @@ }, "dragging": false, "height": 324, - "id": "note-f6zyT", + "id": "note-CWV0c", "measured": { "height": 324, - "width": 324 + "width": 326 }, "position": { "x": 824.1003268813427, @@ -3061,7 +2746,7 @@ }, { "data": { - "id": "note-AmpWa", + "id": "note-ClCtT", "node": { "description": "### 💡 Add your OpenAI API key here 👇", "display_name": "", @@ -3074,10 +2759,10 @@ }, "dragging": false, "height": 324, - "id": "note-AmpWa", + "id": "note-ClCtT", "measured": { "height": 324, - "width": 324 + "width": 326 }, "position": { "x": 2350.297636215281, @@ -3093,7 +2778,7 @@ }, { "data": { - "id": "AstraDB-O0rq2", + "id": "AstraDB-eCpm7", "node": { "base_classes": [ "Data", @@ -3293,7 +2978,11 @@ "info": "Select a database in Astra DB.", "name": "database_name", "options": [], - "options_metadata": [], + "options_metadata": [ + { + "collections": 0 + } + ], "placeholder": "", "real_time_refresh": true, "refresh_button": true, @@ -3303,7 +2992,7 @@ "tool_mode": false, "trace_as_metadata": true, "type": "str", - "value": [] + "value": "" }, "deletion_field": { "_input_type": "StrInput", @@ -3522,7 +3211,7 @@ "show": true, "title_case": false, "type": "str", - "value": "ASTRA_DB_APPLICATION_TOKEN" + "value": "" } }, "tool_mode": false @@ -3531,10 +3220,10 @@ "type": "AstraDB" }, "dragging": false, - "id": "AstraDB-O0rq2", + "id": "AstraDB-eCpm7", "measured": { - "height": 614, - "width": 320 + "height": 686, + "width": 360 }, "position": { "x": 2053.72248912555, @@ -3545,7 +3234,7 @@ }, { "data": { - "id": "AstraDB-KN0Mp", + "id": "AstraDB-2ETzC", "node": { "base_classes": [ "Data", @@ -3745,7 +3434,11 @@ "info": "Select a database in Astra DB.", "name": "database_name", "options": [], - "options_metadata": [], + "options_metadata": [ + { + "collections": 1 + } + ], "placeholder": "", "real_time_refresh": true, "refresh_button": true, @@ -3974,7 +3667,7 @@ "show": true, "title_case": false, "type": "str", - "value": "ASTRA_DB_APPLICATION_TOKEN" + "value": "" } }, "tool_mode": false @@ -3983,23 +3676,365 @@ "type": "AstraDB" }, "dragging": false, - "id": "AstraDB-KN0Mp", + "id": "AstraDB-2ETzC", "measured": { - "height": 614, - "width": 320 + "height": 686, + "width": 360 }, "position": { "x": 1211.81052392379, "y": 596.2478494450424 }, - "selected": true, + "selected": false, + "type": "genericNode" + }, + { + "data": { + "id": "OpenAIModel-IqFJR", + "node": { + "base_classes": [ + "LanguageModel", + "Message" + ], + "beta": false, + "category": "models", + "conditional_paths": [], + "custom_fields": {}, + "description": "Generates text using OpenAI LLMs.", + "display_name": "OpenAI", + "documentation": "", + "edited": false, + "field_order": [ + "input_value", + "system_message", + "stream", + "max_tokens", + "model_kwargs", + "json_mode", + "model_name", + "openai_api_base", + "api_key", + "temperature", + "seed" + ], + "frozen": false, + "icon": "OpenAI", + "key": "OpenAIModel", + "legacy": false, + "metadata": {}, + "minimized": false, + "output_types": [], + "outputs": [ + { + "allows_loop": false, + "cache": true, + "display_name": "Message", + "method": "text_response", + "name": "text_output", + "required_inputs": [], + "selected": "Message", + "types": [ + "Message" + ], + "value": "__UNDEFINED__" + }, + { + "allows_loop": false, + "cache": true, + "display_name": "Language Model", + "method": "build_model", + "name": "model_output", + "required_inputs": [], + "selected": "LanguageModel", + "types": [ + "LanguageModel" + ], + "value": "__UNDEFINED__" + } + ], + "pinned": false, + "score": 0.14285714285714285, + "template": { + "_type": "Component", + "api_key": { + "_input_type": "SecretStrInput", + "advanced": false, + "display_name": "OpenAI API Key", + "dynamic": false, + "info": "The OpenAI API Key to use for the OpenAI model.", + "input_types": [ + "Message" + ], + "load_from_db": true, + "name": "api_key", + "password": true, + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "type": "str", + "value": "OPENAI_API_KEY" + }, + "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 langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, IntInput, SecretStrInput, SliderInput, StrInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n SliderInput(\n name=\"temperature\", display_name=\"Temperature\", value=0.1, range_spec=RangeSpec(min=0, max=2, step=0.01)\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n" + }, + "input_value": { + "_input_type": "MessageInput", + "advanced": false, + "display_name": "Input", + "dynamic": false, + "info": "", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "input_value", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "json_mode": { + "_input_type": "BoolInput", + "advanced": true, + "display_name": "JSON Mode", + "dynamic": false, + "info": "If True, it will output JSON regardless of passing a schema.", + "list": false, + "list_add_label": "Add More", + "name": "json_mode", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "max_tokens": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Max Tokens", + "dynamic": false, + "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", + "list": false, + "list_add_label": "Add More", + "name": "max_tokens", + "placeholder": "", + "range_spec": { + "max": 128000, + "min": 0, + "step": 0.1, + "step_type": "float" + }, + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": "" + }, + "model_kwargs": { + "_input_type": "DictInput", + "advanced": true, + "display_name": "Model Kwargs", + "dynamic": false, + "info": "Additional keyword arguments to pass to the model.", + "list": false, + "list_add_label": "Add More", + "name": "model_kwargs", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "type": "dict", + "value": {} + }, + "model_name": { + "_input_type": "DropdownInput", + "advanced": false, + "combobox": false, + "dialog_inputs": {}, + "display_name": "Model Name", + "dynamic": false, + "info": "", + "name": "model_name", + "options": [ + "gpt-4o-mini", + "gpt-4o", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125" + ], + "options_metadata": [], + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "gpt-4o-mini" + }, + "openai_api_base": { + "_input_type": "StrInput", + "advanced": true, + "display_name": "OpenAI API Base", + "dynamic": false, + "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.", + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "name": "openai_api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "seed": { + "_input_type": "IntInput", + "advanced": true, + "display_name": "Seed", + "dynamic": false, + "info": "The seed controls the reproducibility of the job.", + "list": false, + "list_add_label": "Add More", + "name": "seed", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "int", + "value": 1 + }, + "stream": { + "_input_type": "BoolInput", + "advanced": false, + "display_name": "Stream", + "dynamic": false, + "info": "Stream the response from the model. Streaming works only in Chat.", + "list": false, + "list_add_label": "Add More", + "name": "stream", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_metadata": true, + "type": "bool", + "value": false + }, + "system_message": { + "_input_type": "MultilineInput", + "advanced": false, + "display_name": "System Message", + "dynamic": false, + "info": "System message to pass to the model.", + "input_types": [ + "Message" + ], + "list": false, + "list_add_label": "Add More", + "load_from_db": false, + "multiline": true, + "name": "system_message", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + }, + "temperature": { + "_input_type": "SliderInput", + "advanced": false, + "display_name": "Temperature", + "dynamic": false, + "info": "", + "max_label": "", + "max_label_icon": "", + "min_label": "", + "min_label_icon": "", + "name": "temperature", + "placeholder": "", + "range_spec": { + "max": 2, + "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, + "type": "slider", + "value": 0.1 + } + }, + "tool_mode": false + }, + "showNode": true, + "type": "OpenAIModel" + }, + "dragging": false, + "id": "OpenAIModel-IqFJR", + "measured": { + "height": 734, + "width": 360 + }, + "position": { + "x": 2365.714820732046, + "y": 600.6979286268308 + }, + "selected": false, "type": "genericNode" } ], "viewport": { - "x": 112.11000558627495, - "y": -163.1714705321857, - "zoom": 0.43217536168398524 + "x": 47.8442601004615, + "y": -178.71161058286998, + "zoom": 0.47333491993960286 } }, "description": "Load your data for chat context with Retrieval Augmented Generation.",