mirror of https://github.com/langgenius/dify.git
feat(notion): Notion Database extracts Rows content `in row order` and appends `Row Page URL` (#22646)
Co-authored-by: Aurelius Huang <cm.huang@aftership.com>
This commit is contained in:
parent
8c6d87f08a
commit
ffddabde43
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import logging
|
||||
import operator
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import requests
|
||||
|
|
@ -130,13 +131,15 @@ class NotionExtractor(BaseExtractor):
|
|||
data[property_name] = value
|
||||
row_dict = {k: v for k, v in data.items() if v}
|
||||
row_content = ""
|
||||
for key, value in row_dict.items():
|
||||
for key, value in sorted(row_dict.items(), key=operator.itemgetter(0)):
|
||||
if isinstance(value, dict):
|
||||
value_dict = {k: v for k, v in value.items() if v}
|
||||
value_content = "".join(f"{k}:{v} " for k, v in value_dict.items())
|
||||
row_content = row_content + f"{key}:{value_content}\n"
|
||||
else:
|
||||
row_content = row_content + f"{key}:{value}\n"
|
||||
if "url" in result:
|
||||
row_content = row_content + f"Row Page URL:{result.get('url', '')}\n"
|
||||
database_content.append(row_content)
|
||||
|
||||
has_more = response_data.get("has_more", False)
|
||||
|
|
|
|||
Loading…
Reference in New Issue