refactor: Improve advanced options in ChatComponent, URLComponent, and MessageHistoryComponent

This commit is contained in:
Rodrigo 2024-06-10 21:27:47 -03:00
commit 49bdbef548
5 changed files with 10 additions and 7 deletions

View file

@ -23,7 +23,7 @@ class ChatComponent(CustomComponent):
"display_name": "Sender Type", "display_name": "Sender Type",
"advanced": True, "advanced": True,
}, },
"sender_name": {"display_name": "Sender Name"}, "sender_name": {"display_name": "Sender Name", "advanced": True},
"session_id": { "session_id": {
"display_name": "Session ID", "display_name": "Session ID",
"info": "If provided, the message will be stored in the memory.", "info": "If provided, the message will be stored in the memory.",

View file

@ -20,7 +20,7 @@ class URLComponent(CustomComponent):
self, self,
urls: list[str], urls: list[str],
) -> list[Record]: ) -> list[Record]:
loader = WebBaseLoader(web_paths=urls) loader = WebBaseLoader(web_paths=[url for url in urls if url])
docs = loader.load() docs = loader.load()
records = self.to_records(docs) records = self.to_records(docs)
self.status = records self.status = records

View file

@ -6,25 +6,27 @@ from langflow.schema import Record
class MessageHistoryComponent(CustomComponent): class MessageHistoryComponent(CustomComponent):
display_name = "Message History" display_name = "Memory"
description = "Retrieves stored chat messages given a specific Session ID." description = "Retrieves stored chat messages."
beta: bool = True
def build_config(self): def build_config(self):
return { return {
"sender": { "sender": {
"options": ["Machine", "User", "Machine and User"], "options": ["Machine", "User", "Machine and User"],
"display_name": "Sender Type", "display_name": "Sender Type",
"advanced": True,
}, },
"sender_name": {"display_name": "Sender Name", "advanced": True}, "sender_name": {"display_name": "Sender Name", "advanced": True},
"n_messages": { "n_messages": {
"display_name": "Number of Messages", "display_name": "Number of Messages",
"info": "Number of messages to retrieve.", "info": "Number of messages to retrieve.",
"advanced": True,
}, },
"session_id": { "session_id": {
"display_name": "Session ID", "display_name": "Session ID",
"info": "Session ID of the chat history.", "info": "Session ID of the chat history.",
"input_types": ["Text"], "input_types": ["Text"],
"advanced": True,
}, },
"order": { "order": {
"options": ["Ascending", "Descending"], "options": ["Ascending", "Descending"],
@ -39,7 +41,7 @@ class MessageHistoryComponent(CustomComponent):
sender: Optional[str] = "Machine and User", sender: Optional[str] = "Machine and User",
sender_name: Optional[str] = None, sender_name: Optional[str] = None,
session_id: Optional[str] = None, session_id: Optional[str] = None,
n_messages: int = 5, n_messages: int = 100,
order: Optional[str] = "Descending", order: Optional[str] = "Descending",
) -> List[Record]: ) -> List[Record]:
order = "DESC" if order == "Descending" else "ASC" order = "DESC" if order == "Descending" else "ASC"

View file

@ -17,6 +17,7 @@ class RecordsToTextComponent(CustomComponent):
"template": { "template": {
"display_name": "Template", "display_name": "Template",
"info": "The template to use for formatting the records. It can contain the keys {text}, {data} or any other key in the Record.", "info": "The template to use for formatting the records. It can contain the keys {text}, {data} or any other key in the Record.",
"multiline": True,
}, },
} }

View file

@ -65,7 +65,7 @@ export default function SelectionMenu({
className={`${ className={`${
disable disable
? "flex h-full w-full cursor-not-allowed items-center justify-between text-sm text-muted-foreground" ? "flex h-full w-full cursor-not-allowed items-center justify-between text-sm text-muted-foreground"
: "flex h-full w-full items-center justify-between text-sm hover:text-indigo-500" : "flex h-full w-full items-center justify-between text-sm"
}`} }`}
onClick={onClick} onClick={onClick}
disabled={disable} disabled={disable}