diff --git a/web/app/components/datasets/list/dataset-card/index.tsx b/web/app/components/datasets/list/dataset-card/index.tsx
index eea0618b94..60b00740b9 100644
--- a/web/app/components/datasets/list/dataset-card/index.tsx
+++ b/web/app/components/datasets/list/dataset-card/index.tsx
@@ -2,9 +2,8 @@
import { useRouter } from 'next/navigation'
import { useTranslation } from 'react-i18next'
import type { DataSet } from '@/models/datasets'
-import { ChunkingMode } from '@/models/datasets'
-import { useAppContext } from '@/context/app-context'
-import { ExternalKnowledgeBase, General, Graph, ParentChild, Qa } from '@/app/components/base/icons/src/public/knowledge'
+import { useSelector as useAppContextWithSelector } from '@/context/app-context'
+import { General } from '@/app/components/base/icons/src/public/knowledge'
import { useKnowledge } from '@/hooks/use-knowledge'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import type { Tag } from '@/app/components/base/tag-management/constant'
@@ -23,25 +22,11 @@ import CustomPopover from '@/app/components/base/popover'
import Operations from './operations'
import AppIcon from '@/app/components/base/app-icon'
import CornerLabel from '@/app/components/base/corner-label'
+import { DOC_FORM_ICON, DOC_FORM_TEXT } from '@/models/datasets'
const EXTERNAL_PROVIDER = 'external'
-export const DOC_FORM_ICON: Record
> = {
- [ChunkingMode.text]: General,
- [ChunkingMode.qa]: Qa,
- [ChunkingMode.parentChild]: ParentChild,
- [ChunkingMode.graph]: Graph,
- external: ExternalKnowledgeBase,
-}
-
-export const DOC_FORM_TEXT: Record = {
- [ChunkingMode.text]: 'general',
- [ChunkingMode.qa]: 'qa',
- [ChunkingMode.parentChild]: 'parentChild',
- [ChunkingMode.graph]: 'graph',
-}
-
-export type DatasetCardProps = {
+type DatasetCardProps = {
dataset: DataSet
onSuccess?: () => void
}
@@ -53,7 +38,7 @@ const DatasetCard = ({
const { t } = useTranslation()
const { push } = useRouter()
- const { isCurrentWorkspaceDatasetOperator } = useAppContext()
+ const isCurrentWorkspaceDatasetOperator = useAppContextWithSelector(state => state.isCurrentWorkspaceDatasetOperator)
const [tags, setTags] = useState(dataset.tags)
const tagSelectorRef = useRef(null)
const isHoveringTagSelector = useHover(tagSelectorRef)
diff --git a/web/i18n/de-DE/dataset-pipeline.ts b/web/i18n/de-DE/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/de-DE/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/en-US/dataset-pipeline.ts b/web/i18n/en-US/dataset-pipeline.ts
new file mode 100644
index 0000000000..4a54196ea8
--- /dev/null
+++ b/web/i18n/en-US/dataset-pipeline.ts
@@ -0,0 +1,25 @@
+const translation = {
+ creation: {
+ title: 'Create knowledge pipeline',
+ createFromScratch: {
+ title: 'Create from scratch',
+ description: 'Blank knowledge pipeline',
+ },
+ ImportDSL: {
+ title: 'Import',
+ description: 'Import from a DSL file',
+ },
+ createKnowledge: 'Create Knowledge',
+ knowledgeNameAndIcon: 'Knowledge name & icon',
+ knowledgeNameAndIconPlaceholder: 'Please enter the name of the Knowledge Base',
+ knowledgeDescription: 'Knowledge description',
+ knowledgeDescriptionPlaceholder: 'Describe what is in this Knowledge Base. A detailed description allows AI to access the content of the dataset more accurately. If empty, Dify will use the default hit strategy. (Optional)',
+ knowledgePermissions: 'Permissions',
+ },
+ tabs: {
+ builtInPipeline: 'Built-in pipeline',
+ customized: 'Customized',
+ },
+}
+
+export default translation
diff --git a/web/i18n/es-ES/dataset-pipeline.ts b/web/i18n/es-ES/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/es-ES/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/fa-IR/dataset-pipeline.ts b/web/i18n/fa-IR/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/fa-IR/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/fr-FR/dataset-pipeline.ts b/web/i18n/fr-FR/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/fr-FR/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/hi-IN/dataset-pipeline.ts b/web/i18n/hi-IN/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/hi-IN/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/i18next-config.ts b/web/i18n/i18next-config.ts
index 8c5583bf9a..b9ded9afa7 100644
--- a/web/i18n/i18next-config.ts
+++ b/web/i18n/i18next-config.ts
@@ -34,6 +34,7 @@ const loadLangResources = (lang: string) => ({
datasetHitTesting: require(`./${lang}/dataset-hit-testing`).default,
datasetSettings: require(`./${lang}/dataset-settings`).default,
datasetCreation: require(`./${lang}/dataset-creation`).default,
+ datasetPipeline: require(`./${lang}/dataset-pipeline`).default,
explore: require(`./${lang}/explore`).default,
billing: require(`./${lang}/billing`).default,
custom: require(`./${lang}/custom`).default,
diff --git a/web/i18n/it-IT/dataset-pipeline.ts b/web/i18n/it-IT/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/it-IT/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/ja-JP/dataset-pipeline.ts b/web/i18n/ja-JP/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/ja-JP/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/ko-KR/dataset-pipeline.ts b/web/i18n/ko-KR/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/ko-KR/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/pl-PL/dataset-pipeline.ts b/web/i18n/pl-PL/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/pl-PL/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/pt-BR/dataset-pipeline.ts b/web/i18n/pt-BR/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/pt-BR/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/ro-RO/dataset-pipeline.ts b/web/i18n/ro-RO/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/ro-RO/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/ru-RU/dataset-pipeline.ts b/web/i18n/ru-RU/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/ru-RU/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/sl-SI/dataset-pipeline.ts b/web/i18n/sl-SI/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/sl-SI/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/th-TH/dataset-pipeline.ts b/web/i18n/th-TH/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/th-TH/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/tr-TR/dataset-pipeline.ts b/web/i18n/tr-TR/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/tr-TR/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/uk-UA/dataset-pipeline.ts b/web/i18n/uk-UA/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/uk-UA/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/vi-VN/dataset-pipeline.ts b/web/i18n/vi-VN/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/vi-VN/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/i18n/zh-Hans/dataset-pipeline.ts b/web/i18n/zh-Hans/dataset-pipeline.ts
new file mode 100644
index 0000000000..e193ddb479
--- /dev/null
+++ b/web/i18n/zh-Hans/dataset-pipeline.ts
@@ -0,0 +1,25 @@
+const translation = {
+ creation: {
+ title: '创建知识库流水线',
+ createFromScratch: {
+ title: '从零开始创建',
+ description: '空白知识库流水线',
+ },
+ ImportDSL: {
+ title: '导入',
+ description: '从 DSL 文件导入',
+ },
+ createKnowledge: '创建知识库',
+ knowledgeNameAndIcon: '知识库名称和图标',
+ knowledgeNameAndIconPlaceholder: '请输入知识库名称',
+ knowledgeDescription: '知识库描述',
+ knowledgeDescriptionPlaceholder: '描述知识库中的内容。详细的描述可以让 AI 更准确地访问数据集的内容。如果为空,Dify 将使用默认的命中策略。(可选)',
+ knowledgePermissions: '权限',
+ },
+ tabs: {
+ builtInPipeline: '内置流水线',
+ customized: '自定义',
+ },
+}
+
+export default translation
diff --git a/web/i18n/zh-Hant/dataset-pipeline.ts b/web/i18n/zh-Hant/dataset-pipeline.ts
new file mode 100644
index 0000000000..e2410dd34b
--- /dev/null
+++ b/web/i18n/zh-Hant/dataset-pipeline.ts
@@ -0,0 +1,3 @@
+const translation = {}
+
+export default translation
diff --git a/web/models/datasets.ts b/web/models/datasets.ts
index cc06d6e564..e0a09d7af6 100644
--- a/web/models/datasets.ts
+++ b/web/models/datasets.ts
@@ -4,6 +4,7 @@ import type { Tag } from '@/app/components/base/tag-management/constant'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
import type { MetadataFilteringVariableType } from '@/app/components/workflow/nodes/knowledge-retrieval/types'
import type { MetadataItemWithValue } from '@/app/components/datasets/metadata/types'
+import { ExternalKnowledgeBase, General, Graph, ParentChild, Qa } from '@/app/components/base/icons/src/public/knowledge'
export enum DataSourceType {
FILE = 'upload_file',
@@ -31,16 +32,18 @@ export type MetadataInDoc = {
name: string
}
+export type IconInfo = {
+ icon: string
+ icon_background?: string
+ icon_type: AppIconType
+ icon_url?: string
+}
+
export type DataSet = {
id: string
name: string
indexing_status: DocumentIndexingStatus
- icon_info: {
- icon: string
- icon_background?: string
- icon_type: AppIconType
- icon_url?: string
- }
+ icon_info: IconInfo
description: string
permission: DatasetPermission
data_source_type: DataSourceType
@@ -346,7 +349,7 @@ export type DocumentListResponse = {
export type DocumentReq = {
original_document_id?: string
- indexing_technique?: string
+ indexing_technique?: IndexingType
doc_form: ChunkingMode
doc_language: string
process_rule: ProcessRule
@@ -700,3 +703,47 @@ export type BatchImportResponse = {
job_id: string
job_status: string
}
+
+export const DOC_FORM_ICON: Record> = {
+ [ChunkingMode.text]: General,
+ [ChunkingMode.qa]: Qa,
+ [ChunkingMode.parentChild]: ParentChild,
+ [ChunkingMode.graph]: Graph,
+ external: ExternalKnowledgeBase,
+}
+
+export const DOC_FORM_TEXT: Record = {
+ [ChunkingMode.text]: 'general',
+ [ChunkingMode.qa]: 'qa',
+ [ChunkingMode.parentChild]: 'parentChild',
+ [ChunkingMode.graph]: 'graph',
+}
+
+export type CreateDatasetReq = {
+ name: string
+ description: string
+ icon_info: IconInfo
+ doc_form?: ChunkingMode
+ permission: DatasetPermission
+ partial_member_list?: {
+ user_id: string
+ role?: 'owner' | 'admin' | 'editor' | 'normal' | 'dataset_operator'
+ }[]
+ indexing_technique?: IndexingType
+ retrieval_mode?: RetrievalConfig
+ embedding_model?: string
+ embedding_model_provider?: string
+}
+
+export type CreateDatasetResponse = {
+ id: string
+ name: string
+ description: string
+ permission: DatasetPermission
+ data_source_type: DataSourceType
+ indexing_technique: IndexingType
+ created_by: string
+ created_at: number
+ updated_by: string
+ updated_at: number
+}
diff --git a/web/models/pipeline.ts b/web/models/pipeline.ts
new file mode 100644
index 0000000000..987c3f1d51
--- /dev/null
+++ b/web/models/pipeline.ts
@@ -0,0 +1,36 @@
+import type { ChunkingMode, IconInfo } from './datasets'
+
+export type PipelineTemplateListParams = {
+ type: 'built-in' | 'customized'
+}
+
+export type PipelineTemple = {
+ id: string
+ name: string
+ icon_info: IconInfo
+ description: string
+ position: number
+ doc_form: ChunkingMode
+}
+
+export type PipelineTemplateListResponse = {
+ pipelines: PipelineTemple[]
+}
+
+export type PipelineTemplateByIdResponse = {
+ name: string
+ icon_info: IconInfo
+ description: string
+ export_data: string
+}
+
+export type UpdatePipelineInfoPayload = {
+ pipelineId: string
+ name: string
+ icon_info: IconInfo
+ description: string
+}
+
+export type ExportPipelineDSLResponse = {
+ data: string
+}
diff --git a/web/service/knowledge/use-create-dataset.ts b/web/service/knowledge/use-create-dataset.ts
index 88ef1d9ffa..791107f2a3 100644
--- a/web/service/knowledge/use-create-dataset.ts
+++ b/web/service/knowledge/use-create-dataset.ts
@@ -3,8 +3,24 @@ import type { MutationOptions } from '@tanstack/react-query'
import { useMutation } from '@tanstack/react-query'
import { createDocument, createFirstDocument, fetchDefaultProcessRule, fetchFileIndexingEstimate } from '../datasets'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
-import type { ChunkingMode, CrawlOptions, CrawlResultItem, CreateDocumentReq, CustomFile, DataSourceType, FileIndexingEstimateResponse, IndexingEstimateParams, NotionInfo, ProcessRule, ProcessRuleResponse, createDocumentResponse } from '@/models/datasets'
+import type {
+ ChunkingMode,
+ CrawlOptions,
+ CrawlResultItem,
+ CreateDatasetReq,
+ CreateDatasetResponse,
+ CreateDocumentReq,
+ CustomFile,
+ DataSourceType,
+ FileIndexingEstimateResponse,
+ IndexingEstimateParams,
+ NotionInfo,
+ ProcessRule,
+ ProcessRuleResponse,
+ createDocumentResponse,
+} from '@/models/datasets'
import type { DataSourceProvider, NotionPage } from '@/models/common'
+import { post } from '../base'
export const getNotionInfo = (
notionPages: NotionPage[],
@@ -221,3 +237,14 @@ export const useFetchDefaultProcessRule = (
...mutationOptions,
})
}
+
+export const useCreateDataset = (
+ mutationOptions: MutationOptions = {},
+) => {
+ return useMutation({
+ mutationFn: (req: CreateDatasetReq) => {
+ return post('/datasets', { body: req })
+ },
+ ...mutationOptions,
+ })
+}
diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts
new file mode 100644
index 0000000000..3fbfc2eda8
--- /dev/null
+++ b/web/service/use-pipeline.ts
@@ -0,0 +1,75 @@
+import { useMutation, useQuery } from '@tanstack/react-query'
+import { del, get, patch } from './base'
+import type {
+ ExportPipelineDSLResponse,
+ PipelineTemplateByIdResponse,
+ PipelineTemplateListParams,
+ PipelineTemplateListResponse,
+ UpdatePipelineInfoPayload,
+} from '@/models/pipeline'
+
+const NAME_SPACE = 'pipeline'
+
+export const usePipelineTemplateList = (params: PipelineTemplateListParams) => {
+ return useQuery({
+ queryKey: [NAME_SPACE, 'template', 'list'],
+ queryFn: () => {
+ return get('/rag/pipeline/template', { params })
+ },
+ })
+}
+
+export const usePipelineTemplateById = (templateId: string) => {
+ return useQuery({
+ queryKey: [NAME_SPACE, 'template', templateId],
+ queryFn: () => {
+ return get(`/rag/pipeline/template/${templateId}`)
+ },
+ })
+}
+
+export const useUpdatePipelineInfo = ({
+ onSuccess,
+ onError,
+}: {
+ onSuccess?: () => void
+ onError?: (error: any) => void
+}) => {
+ return useMutation({
+ mutationKey: [NAME_SPACE, 'template', 'update'],
+ mutationFn: (payload: UpdatePipelineInfoPayload) => {
+ const { pipelineId, ...rest } = payload
+ return patch(`/rag/pipeline/${pipelineId}`, {
+ body: rest,
+ })
+ },
+ onSuccess,
+ onError,
+ })
+}
+
+export const useDeletePipeline = ({
+ onSuccess,
+ onError,
+}: {
+ onSuccess?: () => void
+ onError?: (error: any) => void
+}) => {
+ return useMutation({
+ mutationKey: [NAME_SPACE, 'template', 'delete'],
+ mutationFn: (pipelineId: string) => {
+ return del(`/rag/pipeline/${pipelineId}`)
+ },
+ onSuccess,
+ onError,
+ })
+}
+
+export const useExportPipelineDSL = (pipelineId: string) => {
+ return useQuery({
+ queryKey: [NAME_SPACE, 'template', 'export', pipelineId],
+ queryFn: () => {
+ return get(`/rag/pipeline/${pipelineId}`)
+ },
+ })
+}