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.
This commit is contained in:
ogabrielluiz 2024-06-12 16:14:09 -03:00
commit a81e81b0fc

View file

@ -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