From bb785c7be4cbd9c8e75210ecb4ea04a3b528f54b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 24 Jun 2024 09:25:12 -0300 Subject: [PATCH] fix: remove prompt chaining project --- .../Langflow Prompt Chaining.json | 1776 ----------------- 1 file changed, 1776 deletions(-) delete mode 100644 src/backend/base/langflow/initial_setup/starter_projects/Langflow Prompt Chaining.json diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Langflow Prompt Chaining.json b/src/backend/base/langflow/initial_setup/starter_projects/Langflow Prompt Chaining.json deleted file mode 100644 index b2ecbd035..000000000 --- a/src/backend/base/langflow/initial_setup/starter_projects/Langflow Prompt Chaining.json +++ /dev/null @@ -1,1776 +0,0 @@ -{ - "data": { - "edges": [ - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "TextInput", - "id": "TextInput-sptaH", - "name": "text", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "document", - "id": "Prompt-amqBu", - "inputTypes": [ - "Document", - "Message", - "Record", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-TextInput-sptaH{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œTextInputœ,œidœ:œTextInput-sptaHœ}-Prompt-amqBu{œfieldNameœ:œdocumentœ,œidœ:œPrompt-amqBuœ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}", - "source": "TextInput-sptaH", - "sourceHandle": "{œdataTypeœ: œTextInputœ, œidœ: œTextInput-sptaHœ, œnameœ: œtextœ, œoutput_typesœ: [œMessageœ]}", - "style": { - "stroke": "#555" - }, - "target": "Prompt-amqBu", - "targetHandle": "{œfieldNameœ: œdocumentœ, œidœ: œPrompt-amqBuœ, œinputTypesœ: [œDocumentœ, œMessageœ, œRecordœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-amqBu", - "name": "text", - "output_types": [] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "TextOutput-2MS4a", - "inputTypes": [ - "Record", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-amqBu{œbaseClassesœ:[œobjectœ,œstrœ,œTextœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-amqBuœ}-TextOutput-2MS4a{œfieldNameœ:œinput_valueœ,œidœ:œTextOutput-2MS4aœ,œinputTypesœ:[œRecordœ,œTextœ],œtypeœ:œstrœ}", - "source": "Prompt-amqBu", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-amqBuœ, œnameœ: œtextœ, œoutput_typesœ: []}", - "style": { - "stroke": "#555" - }, - "target": "TextOutput-2MS4a", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œTextOutput-2MS4aœ, œinputTypesœ: [œRecordœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-amqBu", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-uYXZJ", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-amqBu{œbaseClassesœ:[œobjectœ,œstrœ,œTextœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-amqBuœ}-OpenAIModel-uYXZJ{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-uYXZJœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}", - "source": "Prompt-amqBu", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-amqBuœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "style": { - "stroke": "#555" - }, - "target": "OpenAIModel-uYXZJ", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-uYXZJœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-uYXZJ", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "summary", - "id": "Prompt-gTNiz", - "inputTypes": [ - "Document", - "Message", - "Record", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-uYXZJ{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-uYXZJœ}-Prompt-gTNiz{œfieldNameœ:œsummaryœ,œidœ:œPrompt-gTNizœ,œinputTypesœ:[œDocumentœ,œBaseOutputParserœ,œRecordœ,œTextœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-uYXZJ", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-uYXZJœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "style": { - "stroke": "#555" - }, - "target": "Prompt-gTNiz", - "targetHandle": "{œfieldNameœ: œsummaryœ, œidœ: œPrompt-gTNizœ, œinputTypesœ: [œDocumentœ, œMessageœ, œRecordœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-uYXZJ", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-EJkG3", - "inputTypes": [ - "Message", - "str" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-uYXZJ{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-uYXZJœ}-ChatOutput-EJkG3{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-EJkG3œ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-uYXZJ", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-uYXZJœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "style": { - "stroke": "#555" - }, - "target": "ChatOutput-EJkG3", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-EJkG3œ, œinputTypesœ: [œMessageœ, œstrœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-gTNiz", - "name": "text", - "output_types": [] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "TextOutput-MUDOR", - "inputTypes": [ - "Record", - "Text" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-gTNiz{œbaseClassesœ:[œobjectœ,œstrœ,œTextœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-gTNizœ}-TextOutput-MUDOR{œfieldNameœ:œinput_valueœ,œidœ:œTextOutput-MUDORœ,œinputTypesœ:[œRecordœ,œTextœ],œtypeœ:œstrœ}", - "source": "Prompt-gTNiz", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-gTNizœ, œnameœ: œtextœ, œoutput_typesœ: []}", - "style": { - "stroke": "#555" - }, - "target": "TextOutput-MUDOR", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œTextOutput-MUDORœ, œinputTypesœ: [œRecordœ, œTextœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "Prompt", - "id": "Prompt-gTNiz", - "name": "prompt", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "OpenAIModel-XawYB", - "inputTypes": [ - "Message" - ], - "type": "str" - } - }, - "id": "reactflow__edge-Prompt-gTNiz{œbaseClassesœ:[œobjectœ,œstrœ,œTextœ],œdataTypeœ:œPromptœ,œidœ:œPrompt-gTNizœ}-OpenAIModel-XawYB{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-XawYBœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}", - "source": "Prompt-gTNiz", - "sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-gTNizœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}", - "style": { - "stroke": "#555" - }, - "target": "OpenAIModel-XawYB", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-XawYBœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}" - }, - { - "className": "stroke-gray-900 stroke-connection", - "data": { - "sourceHandle": { - "dataType": "OpenAIModel", - "id": "OpenAIModel-XawYB", - "name": "text_output", - "output_types": [ - "Message" - ] - }, - "targetHandle": { - "fieldName": "input_value", - "id": "ChatOutput-DNmvg", - "inputTypes": [ - "Message", - "str" - ], - "type": "str" - } - }, - "id": "reactflow__edge-OpenAIModel-XawYB{œbaseClassesœ:[œstrœ,œTextœ,œobjectœ],œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-XawYBœ}-ChatOutput-DNmvg{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-DNmvgœ,œinputTypesœ:[œTextœ],œtypeœ:œstrœ}", - "source": "OpenAIModel-XawYB", - "sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-XawYBœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}", - "style": { - "stroke": "#555" - }, - "target": "ChatOutput-DNmvg", - "targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-DNmvgœ, œinputTypesœ: [œMessageœ, œstrœ], œtypeœ: œstrœ}" - } - ], - "nodes": [ - { - "data": { - "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt", - "id": "Prompt-amqBu", - "node": { - "base_classes": [ - "object", - "str", - "Text" - ], - "beta": false, - "custom_fields": { - "template": [ - "document" - ] - }, - "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt", - "documentation": "", - "error": null, - "field_formatters": {}, - "field_order": [], - "frozen": false, - "full_path": null, - "icon": "prompts", - "is_composition": null, - "is_input": null, - "is_output": null, - "name": "", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Prompt Message", - "method": "build_prompt", - "name": "prompt", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - } - ], - "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 langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n" - }, - "document": { - "advanced": false, - "display_name": "document", - "dynamic": false, - "field_type": "str", - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Document", - "Message", - "Record", - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "document", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "template": { - "advanced": false, - "display_name": "Template", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "template", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "prompt", - "value": "You are a helpful assistant. Given a long document, your task is to create a concise summary that captures the main points and key details. The summary should be clear, accurate, and succinct. Please provide the summary in the format below:\n####\n{document}\n####\n" - } - } - }, - "type": "Prompt" - }, - "dragging": false, - "height": 385, - "id": "Prompt-amqBu", - "position": { - "x": 2191.5837146441663, - "y": 1047.9307944451873 - }, - "positionAbsolute": { - "x": 2191.5837146441663, - "y": 1047.9307944451873 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt", - "id": "Prompt-gTNiz", - "node": { - "base_classes": [ - "object", - "str", - "Text" - ], - "beta": false, - "custom_fields": { - "template": [ - "summary" - ] - }, - "description": "Create a prompt template with dynamic variables.", - "display_name": "Prompt", - "documentation": "", - "error": null, - "field_formatters": {}, - "field_order": [], - "frozen": false, - "full_path": null, - "icon": "prompts", - "is_composition": null, - "is_input": null, - "is_output": null, - "name": "", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Prompt Message", - "method": "build_prompt", - "name": "prompt", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - } - ], - "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 langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n" - }, - "summary": { - "advanced": false, - "display_name": "summary", - "dynamic": false, - "field_type": "str", - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Document", - "Message", - "Record", - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "summary", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "template": { - "advanced": false, - "display_name": "Template", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "template", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "prompt", - "value": "Given a summary of an article, please create two multiple-choice questions that cover the key points and details mentioned. Ensure the questions are clear and provide three options (A, B, C), with one correct answer.\n####\n{summary}\n####" - } - } - }, - "type": "Prompt" - }, - "dragging": false, - "height": 385, - "id": "Prompt-gTNiz", - "position": { - "x": 3731.0813766902447, - "y": 799.631909121391 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "ChatOutput-EJkG3", - "node": { - "base_classes": [ - "object", - "Record", - "Text", - "str" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "record_template": null, - "return_record": null, - "sender": null, - "sender_name": null, - "session_id": null - }, - "description": "Display a chat message in the Playground.", - "display_name": "Chat Output", - "documentation": "", - "field_formatters": {}, - "field_order": [], - "frozen": false, - "icon": "ChatOutput", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Message", - "method": "message_response", - "name": "message", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - } - ], - "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 langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, Output, MessageTextInput\nfrom langflow.schema.message import Message\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"ChatOutput\"\n\n inputs = [\n MessageTextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"Machine\",\n advanced=True,\n info=\"Type of sender.\",\n ),\n MessageTextInput(\n name=\"sender_name\", display_name=\"Sender Name\", info=\"Name of the sender.\", value=\"AI\", advanced=True\n ),\n MessageTextInput(name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True),\n MessageTextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n" - }, - "input_value": { - "advanced": false, - "display_name": "Text", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Message to be passed as output.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "sender": { - "advanced": true, - "display_name": "Sender Type", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Type of sender.", - "input_types": [ - "Text" - ], - "list": true, - "load_from_db": false, - "multiline": false, - "name": "sender", - "options": [ - "Machine", - "User" - ], - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "Machine" - }, - "sender_name": { - "advanced": true, - "display_name": "Sender Name", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Name of the sender.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "sender_name", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "AI" - }, - "session_id": { - "advanced": true, - "display_name": "Session ID", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Session ID for the message.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "session_id", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - } - } - }, - "type": "ChatOutput" - }, - "dragging": false, - "height": 385, - "id": "ChatOutput-EJkG3", - "position": { - "x": 3722.1747844849388, - "y": 1283.413553222214 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "ChatOutput-DNmvg", - "node": { - "base_classes": [ - "object", - "Record", - "Text", - "str" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "record_template": null, - "return_record": null, - "sender": null, - "sender_name": null, - "session_id": null - }, - "description": "Display a chat message in the Playground.", - "display_name": "Chat Output", - "documentation": "", - "field_formatters": {}, - "field_order": [], - "frozen": false, - "icon": "ChatOutput", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Message", - "method": "message_response", - "name": "message", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - } - ], - "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 langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, Output, MessageTextInput\nfrom langflow.schema.message import Message\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"ChatOutput\"\n\n inputs = [\n MessageTextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"Machine\",\n advanced=True,\n info=\"Type of sender.\",\n ),\n MessageTextInput(\n name=\"sender_name\", display_name=\"Sender Name\", info=\"Name of the sender.\", value=\"AI\", advanced=True\n ),\n MessageTextInput(name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True),\n MessageTextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n" - }, - "input_value": { - "advanced": false, - "display_name": "Text", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Message to be passed as output.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "sender": { - "advanced": true, - "display_name": "Sender Type", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Type of sender.", - "input_types": [ - "Text" - ], - "list": true, - "load_from_db": false, - "multiline": false, - "name": "sender", - "options": [ - "Machine", - "User" - ], - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "Machine" - }, - "sender_name": { - "advanced": true, - "display_name": "Sender Name", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Name of the sender.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "sender_name", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "AI" - }, - "session_id": { - "advanced": true, - "display_name": "Session ID", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Session ID for the message.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "session_id", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - } - } - }, - "type": "ChatOutput" - }, - "height": 385, - "id": "ChatOutput-DNmvg", - "position": { - "x": 5077.71285886074, - "y": 1232.9152769735522 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "TextInput-sptaH", - "node": { - "base_classes": [ - "str", - "Text", - "object" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "record_template": null - }, - "description": "Get text inputs from the Playground.", - "display_name": "Text Input", - "documentation": "", - "field_formatters": {}, - "field_order": [], - "frozen": false, - "icon": "type", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Text", - "method": "text_response", - "name": "text", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - } - ], - "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 langflow.base.io.text import TextComponent\nfrom langflow.io import Output, MessageTextInput\nfrom langflow.schema.message import Message\n\n\nclass TextInputComponent(TextComponent):\n display_name = \"Text Input\"\n description = \"Get text inputs from the Playground.\"\n icon = \"type\"\n\n inputs = [\n MessageTextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Text to be passed as input.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Text\", name=\"text\", method=\"text_response\"),\n ]\n\n def text_response(self) -> Message:\n message = Message(\n text=self.input_value,\n )\n return message\n" - }, - "input_value": { - "advanced": false, - "display_name": "Text", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Text to be passed as input.", - "input_types": [ - "Message", - "str" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - } - } - }, - "type": "TextInput" - }, - "dragging": false, - "height": 290, - "id": "TextInput-sptaH", - "position": { - "x": 1700.5624822024752, - "y": 1039.603088937466 - }, - "positionAbsolute": { - "x": 1700.5624822024752, - "y": 1039.603088937466 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "TextOutput-2MS4a", - "node": { - "base_classes": [ - "str", - "Text", - "object" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "record_template": null - }, - "description": "Display a text output in the Playground.", - "display_name": "First Prompt", - "documentation": "", - "field_formatters": {}, - "field_order": [], - "frozen": false, - "icon": "type", - "output_types": [ - "Text" - ], - "template": { - "_type": "CustomComponent", - "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 Optional\n\nfrom langflow.base.io.text import TextComponent\nfrom langflow.field_typing import Text\n\n\nclass TextOutput(TextComponent):\n display_name = \"Text Output\"\n description = \"Display a text output in the Playground.\"\n icon = \"type\"\n\n def build_config(self):\n return {\n \"input_value\": {\n \"display_name\": \"Value\",\n \"input_types\": [\"Record\", \"Text\"],\n \"info\": \"Text or Record to be passed as output.\",\n },\n \"record_template\": {\n \"display_name\": \"Record Template\",\n \"multiline\": True,\n \"info\": \"Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.\",\n \"advanced\": True,\n },\n }\n\n def build(self, input_value: Optional[Text] = \"\", record_template: str = \"\") -> Text:\n return super().build(input_value=input_value, record_template=record_template)\n" - }, - "input_value": { - "advanced": false, - "display_name": "Value", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Text or Record to be passed as output.", - "input_types": [ - "Record", - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "record_template": { - "advanced": true, - "display_name": "Record Template", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "record_template", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - } - } - }, - "type": "TextOutput" - }, - "dragging": false, - "height": 290, - "id": "TextOutput-2MS4a", - "position": { - "x": 2917.216113690115, - "y": 513.0058511435552 - }, - "positionAbsolute": { - "x": 2917.216113690115, - "y": 513.0058511435552 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "OpenAIModel-uYXZJ", - "node": { - "base_classes": [ - "str", - "Text", - "object" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "max_tokens": null, - "model_kwargs": null, - "model_name": null, - "openai_api_base": null, - "openai_api_key": null, - "stream": null, - "system_message": null, - "temperature": null - }, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "field_formatters": {}, - "field_order": [ - "max_tokens", - "model_kwargs", - "model_name", - "openai_api_base", - "openai_api_key", - "temperature", - "input_value", - "system_message", - "stream" - ], - "frozen": false, - "icon": "OpenAI", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Text", - "method": "text_response", - "name": "text_output", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "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 operator\nfrom functools import reduce\n\nfrom langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.constants import STREAM_INFO_TEXT\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.inputs import (\n BoolInput,\n DictInput,\n DropdownInput,\n FloatInput,\n IntInput,\n MessageInput,\n SecretStrInput,\n StrInput,\n)\nfrom langflow.schema.message import Message\nfrom langflow.template import Output\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n inputs = [\n MessageInput(name=\"input_value\", display_name=\"Input\"),\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 ),\n DictInput(name=\"model_kwargs\", display_name=\"Model Kwargs\", advanced=True),\n DictInput(\n name=\"output_schema\",\n is_list=True,\n display_name=\"Schema\",\n advanced=True,\n info=\"The schema for the Output of the model. You must pass the word JSON in the prompt. If left blank, JSON mode will be disabled.\",\n ),\n DropdownInput(\n name=\"model_name\", display_name=\"Model Name\", advanced=False, options=MODEL_NAMES, value=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. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"openai_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 FloatInput(name=\"temperature\", display_name=\"Temperature\", value=0.1),\n BoolInput(name=\"stream\", display_name=\"Stream\", info=STREAM_INFO_TEXT, advanced=True),\n StrInput(\n name=\"system_message\",\n display_name=\"System Message\",\n info=\"System message to pass to the model.\",\n advanced=True,\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 outputs = [\n Output(display_name=\"Text\", name=\"text_output\", method=\"text_response\"),\n Output(display_name=\"Language Model\", name=\"model_output\", method=\"build_model\"),\n ]\n\n def text_response(self) -> Message:\n input_value = self.input_value\n stream = self.stream\n system_message = self.system_message\n output = self.build_model()\n result = self.get_chat_result(output, stream, input_value, system_message)\n self.status = result\n return result\n\n def build_model(self) -> LanguageModel:\n # self.output_schea is a list of dictionaries\n # let's convert it to a dictionary\n output_schema_dict: dict[str, str] = reduce(operator.ior, self.output_schema or {}, {})\n openai_api_key = self.openai_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\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = bool(output_schema_dict)\n seed = self.seed\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs or {},\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature or 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.with_structured_output(schema=output_schema_dict, method=\"json_mode\")\n\n return output\n" - }, - "input_value": { - "advanced": false, - "display_name": "Input", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "max_tokens": { - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "max_tokens", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "model_kwargs": { - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "model_kwargs", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "model_name": { - "advanced": false, - "display_name": "Model Name", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": true, - "load_from_db": false, - "multiline": false, - "name": "model_name", - "options": [ - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "gpt-3.5-turbo" - }, - "openai_api_base": { - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "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.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "openai_api_base", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "openai_api_key": { - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [], - "list": false, - "load_from_db": true, - "multiline": false, - "name": "openai_api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "stream": { - "advanced": true, - "display_name": "Stream", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Stream the response from the model. Streaming works only in Chat.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "stream", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": false - }, - "system_message": { - "advanced": true, - "display_name": "System Message", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "System message to pass to the model.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "system_message", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "temperature": { - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "temperature", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": 0.1 - } - } - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 565, - "id": "OpenAIModel-uYXZJ", - "position": { - "x": 2925.784767523062, - "y": 933.6465680967775 - }, - "positionAbsolute": { - "x": 2925.784767523062, - "y": 933.6465680967775 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "TextOutput-MUDOR", - "node": { - "base_classes": [ - "str", - "Text", - "object" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "record_template": null - }, - "description": "Display a text output in the Playground.", - "display_name": "Second Prompt", - "documentation": "", - "field_formatters": {}, - "field_order": [], - "frozen": false, - "icon": "type", - "output_types": [ - "Text" - ], - "template": { - "_type": "CustomComponent", - "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 Optional\n\nfrom langflow.base.io.text import TextComponent\nfrom langflow.field_typing import Text\n\n\nclass TextOutput(TextComponent):\n display_name = \"Text Output\"\n description = \"Display a text output in the Playground.\"\n icon = \"type\"\n\n def build_config(self):\n return {\n \"input_value\": {\n \"display_name\": \"Value\",\n \"input_types\": [\"Record\", \"Text\"],\n \"info\": \"Text or Record to be passed as output.\",\n },\n \"record_template\": {\n \"display_name\": \"Record Template\",\n \"multiline\": True,\n \"info\": \"Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.\",\n \"advanced\": True,\n },\n }\n\n def build(self, input_value: Optional[Text] = \"\", record_template: str = \"\") -> Text:\n return super().build(input_value=input_value, record_template=record_template)\n" - }, - "input_value": { - "advanced": false, - "display_name": "Value", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Text or Record to be passed as output.", - "input_types": [ - "Record", - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "record_template": { - "advanced": true, - "display_name": "Record Template", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "record_template", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - } - } - }, - "type": "TextOutput" - }, - "dragging": false, - "height": 290, - "id": "TextOutput-MUDOR", - "position": { - "x": 4446.064323520379, - "y": 633.833297518702 - }, - "positionAbsolute": { - "x": 4446.064323520379, - "y": 633.833297518702 - }, - "selected": false, - "type": "genericNode", - "width": 384 - }, - { - "data": { - "id": "OpenAIModel-XawYB", - "node": { - "base_classes": [ - "str", - "Text", - "object" - ], - "beta": false, - "custom_fields": { - "input_value": null, - "max_tokens": null, - "model_kwargs": null, - "model_name": null, - "openai_api_base": null, - "openai_api_key": null, - "stream": null, - "system_message": null, - "temperature": null - }, - "description": "Generates text using OpenAI LLMs.", - "display_name": "OpenAI", - "documentation": "", - "field_formatters": {}, - "field_order": [ - "max_tokens", - "model_kwargs", - "model_name", - "openai_api_base", - "openai_api_key", - "temperature", - "input_value", - "system_message", - "stream" - ], - "frozen": false, - "icon": "OpenAI", - "output_types": [], - "outputs": [ - { - "cache": true, - "display_name": "Text", - "method": "text_response", - "name": "text_output", - "selected": "Message", - "types": [ - "Message" - ], - "value": "__UNDEFINED__" - }, - { - "cache": true, - "display_name": "Language Model", - "method": "build_model", - "name": "model_output", - "selected": "LanguageModel", - "types": [ - "LanguageModel" - ], - "value": "__UNDEFINED__" - } - ], - "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 operator\nfrom functools import reduce\n\nfrom langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.constants import STREAM_INFO_TEXT\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.inputs import (\n BoolInput,\n DictInput,\n DropdownInput,\n FloatInput,\n IntInput,\n MessageInput,\n SecretStrInput,\n StrInput,\n)\nfrom langflow.schema.message import Message\nfrom langflow.template import Output\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n inputs = [\n MessageInput(name=\"input_value\", display_name=\"Input\"),\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 ),\n DictInput(name=\"model_kwargs\", display_name=\"Model Kwargs\", advanced=True),\n DictInput(\n name=\"output_schema\",\n is_list=True,\n display_name=\"Schema\",\n advanced=True,\n info=\"The schema for the Output of the model. You must pass the word JSON in the prompt. If left blank, JSON mode will be disabled.\",\n ),\n DropdownInput(\n name=\"model_name\", display_name=\"Model Name\", advanced=False, options=MODEL_NAMES, value=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. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"openai_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 FloatInput(name=\"temperature\", display_name=\"Temperature\", value=0.1),\n BoolInput(name=\"stream\", display_name=\"Stream\", info=STREAM_INFO_TEXT, advanced=True),\n StrInput(\n name=\"system_message\",\n display_name=\"System Message\",\n info=\"System message to pass to the model.\",\n advanced=True,\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 outputs = [\n Output(display_name=\"Text\", name=\"text_output\", method=\"text_response\"),\n Output(display_name=\"Language Model\", name=\"model_output\", method=\"build_model\"),\n ]\n\n def text_response(self) -> Message:\n input_value = self.input_value\n stream = self.stream\n system_message = self.system_message\n output = self.build_model()\n result = self.get_chat_result(output, stream, input_value, system_message)\n self.status = result\n return result\n\n def build_model(self) -> LanguageModel:\n # self.output_schea is a list of dictionaries\n # let's convert it to a dictionary\n output_schema_dict: dict[str, str] = reduce(operator.ior, self.output_schema or {}, {})\n openai_api_key = self.openai_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\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = bool(output_schema_dict)\n seed = self.seed\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs or {},\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature or 0.1,\n seed=seed,\n )\n if json_mode:\n output = output.with_structured_output(schema=output_schema_dict, method=\"json_mode\")\n\n return output\n" - }, - "input_value": { - "advanced": false, - "display_name": "Input", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Message" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "input_value", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "max_tokens": { - "advanced": true, - "display_name": "Max Tokens", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "max_tokens", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "model_kwargs": { - "advanced": true, - "display_name": "Model Kwargs", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "model_kwargs", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "model_name": { - "advanced": false, - "display_name": "Model Name", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": true, - "load_from_db": false, - "multiline": false, - "name": "model_name", - "options": [ - "gpt-4o", - "gpt-4-turbo", - "gpt-4-turbo-preview", - "gpt-3.5-turbo", - "gpt-3.5-turbo-0125" - ], - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "gpt-4o" - }, - "openai_api_base": { - "advanced": true, - "display_name": "OpenAI API Base", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "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.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "openai_api_base", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "openai_api_key": { - "advanced": false, - "display_name": "OpenAI API Key", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "The OpenAI API Key to use for the OpenAI model.", - "input_types": [], - "list": false, - "load_from_db": true, - "multiline": false, - "name": "openai_api_key", - "password": true, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "OPENAI_API_KEY" - }, - "stream": { - "advanced": true, - "display_name": "Stream", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "Stream the response from the model. Streaming works only in Chat.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "stream", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": false - }, - "system_message": { - "advanced": true, - "display_name": "System Message", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "System message to pass to the model.", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": true, - "name": "system_message", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": "" - }, - "temperature": { - "advanced": false, - "display_name": "Temperature", - "dynamic": false, - "fileTypes": [], - "file_path": "", - "info": "", - "input_types": [ - "Text" - ], - "list": false, - "load_from_db": false, - "multiline": false, - "name": "temperature", - "password": false, - "placeholder": "", - "required": false, - "show": true, - "title_case": false, - "type": "str", - "value": 0.1 - } - } - }, - "type": "OpenAIModel" - }, - "dragging": false, - "height": 565, - "id": "OpenAIModel-XawYB", - "position": { - "x": 4500.152018344182, - "y": 1027.7382026227656 - }, - "positionAbsolute": { - "x": 4500.152018344182, - "y": 1027.7382026227656 - }, - "selected": false, - "type": "genericNode", - "width": 384 - } - ], - "viewport": { - "x": -383.7251879618552, - "y": 69.19813933800037, - "zoom": 0.3105753483695743 - } - }, - "description": "The Prompt Chaining flow chains prompts with LLMs, refining outputs through iterative stages.", - "id": "85392e54-20f3-4ab5-a179-cb4bef16f639", - "is_component": false, - "last_tested_version": "1.0.0a0", - "name": "Prompt Chaining" -} \ No newline at end of file