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:
Rodrigo 2024-06-12 17:52:12 -03:00
commit 2a1c6e76a5

View file

@ -1,5 +1,4 @@
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 Output
@ -26,23 +25,22 @@ class ChatInput(ChatComponent):
info="Type of sender.",
advanced=True,
),
StrInput(name="sender_name", type=str, display_name="Sender Name", info="Name of the sender.", value="User"),
StrInput(
name="sender_name",
type=str,
display_name="Sender Name",
info="Name of the sender.",
value="User",
advanced=True,
),
StrInput(
name="session_id", type=str, display_name="Session ID", info="Session ID for the message.", advanced=True
),
]
outputs = [
Output(display_name="Text", name="text", method="text_response"),
Output(display_name="Message", name="message", method="message_response"),
]
def text_response(self) -> Text:
result = self.input_value
if self.session_id:
self.message_response()
self.status = result
return result
def message_response(self) -> Message:
message = Message(
text=self.input_value,