From a81e81b0fc5ad4f43317bd0ea4000815d15d54f3 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Wed, 12 Jun 2024 16:14:09 -0300 Subject: [PATCH] refactor: Update ChatInput inputs to use specific input classes Update the inputs of the ChatInput class in ChatInput.py to use specific input classes such as StrInput and DropdownInput. This change improves the organization and separation of concerns in the codebase, making it easier to understand and maintain. --- .../base/langflow/components/inputs/ChatInput.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/backend/base/langflow/components/inputs/ChatInput.py b/src/backend/base/langflow/components/inputs/ChatInput.py index 531e4fd99..344d868b9 100644 --- a/src/backend/base/langflow/components/inputs/ChatInput.py +++ b/src/backend/base/langflow/components/inputs/ChatInput.py @@ -1,7 +1,8 @@ from langflow.base.io.chat import ChatComponent from langflow.field_typing import Text +from langflow.inputs import DropdownInput, StrInput from langflow.schema.message import Message -from langflow.template import Input, Output +from langflow.template import Output class ChatInput(ChatComponent): @@ -10,25 +11,23 @@ class ChatInput(ChatComponent): icon = "ChatInput" inputs = [ - Input( + StrInput( name="input_value", - type=str, display_name="Text", multiline=True, input_types=[], info="Message to be passed as input.", ), - Input( + DropdownInput( name="sender", - type=str, display_name="Sender Type", options=["Machine", "User"], value="User", info="Type of sender.", advanced=True, ), - Input(name="sender_name", type=str, display_name="Sender Name", info="Name of the sender.", value="User"), - Input( + StrInput(name="sender_name", type=str, display_name="Sender Name", info="Name of the sender.", value="User"), + StrInput( name="session_id", type=str, display_name="Session ID", info="Session ID for the message.", advanced=True ), ] @@ -40,8 +39,7 @@ class ChatInput(ChatComponent): def text_response(self) -> Text: result = self.input_value if self.session_id: - message = self.message_response() - self.store_message(message) + self.message_response() self.status = result return result