rename Record to Data
This commit is contained in:
parent
a562ae5b0b
commit
1d0056f4fc
142 changed files with 819 additions and 869 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue