rename Record to Data
This commit is contained in:
parent
a562ae5b0b
commit
1d0056f4fc
142 changed files with 819 additions and 869 deletions
|
|
@ -24,15 +24,15 @@ Provide the session ID to clear its message history.
|
|||
|
||||
---
|
||||
|
||||
## Extract Key From Record
|
||||
## Extract Key From Data
|
||||
|
||||
This component extracts specified keys from a record.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- **Record:**
|
||||
- **Data:**
|
||||
|
||||
- **Display Name:** Record
|
||||
- **Display Name:** Data
|
||||
- **Info:** The record from which to extract keys.
|
||||
|
||||
- **Keys:**
|
||||
|
|
@ -138,9 +138,9 @@ This component generates a notification.
|
|||
- **Display Name:** Name
|
||||
- **Info:** The notification's name.
|
||||
|
||||
- **Record:**
|
||||
- **Data:**
|
||||
|
||||
- **Display Name:** Record
|
||||
- **Display Name:** Data
|
||||
- **Info:** Optionally, a record to store in the notification.
|
||||
|
||||
- **Append:**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ This component retrieves stored chat messages based on a specific session ID.
|
|||
- **Number of messages:** Number of messages to retrieve.
|
||||
- **Session ID:** The session ID of the chat history.
|
||||
- **Order:** Choose the message order, either "Ascending" or "Descending".
|
||||
- **Record template:** (Optional) Template to convert a record to text. If left empty, the system dynamically sets it to the record's text key.
|
||||
- **Data template:** (Optional) Template to convert a record to text. If left empty, the system dynamically sets it to the record's text key.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -124,5 +124,5 @@ Update a record with text-based key/value pairs, similar to updating a Python di
|
|||
|
||||
#### Parameters
|
||||
|
||||
- **Record:** The record to update.
|
||||
- **Data:** The record to update.
|
||||
- **New data:** The new data to update the record with.
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ They also dynamically change the Playground and can be renamed to facilitate bui
|
|||
|
||||
## Inputs
|
||||
|
||||
Inputs are components used to define where data enters your flow. They can receive data from the user, a database, or any other source that can be converted to Text or Record.
|
||||
Inputs are components used to define where data enters your flow. They can receive data from the user, a database, or any other source that can be converted to Text or Data.
|
||||
|
||||
The difference between Chat Input and other Input components is the output format, the number of configurable fields, and the way they are displayed in the Playground.
|
||||
|
||||
Chat Input components can output `Text` or `Record`. When you want to pass the sender name or sender to the next component, use the `Record` output. To pass only the message, use the `Text` output, useful when saving the message to a database or memory system like Zep.
|
||||
Chat Input components can output `Text` or `Data`. When you want to pass the sender name or sender to the next component, use the `Data` output. To pass only the message, use the `Text` output, useful when saving the message to a database or memory system like Zep.
|
||||
|
||||
You can find out more about Chat Input and other Inputs [here](#chat-input).
|
||||
|
||||
|
|
@ -38,8 +38,8 @@ This component collects user input from the chat.
|
|||
|
||||
<Admonition type="note" title="Note">
|
||||
<p>
|
||||
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`.
|
||||
If `As Data` is `true` and the `Message` is a `Data`, the data of the `Data`
|
||||
will be updated with the `Sender`, `Sender Name`, and `Session ID`.
|
||||
</p>
|
||||
</Admonition>
|
||||
|
||||
|
|
@ -70,11 +70,11 @@ The **Text Input** component adds an **Input** field on the Playground. This ena
|
|||
**Parameters**
|
||||
|
||||
- **Value:** Specifies the text input value. This is where the user inputs text data that will be passed to the next component in the sequence. If no value is provided, it defaults to an empty string.
|
||||
- **Record Template:** Specifies how a `Record` should be converted into `Text`.
|
||||
- **Data Template:** Specifies how a `Data` should be converted into `Text`.
|
||||
|
||||
The **Record Template** field is used to specify how a `Record` should be converted into `Text`. This is particularly useful when you want to extract specific information from a `Record` and pass it as text to the next component in the sequence.
|
||||
The **Data Template** field is used to specify how a `Data` should be converted into `Text`. This is particularly useful when you want to extract specific information from a `Data` and pass it as text to the next component in the sequence.
|
||||
|
||||
For example, if you have a `Record` with the following structure:
|
||||
For example, if you have a `Data` with the following structure:
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
@ -84,9 +84,9 @@ For example, if you have a `Record` with the following structure:
|
|||
}
|
||||
```
|
||||
|
||||
A template with `Name: {name}, Age: {age}` will convert the `Record` into a text string of `Name: John Doe, Age: 30`.
|
||||
A template with `Name: {name}, Age: {age}` will convert the `Data` into a text string of `Name: John Doe, Age: 30`.
|
||||
|
||||
If you pass more than one `Record`, the text will be concatenated with a new line separator.
|
||||
If you pass more than one `Data`, the text will be concatenated with a new line separator.
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
@ -112,8 +112,8 @@ This component sends a message to the chat.
|
|||
|
||||
<Admonition type="note" title="Note">
|
||||
<p>
|
||||
If `As Record` is `true` and the `Message` is a `Record`, the data in the
|
||||
`Record` is updated with the `Sender`, `Sender Name`, and `Session ID`.
|
||||
If `As Data` is `true` and the `Message` is a `Data`, the data in the `Data`
|
||||
is updated with the `Sender`, `Sender Name`, and `Session ID`.
|
||||
</p>
|
||||
</Admonition>
|
||||
|
||||
|
|
@ -154,4 +154,5 @@ The `PromptTemplate` component enables users to create prompts and define variab
|
|||
|
||||
After defining a variable in the prompt template, it acts as its own component input. See [Prompt Customization](../administration/prompt-customization) for more details.
|
||||
|
||||
- **template:** The template used to format an individual request.
|
||||
- **template:** The template used to format an individual request.import Admonition from "@theme/Admonition";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
# Text and Record
|
||||
# Text and Data
|
||||
|
||||
In Langflow 1.0, we added two main input and output types: `Text` and `Record`.
|
||||
In Langflow 1.0, we added two main input and output types: `Text` and `Data`.
|
||||
|
||||
`Text` is a simple string input and output type, while `Record` is a structure very similar to a dictionary in Python. It is a key-value pair data structure.
|
||||
`Text` is a simple string input and output type, while `Data` is a structure very similar to a dictionary in Python. It is a key-value pair data structure.
|
||||
|
||||
We've created a few components to help you work with these types. Let's see how a few of them work.
|
||||
|
||||
## Records To Text
|
||||
|
||||
This is a component that takes in Records and outputs a `Text`. It does this using a template string and concatenating the values of the `Record`, one per line.
|
||||
This is a component that takes in Records and outputs a `Text`. It does this using a template string and concatenating the values of the `Data`, one per line.
|
||||
|
||||
If we have the following Records:
|
||||
|
||||
|
|
@ -32,13 +32,13 @@ Alice: Hello!
|
|||
John: Hi!
|
||||
```
|
||||
|
||||
## Create Record
|
||||
## Create Data
|
||||
|
||||
This component allows you to create a `Record` from a number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15). Once you've picked that number you'll need to write the name of the Key and can pass `Text` values from other components to it.
|
||||
This component allows you to create a `Data` from a number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15). Once you've picked that number you'll need to write the name of the Key and can pass `Text` values from other components to it.
|
||||
|
||||
## Documents To Records
|
||||
|
||||
This component takes in a LangChain `Document` and outputs a `Record`. It does this by extracting the `page_content` and the `metadata` from the `Document` and adding them to the `Record` as text and data respectively.
|
||||
This component takes in a LangChain `Document` and outputs a `Data`. It does this by extracting the `page_content` and the `metadata` from the `Document` and adding them to the `Data` as text and data respectively.
|
||||
|
||||
## Why is this useful?
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,18 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
|
|||
import ReactPlayer from "react-player";
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Create Record
|
||||
# Create Data
|
||||
|
||||
In Langflow, a `Record` has a structure very similar to a Python dictionary. It is a key-value pair data structure.
|
||||
In Langflow, a `Data` has a structure very similar to a Python dictionary. It is a key-value pair data structure.
|
||||
|
||||
The **Create Record** component allows you to dynamically create a `Record` from a specified number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15 😅). Once you've chosen the number of `Records`, add keys and fill up values, or pass on values from other components to the component using the input handles.
|
||||
The **Create Data** component allows you to dynamically create a `Data` from a specified number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15 😅). Once you've chosen the number of `Records`, add keys and fill up values, or pass on values from other components to the component using the input handles.
|
||||
|
||||
<div
|
||||
style={{ marginBottom: "20px", display: "flex", justifyContent: "center" }}
|
||||
>
|
||||
<ReactPlayer playing controls url="/videos/create_record.mp4" />
|
||||
</div>
|
||||
import ThemedImage from "@theme/ThemedImage"; import useBaseUrl from
|
||||
"@docusaurus/useBaseUrl"; import ZoomableImage from
|
||||
"/src/theme/ZoomableImage.js"; import ReactPlayer from "react-player"; import
|
||||
Admonition from "@theme/Admonition";
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import requests
|
|||
from typing import Dict
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.schema import Record
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
class NotionDatabaseProperties(CustomComponent):
|
||||
|
|
@ -61,7 +61,7 @@ class NotionDatabaseProperties(CustomComponent):
|
|||
self,
|
||||
database_id: str,
|
||||
notion_secret: str,
|
||||
) -> Record:
|
||||
) -> Data:
|
||||
url = f"https://api.notion.com/v1/databases/{database_id}"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {notion_secret}",
|
||||
|
|
@ -74,7 +74,7 @@ class NotionDatabaseProperties(CustomComponent):
|
|||
data = response.json()
|
||||
properties = data.get("properties", {})
|
||||
|
||||
record = Record(text=str(response.json()), data=properties)
|
||||
record = Data(text=str(response.json()), data=properties)
|
||||
self.status = f"Retrieved {len(properties)} properties from the Notion database.\n {record.text}"
|
||||
return record
|
||||
```
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import requests
|
|||
import json
|
||||
from typing import Dict, Any, List
|
||||
from langflow.custom import CustomComponent
|
||||
from langflow.schema import Record
|
||||
from langflow.schema import Data
|
||||
|
||||
class NotionListPages(CustomComponent):
|
||||
display_name = "List Pages [Notion]"
|
||||
|
|
@ -83,7 +83,7 @@ class NotionListPages(CustomComponent):
|
|||
notion_secret: str,
|
||||
database_id: str,
|
||||
query_payload: str = "{}",
|
||||
) -> List[Record]:
|
||||
) -> List[Data]:
|
||||
try:
|
||||
query_data = json.loads(query_payload)
|
||||
filter_obj = query_data.get("filter")
|
||||
|
|
@ -127,14 +127,14 @@ class NotionListPages(CustomComponent):
|
|||
)
|
||||
|
||||
combined_text += text
|
||||
records.append(Record(text=text, data=page_data))
|
||||
records.append(Data(text=text, data=page_data))
|
||||
|
||||
self.status = combined_text.strip()
|
||||
return records
|
||||
|
||||
except Exception as e:
|
||||
self.status = f"An error occurred: {str(e)}"
|
||||
return [Record(text=self.status, data=[])]
|
||||
return [Data(text=self.status, data=[])]
|
||||
```
|
||||
|
||||
<Admonition type="info" title="Example Usage">
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import requests
|
|||
from typing import List
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.schema import Record
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
class NotionUserList(CustomComponent):
|
||||
|
|
@ -52,7 +52,7 @@ class NotionUserList(CustomComponent):
|
|||
def build(
|
||||
self,
|
||||
notion_secret: str,
|
||||
) -> List[Record]:
|
||||
) -> List[Data]:
|
||||
url = "https://api.notion.com/v1/users"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {notion_secret}",
|
||||
|
|
@ -84,7 +84,7 @@ class NotionUserList(CustomComponent):
|
|||
output += f"{key.replace('_', ' ').title()}: {value}\n"
|
||||
output += "________________________\n"
|
||||
|
||||
record = Record(text=output, data=record_data)
|
||||
record = Data(text=output, data=record_data)
|
||||
records.append(record)
|
||||
|
||||
self.status = "\n".join(record.text for record in records)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import requests
|
|||
from typing import Dict, Any
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.schema import Record
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
class NotionPageContent(CustomComponent):
|
||||
|
|
@ -64,7 +64,7 @@ class NotionPageContent(CustomComponent):
|
|||
self,
|
||||
page_id: str,
|
||||
notion_secret: str,
|
||||
) -> Record:
|
||||
) -> Data:
|
||||
blocks_url = f"https://api.notion.com/v1/blocks/{page_id}/children?page_size=100"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {notion_secret}",
|
||||
|
|
@ -80,7 +80,7 @@ class NotionPageContent(CustomComponent):
|
|||
content = self.parse_blocks(blocks_data["results"])
|
||||
|
||||
self.status = content
|
||||
return Record(data={"content": content}, text=content)
|
||||
return Data(data={"content": content}, text=content)
|
||||
|
||||
def parse_blocks(self, blocks: list) -> str:
|
||||
content = ""
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import requests
|
|||
from typing import Dict, Any
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.schema import Record
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
class NotionPageUpdate(CustomComponent):
|
||||
|
|
@ -61,7 +61,7 @@ class NotionPageUpdate(CustomComponent):
|
|||
page_id: str,
|
||||
properties: str,
|
||||
notion_secret: str,
|
||||
) -> Record:
|
||||
) -> Data:
|
||||
url = f"https://api.notion.com/v1/pages/{page_id}"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {notion_secret}",
|
||||
|
|
@ -88,7 +88,7 @@ class NotionPageUpdate(CustomComponent):
|
|||
output += f"{prop_name}: {prop_value}\n"
|
||||
|
||||
self.status = output
|
||||
return Record(data=updated_page)
|
||||
return Data(data=updated_page)
|
||||
```
|
||||
|
||||
Let's break down the key parts of this component:
|
||||
|
|
@ -99,7 +99,7 @@ Let's break down the key parts of this component:
|
|||
|
||||
- The component interacts with the Notion API to update the page properties. It constructs the API URL, headers, and request data based on the provided parameters.
|
||||
|
||||
- The processed data is returned as a `Record` object, which can be connected to other components in the Langflow flow. The `Record` object contains the updated page data.
|
||||
- The processed data is returned as a `Data` object, which can be connected to other components in the Langflow flow. The `Data` object contains the updated page data.
|
||||
|
||||
- The component also stores the updated page properties in the `status` attribute for logging and debugging purposes.
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ To use the `NotionSearch` component in a Langflow flow, follow these steps:
|
|||
import requests
|
||||
from typing import Dict, Any, List
|
||||
from langflow.custom import CustomComponent
|
||||
from langflow.schema import Record
|
||||
from langflow.schema import Data
|
||||
|
||||
class NotionSearch(CustomComponent):
|
||||
display_name = "Search Notion"
|
||||
|
|
@ -88,7 +88,7 @@ class NotionSearch(CustomComponent):
|
|||
query: str = "",
|
||||
filter_value: str = "page",
|
||||
sort_direction: str = "descending",
|
||||
) -> List[Record]:
|
||||
) -> List[Data]:
|
||||
try:
|
||||
url = "https://api.notion.com/v1/search"
|
||||
headers = {
|
||||
|
|
@ -135,14 +135,14 @@ class NotionSearch(CustomComponent):
|
|||
|
||||
text += f"type: {result['object']}\nlast_edited_time: {result['last_edited_time']}\n\n"
|
||||
combined_text += text
|
||||
records.append(Record(text=text, data=result_data))
|
||||
records.append(Data(text=text, data=result_data))
|
||||
|
||||
self.status = combined_text
|
||||
return records
|
||||
|
||||
except Exception as e:
|
||||
self.status = f"An error occurred: {str(e)}"
|
||||
return [Record(text=self.status, data=[])]
|
||||
return [Data(text=self.status, data=[])]
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ We have a special channel in our Discord server dedicated to Langflow 1.0 migrat
|
|||
- Continued support for LangChain and new support for multiple frameworks
|
||||
- Redesigned sidebar and customizable interaction panel
|
||||
- New Native Categories and Components
|
||||
- Improved user experience with Text and Record modes
|
||||
- Improved user experience with Text and Data modes
|
||||
- CustomComponent for all components
|
||||
- Compatibility with previous versions using Runnable Executor
|
||||
- Multiple flows in the canvas
|
||||
|
|
@ -58,11 +58,11 @@ Langflow 1.0 introduces many new native categories, including Inputs, Outputs, H
|
|||
|
||||
**Guide coming soon**
|
||||
|
||||
## New Way of Using Langflow: Text and Record (and more to come)
|
||||
## New Way of Using Langflow: Text and Data (and more to come)
|
||||
|
||||
With the introduction of Text and Record types connections between Components are more intuitive and easier to understand. This is the first step in a series of improvements to the way you interact with Langflow. Learn how to use Text, and Record and how they help you build better flows.
|
||||
With the introduction of Text and Data types connections between Components are more intuitive and easier to understand. This is the first step in a series of improvements to the way you interact with Langflow. Learn how to use Text, and Data and how they help you build better flows.
|
||||
|
||||
[Learn more about Text and Record](../components/text-and-record)
|
||||
[Learn more about Text and Data](../components/text-and-record)
|
||||
|
||||
## CustomComponent for All Components
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue