fix: update chat components to make them backwards compatible (#2725)
* feat: Add conditional check for storing message in ChatOutput * refactor: Update store_message method in ChatComponent for backward compatibility * refactor: update input name to not collide with method name
This commit is contained in:
parent
e56a1c1e10
commit
7d3fac6f10
3 changed files with 27 additions and 4 deletions
|
|
@ -49,6 +49,19 @@ class ChatComponent(Component):
|
|||
},
|
||||
}
|
||||
|
||||
# Keep this method for backward compatibility
|
||||
def store_message(
|
||||
self,
|
||||
message: Message,
|
||||
) -> list[Message]:
|
||||
messages = store_message(
|
||||
message,
|
||||
flow_id=self.graph.flow_id,
|
||||
)
|
||||
|
||||
self.status = messages
|
||||
return messages
|
||||
|
||||
def build_with_data(
|
||||
self,
|
||||
sender: Optional[str] = "User",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class ChatInput(ChatComponent):
|
|||
info="Message to be passed as input.",
|
||||
),
|
||||
BoolInput(
|
||||
name="store_message",
|
||||
name="should_store_message",
|
||||
display_name="Store Messages",
|
||||
info="Store the message in the history.",
|
||||
value=True,
|
||||
|
|
@ -66,7 +66,12 @@ class ChatInput(ChatComponent):
|
|||
files=self.files,
|
||||
)
|
||||
|
||||
if self.session_id and isinstance(message, Message) and isinstance(message.text, str):
|
||||
if (
|
||||
self.session_id
|
||||
and isinstance(message, Message)
|
||||
and isinstance(message.text, str)
|
||||
and self.should_store_message
|
||||
):
|
||||
store_message(
|
||||
message,
|
||||
flow_id=self.graph.flow_id,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ChatOutput(ChatComponent):
|
|||
info="Message to be passed as output.",
|
||||
),
|
||||
BoolInput(
|
||||
name="store_message",
|
||||
name="should_store_message",
|
||||
display_name="Store Messages",
|
||||
info="Store the message in the history.",
|
||||
value=True,
|
||||
|
|
@ -57,7 +57,12 @@ class ChatOutput(ChatComponent):
|
|||
sender_name=self.sender_name,
|
||||
session_id=self.session_id,
|
||||
)
|
||||
if self.session_id and isinstance(message, Message) and isinstance(message.text, str):
|
||||
if (
|
||||
self.session_id
|
||||
and isinstance(message, Message)
|
||||
and isinstance(message.text, str)
|
||||
and self.should_store_message
|
||||
):
|
||||
store_message(
|
||||
message,
|
||||
flow_id=self.graph.flow_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue