Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Feat/update notion preview (#29345)

Jyongae4a9040dfd3
diff --git a/api/controllers/console/datasets/data_source.py b/api/controllers/console/datasets/data_source.py
index 01f268d94dc..95399fad135 100644
--- a/api/controllers/console/datasets/data_source.py
+++ b/api/controllers/console/datasets/data_source.py
@@ -218,14 +218,14 @@ class DataSourceNotionListApi(Resource):
@console_ns.route(
- "/notion/workspaces/<uuid:workspace_id>/pages/<uuid:page_id>/<string:page_type>/preview",
+ "/notion/pages/<uuid:page_id>/<string:page_type>/preview",
"/datasets/notion-indexing-estimate",
)
class DataSourceNotionApi(Resource):
@setup_required
@login_required
@account_initialization_required
- def get(self, workspace_id, page_id, page_type):
+ def get(self, page_id, page_type):
_, current_tenant_id = current_account_with_tenant()
credential_id = request.args.get("credential_id", default=None, type=str)
@@ -239,11 +239,10 @@ class DataSourceNotionApi(Resource):
plugin_id="langgenius/notion_datasource",
)
- workspace_id = str(workspace_id)
page_id = str(page_id)
extractor = NotionExtractor(
- notion_workspace_id=workspace_id,
+ notion_workspace_id="",
notion_obj_id=page_id,
notion_page_type=page_type,
notion_access_token=credential.get("integration_secret"),
diff --git a/api/core/rag/extractor/entity/extract_setting.py b/api/core/rag/extractor/entity/extract_setting.py
index c3bfbce98f3..0c420340732 100644
--- a/api/core/rag/extractor/entity/extract_setting.py
+++ b/api/core/rag/extractor/entity/extract_setting.py
@@ -10,7 +10,7 @@ class NotionInfo(BaseModel):
"""
credential_id: str | None = None
- notion_workspace_id: str
+ notion_workspace_id: str | None = ""
notion_obj_id: str
notion_page_type: str
document: Document | None = None
diff --git a/api/core/rag/extractor/extract_processor.py b/api/core/rag/extractor/extract_processor.py
index 0f62f9c4b65..013c287248d 100644
--- a/api/core/rag/extractor/extract_processor.py
+++ b/api/core/rag/extractor/extract_processor.py
@@ -166,7 +166,7 @@ class ExtractProcessor:
elif extract_setting.datasource_type == DatasourceType.NOTION:
assert extract_setting.notion_info is not None, "notion_info is required"
extractor = NotionExtractor(
- notion_workspace_id=extract_setting.notion_info.notion_workspace_id,
+ notion_workspace_id=extract_setting.notion_info.notion_workspace_id or "",
notion_obj_id=extract_setting.notion_info.notion_obj_id,
notion_page_type=extract_setting.notion_info.notion_page_type,
document_model=extract_setting.notion_info.document,
diff --git a/web/app/components/datasets/create/notion-page-preview/index.tsx b/web/app/components/datasets/create/notion-page-preview/index.tsx
index 000b84ac629..edbee2b1946 100644
--- a/web/app/components/datasets/create/notion-page-preview/index.tsx
+++ b/web/app/components/datasets/create/notion-page-preview/index.tsx
@@ -29,7 +29,6 @@ const NotionPagePreview = ({
return
try {
const res = await fetchNotionPagePreview({
- workspaceID: currentPage.workspace_id,
pageID: currentPage.page_id,
pageType: currentPage.type,
credentialID: notionCredentialId,
diff --git a/web/service/datasets.ts b/web/service/datasets.ts
index 624da433f84..8791a61b7ca 100644
--- a/web/service/datasets.ts
+++ b/web/service/datasets.ts
@@ -185,8 +185,8 @@ export const fetchFileIndexingEstimate = (body: IndexingEstimateParams): Promise
return post<FileIndexingEstimateResponse>('/datasets/indexing-estimate', { body })
}
-export const fetchNotionPagePreview = ({ workspaceID, pageID, pageType, credentialID }: { workspaceID: string; pageID: string; pageType: string; credentialID: string }): Promise<{ content: string }> => {
- return get<{ content: string }>(`notion/workspaces/${workspaceID}/pages/${pageID}/${pageType}/preview`, {
+export const fetchNotionPagePreview = ({ pageID, pageType, credentialID }: { pageID: string; pageType: string; credentialID: string }): Promise<{ content: string }> => {
+ return get<{ content: string }>(`notion/pages/${pageID}/${pageType}/preview`, {
params: {
credential_id: credentialID,
},