refactor: Update ChatOutput to use MultilineInput for text input
Update the ChatOutput class in ChatOutput.py to use the MultilineInput class from the langflow library for text input. This change improves the usability and flexibility of the component, allowing for multiline messages to be passed as output.
This commit is contained in:
parent
b362ab0be6
commit
72649a034a
2 changed files with 4 additions and 14 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from langflow.base.io.chat import ChatComponent
|
||||
from langflow.field_typing import Text
|
||||
from langflow.inputs import BoolInput, DropdownInput, StrInput
|
||||
from langflow.inputs import BoolInput, DropdownInput, MultilineInput, StrInput
|
||||
from langflow.schema.message import Message
|
||||
from langflow.template import Output
|
||||
|
||||
|
|
@ -11,10 +10,9 @@ class ChatOutput(ChatComponent):
|
|||
icon = "ChatOutput"
|
||||
|
||||
inputs = [
|
||||
StrInput(
|
||||
MultilineInput(
|
||||
name="input_value",
|
||||
display_name="Text",
|
||||
multiline=True,
|
||||
info="Message to be passed as output.",
|
||||
input_types=["Text", "Message"],
|
||||
),
|
||||
|
|
@ -37,17 +35,9 @@ class ChatOutput(ChatComponent):
|
|||
),
|
||||
]
|
||||
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,
|
||||
|
|
@ -57,7 +47,5 @@ class ChatOutput(ChatComponent):
|
|||
)
|
||||
if self.session_id and isinstance(message, Message) and isinstance(message.text, str):
|
||||
self.store_message(message)
|
||||
self.message.value = message
|
||||
|
||||
self.status = message
|
||||
return message
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ from .inputs import (
|
|||
PromptInput,
|
||||
SecretStrInput,
|
||||
StrInput,
|
||||
MultilineInput,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
|
|
@ -22,4 +23,5 @@ __all__ = [
|
|||
"DropdownInput",
|
||||
"FileInput",
|
||||
"PromptInput",
|
||||
"MultilineInput",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue