From a250335485676ec9fe316db83fe88d4109bb72a2 Mon Sep 17 00:00:00 2001 From: jyong <718720800@qq.com> Date: Tue, 24 Dec 2024 15:26:10 +0800 Subject: [PATCH 1/2] notion and website import fix --- .../entities/knowledge_entities/knowledge_entities.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/services/entities/knowledge_entities/knowledge_entities.py b/api/services/entities/knowledge_entities/knowledge_entities.py index c3bf7c0a7ee796..8d6a246b6428d0 100644 --- a/api/services/entities/knowledge_entities/knowledge_entities.py +++ b/api/services/entities/knowledge_entities/knowledge_entities.py @@ -16,10 +16,16 @@ class ParentMode(str, Enum): PARAGRAPH = "paragraph" +class NotionIcon(BaseModel): + type: str + url: Optional[str] = None + emoji: Optional[str] = None + + class NotionPage(BaseModel): page_id: str page_name: str - page_icon: Optional[str] + page_icon: Optional[NotionIcon] = None type: str From 98cd57f1036ad14e91d75b5efad65150a8c3eee0 Mon Sep 17 00:00:00 2001 From: jyong <718720800@qq.com> Date: Tue, 24 Dec 2024 15:30:39 +0800 Subject: [PATCH 2/2] notion and website import fix --- api/services/dataset_service.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py index 7f2a82425667e7..6ca1ed9225c1dd 100644 --- a/api/services/dataset_service.py +++ b/api/services/dataset_service.py @@ -737,10 +737,10 @@ def save_document_with_dataset_id( elif knowledge_config.data_source.info_list.data_source_type == "notion_import": notion_info_list = knowledge_config.data_source.info_list.notion_info_list for notion_info in notion_info_list: - count = count + len(notion_info["pages"]) + count = count + len(notion_info.pages) elif knowledge_config.data_source.info_list.data_source_type == "website_crawl": website_info = knowledge_config.data_source.info_list.website_info_list - count = len(website_info["urls"]) + count = len(website_info.urls) batch_upload_limit = int(dify_config.BATCH_UPLOAD_LIMIT) if count > batch_upload_limit: raise ValueError(f"You have reached the batch upload limit of {batch_upload_limit}.") @@ -898,7 +898,7 @@ def save_document_with_dataset_id( data_source_info = { "notion_workspace_id": workspace_id, "notion_page_id": page.page_id, - "notion_page_icon": page.page_icon, + "notion_page_icon": page.page_icon.model_dump(), "type": page.type, } document = DocumentService.build_document( @@ -1141,7 +1141,7 @@ def save_document_without_dataset_id(tenant_id: str, knowledge_config: Knowledge elif knowledge_config.data_source.info_list.data_source_type == "notion_import": notion_info_list = knowledge_config.data_source.info_list.notion_info_list for notion_info in notion_info_list: - count = count + len(notion_info["pages"]) + count = count + len(notion_info.pages) elif knowledge_config.data_source.info_list.data_source_type == "website_crawl": website_info = knowledge_config.data_source.info_list.website_info_list count = len(website_info.urls)