From 6b286b02e593fe250606f2fdcf7c894675274571 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 22 Feb 2024 14:09:03 -0300 Subject: [PATCH] Add I/O components documentation --- docs/docs/components/io.mdx | 103 ++++++++++++++++++++++++++++++++++++ docs/sidebars.js | 1 + 2 files changed, 104 insertions(+) create mode 100644 docs/docs/components/io.mdx diff --git a/docs/docs/components/io.mdx b/docs/docs/components/io.mdx new file mode 100644 index 000000000..f41f0563a --- /dev/null +++ b/docs/docs/components/io.mdx @@ -0,0 +1,103 @@ +import Admonition from '@theme/Admonition'; + +# I/O + +## ChatInput + +This component is designed to get user input from the chat. + +**Params** + +- **sender:** specifies the sender type. Defaults to _`"User"`_. Options are _`"Machine"`_ and _`"User"`_. + +- **sender_name:** specifies the name of the sender. Defaults to _`"User"`_. + +- **message:** specifies the message text. It is a multiline text input. + +- **session_id:** specifies the session ID of the chat history. + +- **as_record:** if true, the message will be returned as a _`Record`_. Defaults to _`false`_. + + +

+ If _`as_record`_ is _`true`_ and the _`message`_ is a _`Record`_, the data of the _`Record`_ will be updated with the _`sender`_, _`sender_name`_, and _`session_id`_. +

+
+ +## ChatOutput + +This component is designed to send a message to the chat. + +**Params** + +- **sender:** specifies the sender type. Defaults to _`"Machine"`_. Options are _`"Machine"`_ and _`"User"`_. + +- **sender_name:** specifies the name of the sender. Defaults to _`"AI"`_. + +- **session_id:** specifies the session ID of the chat history. + +- **message:** specifies the message text. + +- **as_record:** if true, the message will be returned as a _`Record`_. Defaults to _`false`_. + + +

+ If _`as_record`_ is _`true`_ and the _`message`_ is a _`Record`_, the data of the _`Record`_ will be updated with the _`sender`_, _`sender_name`_, and _`session_id`_. +

+
+## StoreMessages + +This component is designed to store messages in a structured format. It can store messages provided directly as records or construct records from provided texts and metadata. + +**Params** + +- **records:** (Optional) Specifies the list of records to store. Each `Record` should contain the keys `'sender'`, `'sender_name'`, and `'session_id'`. If not provided, `texts` must be used along with `session_id`, `sender`, and `sender_name` to construct the records. + +- **texts:** (Optional) Specifies the list of text messages to store. If `records` is not provided, `texts` must be provided along with `session_id`, `sender`, and `sender_name`. + +- **session_id:** (Optional) Specifies the session ID associated with the messages. Required if `records` is not provided and `texts` are used. + +- **sender:** (Optional) Specifies the identifier of the sender. Required if `records` is not provided and `texts` are used. + +- **sender_name:** (Optional) Specifies the name of the sender. Required if `records` is not provided and `texts` are used. + + +

+ The component prioritizes the use of `records` for storing messages. If `records` are not provided, it requires `texts`, `session_id`, `sender`, and `sender_name` to construct and store records. Ensure that either `records` or the combination of `texts`, `session_id`, `sender`, and `sender_name` is provided. +

+
+ +## MessageHistory + +This component is designed to retrieve stored messages based on various filters such as sender type, sender name, and session ID. It allows for a flexible retrieval of chat history, providing insights into past interactions. + +**Params** + +- **sender:** (Optional) Specifies the type of the sender. Options are _`"Machine"`_ or _`"User"`_. Filters the messages by the type of sender. + +- **sender_name:** (Optional) Specifies the name of the sender. Filters the messages by the name of the sender. + +- **session_id:** (Optional) Specifies the session ID of the chat history. Filters the messages belonging to a specific session. + +- **n_messages:** Specifies the number of messages to retrieve. Defaults to _`5`_. Determines how many recent messages from the chat history to fetch. + + +

+ The component retrieves messages based on the provided criteria. If no specific criteria are provided, it will return the most recent messages up to the specified limit. This component can be used to review past interactions and analyze the flow of conversations. +

+
+ + +## TextInput + +This component is designed for simple text input, allowing users to pass textual data to subsequent components in the workflow. It's particularly useful for scenarios where a brief user input is required to initiate or influence the process flow. + +**Params** + +- **value:** Specifies the text input value. This is where the user can input the text data that will be passed to the next component in the sequence. If no value is provided, it defaults to an empty string. + + +

+ The `TextInput` component serves as a straightforward means for capturing user input. It ensures that textual data can be seamlessly integrated into the Langflow's component-based processing pipeline, fostering interactivity within automated workflows. +

+
diff --git a/docs/sidebars.js b/docs/sidebars.js index f500d7728..0309f2d9a 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -37,6 +37,7 @@ module.exports = { "components/chains", "components/custom", "components/embeddings", + "components/io", "components/llms", "components/loaders", "components/memories",