Refactor ChatInput and ChatOutput classes to remove 'as_record' parameter
This commit is contained in:
parent
160aa47e26
commit
3f9790a420
2 changed files with 17 additions and 33 deletions
|
|
@ -25,10 +25,6 @@ class ChatInput(CustomComponent):
|
|||
"display_name": "Session ID",
|
||||
"info": "Session ID of the chat history.",
|
||||
},
|
||||
"as_record": {
|
||||
"display_name": "As Record",
|
||||
"info": "If true, the message will be returned as a Record.",
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
@ -36,18 +32,15 @@ class ChatInput(CustomComponent):
|
|||
sender: Optional[str] = "User",
|
||||
sender_name: Optional[str] = "User",
|
||||
message: Optional[str] = None,
|
||||
as_record: Optional[bool] = False,
|
||||
session_id: Optional[str] = None,
|
||||
) -> Union[Text, Record]:
|
||||
self.status = message
|
||||
if as_record:
|
||||
if isinstance(message, Record):
|
||||
# Update the data of the record
|
||||
message.data["sender"] = sender
|
||||
message.data["sender_name"] = sender_name
|
||||
message.data["session_id"] = session_id
|
||||
return message
|
||||
return Record(
|
||||
) -> Record:
|
||||
if isinstance(message, Record):
|
||||
# Update the data of the record
|
||||
message.data["sender"] = sender
|
||||
message.data["sender_name"] = sender_name
|
||||
message.data["session_id"] = session_id
|
||||
else:
|
||||
message = Record(
|
||||
text=message,
|
||||
data={
|
||||
"sender": sender,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from typing import Optional, Union
|
||||
from typing import Optional
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import Text
|
||||
from langflow.schema import Record
|
||||
|
||||
|
||||
|
|
@ -28,10 +27,6 @@ class ChatOutput(CustomComponent):
|
|||
"info": "Session ID of the chat history.",
|
||||
"input_types": ["Text"],
|
||||
},
|
||||
"as_record": {
|
||||
"display_name": "As Record",
|
||||
"info": "If true, the message will be returned as a Record.",
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
@ -40,18 +35,14 @@ class ChatOutput(CustomComponent):
|
|||
sender_name: Optional[str] = "AI",
|
||||
session_id: Optional[str] = None,
|
||||
message: Optional[str] = None,
|
||||
as_record: Optional[bool] = False,
|
||||
) -> Union[Text, Record]:
|
||||
self.status = message
|
||||
if as_record:
|
||||
if isinstance(message, Record):
|
||||
# Update the data of the record
|
||||
message.data["sender"] = sender
|
||||
message.data["sender_name"] = sender_name
|
||||
message.data["session_id"] = session_id
|
||||
|
||||
return message
|
||||
return Record(
|
||||
) -> Record:
|
||||
if isinstance(message, Record):
|
||||
# Update the data of the record
|
||||
message.data["sender"] = sender
|
||||
message.data["sender_name"] = sender_name
|
||||
message.data["session_id"] = session_id
|
||||
else:
|
||||
message = Record(
|
||||
text=message,
|
||||
data={
|
||||
"sender": sender,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue