mirror of
https://github.com/langgenius/dify.git
synced 2025-09-26 01:23:25 +00:00
feat: Enhance dataset pipeline creation and management with new export and delete functionalities, improved internationalization, and refactor for better clarity
This commit is contained in:
parent
6f77f67427
commit
e86a3fc672
@ -17,8 +17,7 @@ import { useCreateDataset } from '@/service/knowledge/use-create-dataset'
|
|||||||
import type { Member } from '@/models/common'
|
import type { Member } from '@/models/common'
|
||||||
|
|
||||||
type CreateFromScratchProps = {
|
type CreateFromScratchProps = {
|
||||||
onClose?: () => void
|
onClose: () => void
|
||||||
onCreate?: () => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_APP_ICON: AppIconSelection = {
|
const DEFAULT_APP_ICON: AppIconSelection = {
|
||||||
@ -29,7 +28,6 @@ const DEFAULT_APP_ICON: AppIconSelection = {
|
|||||||
|
|
||||||
const CreateFromScratch = ({
|
const CreateFromScratch = ({
|
||||||
onClose,
|
onClose,
|
||||||
onCreate,
|
|
||||||
}: CreateFromScratchProps) => {
|
}: CreateFromScratchProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [name, setName] = useState('')
|
const [name, setName] = useState('')
|
||||||
@ -79,7 +77,7 @@ const CreateFromScratch = ({
|
|||||||
|
|
||||||
const { mutateAsync: createEmptyDataset } = useCreateDataset()
|
const { mutateAsync: createEmptyDataset } = useCreateDataset()
|
||||||
|
|
||||||
const handleCreate = useCallback(() => {
|
const handleCreate = useCallback(async () => {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
@ -108,10 +106,12 @@ const CreateFromScratch = ({
|
|||||||
})
|
})
|
||||||
request.partial_member_list = selectedMemberList
|
request.partial_member_list = selectedMemberList
|
||||||
}
|
}
|
||||||
createEmptyDataset(request)
|
await createEmptyDataset(request, {
|
||||||
onCreate?.()
|
onSettled: () => {
|
||||||
onClose?.()
|
onClose?.()
|
||||||
}, [name, permission, appIcon, description, createEmptyDataset, memberList, selectedMemberIDs, onCreate, onClose])
|
},
|
||||||
|
})
|
||||||
|
}, [name, permission, appIcon, description, createEmptyDataset, memberList, selectedMemberIDs, onClose])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative flex flex-col'>
|
<div className='relative flex flex-col'>
|
||||||
@ -132,12 +132,12 @@ const CreateFromScratch = ({
|
|||||||
<div className='flex items-end gap-x-3 self-stretch'>
|
<div className='flex items-end gap-x-3 self-stretch'>
|
||||||
<div className='flex grow flex-col gap-y-1 pb-1'>
|
<div className='flex grow flex-col gap-y-1 pb-1'>
|
||||||
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
||||||
{t('datasetPipeline.creation.knowledgeNameAndIcon')}
|
{t('datasetPipeline.knowledgeNameAndIcon')}
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
onChange={handleAppNameChange}
|
onChange={handleAppNameChange}
|
||||||
value={name}
|
value={name}
|
||||||
placeholder={t('datasetPipeline.creation.knowledgeNameAndIconPlaceholder')}
|
placeholder={t('datasetPipeline.knowledgeNameAndIconPlaceholder')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<AppIcon
|
<AppIcon
|
||||||
@ -153,17 +153,17 @@ const CreateFromScratch = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-y-1'>
|
<div className='flex flex-col gap-y-1'>
|
||||||
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
||||||
{t('datasetPipeline.creation.knowledgeDescription')}
|
{t('datasetPipeline.knowledgeDescription')}
|
||||||
</label>
|
</label>
|
||||||
<Textarea
|
<Textarea
|
||||||
onChange={handleDescriptionChange}
|
onChange={handleDescriptionChange}
|
||||||
value={description}
|
value={description}
|
||||||
placeholder={t('datasetPipeline.creation.knowledgeDescriptionPlaceholder')}
|
placeholder={t('datasetPipeline.knowledgeDescriptionPlaceholder')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-y-1'>
|
<div className='flex flex-col gap-y-1'>
|
||||||
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
||||||
{t('datasetPipeline.creation.knowledgePermissions')}
|
{t('datasetPipeline.knowledgePermissions')}
|
||||||
</label>
|
</label>
|
||||||
<PermissionSelector
|
<PermissionSelector
|
||||||
permission={permission}
|
permission={permission}
|
||||||
|
@ -34,10 +34,6 @@ const CreateOptions = () => {
|
|||||||
setShowCreateModal(false)
|
setShowCreateModal(false)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleCreateFromScratch = useCallback(() => {
|
|
||||||
setShowCreateModal(false)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const openImportFromDSL = useCallback(() => {
|
const openImportFromDSL = useCallback(() => {
|
||||||
setShowImportModal(true)
|
setShowImportModal(true)
|
||||||
}, [])
|
}, [])
|
||||||
@ -73,7 +69,6 @@ const CreateOptions = () => {
|
|||||||
>
|
>
|
||||||
<CreateFromScratch
|
<CreateFromScratch
|
||||||
onClose={closeCreateFromScratch}
|
onClose={closeCreateFromScratch}
|
||||||
onCreate={handleCreateFromScratch}
|
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
<CreateFromDSLModal
|
<CreateFromDSLModal
|
||||||
|
@ -16,7 +16,7 @@ const Item = ({
|
|||||||
}: ItemProps) => {
|
}: ItemProps) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className='group flex w-[337px] items-center gap-x-3 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg p-4 shadow-xs shadow-shadow-shadow-3 hover:shadow-md hover:shadow-shadow-shadow-5'
|
className='group flex w-[337px] cursor-pointer items-center gap-x-3 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg p-4 shadow-xs shadow-shadow-shadow-3 hover:shadow-md hover:shadow-shadow-shadow-5'
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<div className='flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-dashed border-divider-regular bg-background-section group-hover:border-state-accent-hover-alt group-hover:bg-state-accent-hover'>
|
<div className='flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-dashed border-divider-regular bg-background-section group-hover:border-state-accent-hover-alt group-hover:bg-state-accent-hover'>
|
||||||
|
@ -9,16 +9,15 @@ import Button from '@/app/components/base/button'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Toast from '@/app/components/base/toast'
|
import Toast from '@/app/components/base/toast'
|
||||||
import type { PipelineTemple } from '@/models/pipeline'
|
import type { PipelineTemple } from '@/models/pipeline'
|
||||||
|
import { useUpdatePipelineInfo } from '@/service/use-pipeline'
|
||||||
|
|
||||||
type EditPipelineInfoProps = {
|
type EditPipelineInfoProps = {
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
onSave: () => void
|
|
||||||
pipeline: PipelineTemple
|
pipeline: PipelineTemple
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditPipelineInfo = ({
|
const EditPipelineInfo = ({
|
||||||
onClose,
|
onClose,
|
||||||
onSave,
|
|
||||||
pipeline,
|
pipeline,
|
||||||
}: EditPipelineInfoProps) => {
|
}: EditPipelineInfoProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -62,7 +61,9 @@ const EditPipelineInfo = ({
|
|||||||
setDescription(value)
|
setDescription(value)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleSave = useCallback(() => {
|
const { mutateAsync: updatePipeline } = useUpdatePipelineInfo()
|
||||||
|
|
||||||
|
const handleSave = useCallback(async () => {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
@ -70,16 +71,30 @@ const EditPipelineInfo = ({
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
onSave()
|
const request = {
|
||||||
onClose()
|
pipeline_id: pipeline.id,
|
||||||
}, [name, onSave, onClose])
|
name,
|
||||||
|
icon_info: {
|
||||||
|
icon_type: appIcon.type,
|
||||||
|
icon: appIcon.type === 'image' ? appIcon.fileId : appIcon.icon,
|
||||||
|
icon_background: appIcon.type === 'image' ? undefined : appIcon.background,
|
||||||
|
icon_url: appIcon.type === 'image' ? appIcon.url : undefined,
|
||||||
|
},
|
||||||
|
description,
|
||||||
|
}
|
||||||
|
await updatePipeline(request, {
|
||||||
|
onSettled: () => {
|
||||||
|
onClose()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}, [name, appIcon, description, pipeline.id, updatePipeline, onClose])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative flex flex-col'>
|
<div className='relative flex flex-col'>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className='pb-3 pl-6 pr-14 pt-6'>
|
<div className='pb-3 pl-6 pr-14 pt-6'>
|
||||||
<span className='title-2xl-semi-bold text-text-primary'>
|
<span className='title-2xl-semi-bold text-text-primary'>
|
||||||
Edit Pipeline Info
|
{t('datasetPipeline.editPipelineInfo')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
@ -92,11 +107,13 @@ const EditPipelineInfo = ({
|
|||||||
<div className='flex flex-col gap-y-5 px-6 py-3'>
|
<div className='flex flex-col gap-y-5 px-6 py-3'>
|
||||||
<div className='flex items-end gap-x-3 self-stretch'>
|
<div className='flex items-end gap-x-3 self-stretch'>
|
||||||
<div className='flex grow flex-col gap-y-1 pb-1'>
|
<div className='flex grow flex-col gap-y-1 pb-1'>
|
||||||
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>Pipeline name & icon</label>
|
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
||||||
|
{t('datasetPipeline.pipelineNameAndIcon')}
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
onChange={handleAppNameChange}
|
onChange={handleAppNameChange}
|
||||||
value={name}
|
value={name}
|
||||||
placeholder='Please enter the name of the Knowledge Base'
|
placeholder={t('datasetPipeline.knowledgeNameAndIconPlaceholder')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<AppIcon
|
<AppIcon
|
||||||
@ -111,11 +128,13 @@ const EditPipelineInfo = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-y-1'>
|
<div className='flex flex-col gap-y-1'>
|
||||||
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>Knowledge description</label>
|
<label className='system-sm-medium flex h-6 items-center text-text-secondary'>
|
||||||
|
{t('datasetPipeline.knowledgeDescription')}
|
||||||
|
</label>
|
||||||
<Textarea
|
<Textarea
|
||||||
onChange={handleDescriptionChange}
|
onChange={handleDescriptionChange}
|
||||||
value={description}
|
value={description}
|
||||||
placeholder='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)'
|
placeholder={t('datasetPipeline.knowledgeDescriptionPlaceholder')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,6 +10,10 @@ import Modal from '@/app/components/base/modal'
|
|||||||
import EditPipelineInfo from './edit-pipeline-info'
|
import EditPipelineInfo from './edit-pipeline-info'
|
||||||
import type { PipelineTemple } from '@/models/pipeline'
|
import type { PipelineTemple } from '@/models/pipeline'
|
||||||
import { DOC_FORM_ICON, DOC_FORM_TEXT } from '@/models/datasets'
|
import { DOC_FORM_ICON, DOC_FORM_TEXT } from '@/models/datasets'
|
||||||
|
import Confirm from '@/app/components/base/confirm'
|
||||||
|
import { useDeletePipeline, useExportPipelineDSL } from '@/service/use-pipeline'
|
||||||
|
import { downloadFile } from '@/utils/format'
|
||||||
|
import Toast from '@/app/components/base/toast'
|
||||||
|
|
||||||
type TemplateCardProps = {
|
type TemplateCardProps = {
|
||||||
pipeline: PipelineTemple
|
pipeline: PipelineTemple
|
||||||
@ -22,6 +26,7 @@ const TemplateCard = ({
|
|||||||
}: TemplateCardProps) => {
|
}: TemplateCardProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [showEditModal, setShowEditModal] = useState(false)
|
const [showEditModal, setShowEditModal] = useState(false)
|
||||||
|
const [showDeleteConfirm, setShowConfirmDelete] = useState(false)
|
||||||
|
|
||||||
const openEditModal = useCallback(() => {
|
const openEditModal = useCallback(() => {
|
||||||
setShowEditModal(true)
|
setShowEditModal(true)
|
||||||
@ -31,6 +36,48 @@ const TemplateCard = ({
|
|||||||
setShowEditModal(false)
|
setShowEditModal(false)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const { mutateAsync: getDSLFileContent } = useExportPipelineDSL()
|
||||||
|
|
||||||
|
const handleExportDSL = useCallback(async () => {
|
||||||
|
await getDSLFileContent(pipeline.id, {
|
||||||
|
onSuccess: (res) => {
|
||||||
|
const blob = new Blob([res.data], { type: 'application/yaml' })
|
||||||
|
downloadFile({
|
||||||
|
data: blob,
|
||||||
|
fileName: `${pipeline.name}.dsl`,
|
||||||
|
})
|
||||||
|
Toast.notify({
|
||||||
|
type: 'success',
|
||||||
|
message: t('datasetPipeline.exportDSL.successTip'),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
Toast.notify({
|
||||||
|
type: 'error',
|
||||||
|
message: t('datasetPipeline.exportDSL.errorTip'),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}, [t, pipeline.id, pipeline.name, getDSLFileContent])
|
||||||
|
|
||||||
|
const handleDelete = useCallback(() => {
|
||||||
|
setShowConfirmDelete(true)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const onCancelDelete = useCallback(() => {
|
||||||
|
setShowConfirmDelete(false)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const { mutateAsync: deletePipeline } = useDeletePipeline()
|
||||||
|
|
||||||
|
const onConfirmDelete = useCallback(async () => {
|
||||||
|
await deletePipeline(pipeline.id, {
|
||||||
|
onSettled: () => {
|
||||||
|
setShowConfirmDelete(false)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}, [pipeline.id, deletePipeline])
|
||||||
|
|
||||||
const Icon = DOC_FORM_ICON[pipeline.doc_form] || General
|
const Icon = DOC_FORM_ICON[pipeline.doc_form] || General
|
||||||
const iconInfo = pipeline.icon_info
|
const iconInfo = pipeline.icon_info
|
||||||
|
|
||||||
@ -50,13 +97,21 @@ const TemplateCard = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex grow flex-col gap-y-1 py-px'>
|
<div className='flex grow flex-col gap-y-1 py-px'>
|
||||||
<div className='system-md-semibold truncate text-text-secondary' title={pipeline.name}>{pipeline.name}</div>
|
<div
|
||||||
|
className='system-md-semibold truncate text-text-secondary'
|
||||||
|
title={pipeline.name}
|
||||||
|
>
|
||||||
|
{pipeline.name}
|
||||||
|
</div>
|
||||||
<div className='system-2xs-medium-uppercase text-text-tertiary'>
|
<div className='system-2xs-medium-uppercase text-text-tertiary'>
|
||||||
{t(`dataset.chunkingMode.${DOC_FORM_TEXT[pipeline.doc_form]}`)}
|
{t(`dataset.chunkingMode.${DOC_FORM_TEXT[pipeline.doc_form]}`)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className='system-xs-regular line-clamp-3 grow px-4 py-1 text-text-tertiary' title={pipeline.description}>
|
<p
|
||||||
|
className='system-xs-regular line-clamp-3 grow px-4 py-1 text-text-tertiary'
|
||||||
|
title={pipeline.description}
|
||||||
|
>
|
||||||
{pipeline.description}
|
{pipeline.description}
|
||||||
</p>
|
</p>
|
||||||
<div className='absolute bottom-0 left-0 z-10 hidden w-full items-center gap-x-1 bg-pipeline-template-card-hover-bg p-4 pt-8 group-hover:flex'>
|
<div className='absolute bottom-0 left-0 z-10 hidden w-full items-center gap-x-1 bg-pipeline-template-card-hover-bg p-4 pt-8 group-hover:flex'>
|
||||||
@ -68,7 +123,7 @@ const TemplateCard = ({
|
|||||||
className='grow gap-x-0.5'
|
className='grow gap-x-0.5'
|
||||||
>
|
>
|
||||||
<RiAddLine className='size-4' />
|
<RiAddLine className='size-4' />
|
||||||
<span className='px-0.5'>Choose</span>
|
<span className='px-0.5'>{t('datasetPipeline.operations.choose')}</span>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant='secondary'
|
variant='secondary'
|
||||||
@ -78,7 +133,7 @@ const TemplateCard = ({
|
|||||||
className='grow gap-x-0.5'
|
className='grow gap-x-0.5'
|
||||||
>
|
>
|
||||||
<RiArrowRightUpLine className='size-4' />
|
<RiArrowRightUpLine className='size-4' />
|
||||||
<span className='px-0.5'>Details</span>
|
<span className='px-0.5'>{t('datasetPipeline.operations.details')}</span>
|
||||||
</Button>
|
</Button>
|
||||||
{
|
{
|
||||||
showMoreOperations && (
|
showMoreOperations && (
|
||||||
@ -86,9 +141,8 @@ const TemplateCard = ({
|
|||||||
htmlContent={
|
htmlContent={
|
||||||
<Operations
|
<Operations
|
||||||
openEditModal={openEditModal}
|
openEditModal={openEditModal}
|
||||||
onDelete={() => {
|
onExport={handleExportDSL}
|
||||||
console.log('Delete', pipeline)
|
onDelete={handleDelete}
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
className={'z-20 min-w-[160px]'}
|
className={'z-20 min-w-[160px]'}
|
||||||
@ -103,19 +157,27 @@ const TemplateCard = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<Modal
|
{showEditModal && (
|
||||||
isShow={showEditModal}
|
<Modal
|
||||||
onClose={closeEditModal}
|
isShow={showEditModal}
|
||||||
className='max-w-[520px] p-0'
|
|
||||||
>
|
|
||||||
<EditPipelineInfo
|
|
||||||
pipeline={pipeline}
|
|
||||||
onClose={closeEditModal}
|
onClose={closeEditModal}
|
||||||
onSave={() => {
|
className='max-w-[520px] p-0'
|
||||||
console.log('Save', pipeline)
|
>
|
||||||
}}
|
<EditPipelineInfo
|
||||||
|
pipeline={pipeline}
|
||||||
|
onClose={closeEditModal}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
{showDeleteConfirm && (
|
||||||
|
<Confirm
|
||||||
|
title={t('datasetPipeline.deletePipeline.title')}
|
||||||
|
content={t('datasetPipeline.deletePipeline.content')}
|
||||||
|
isShow={showDeleteConfirm}
|
||||||
|
onConfirm={onConfirmDelete}
|
||||||
|
onCancel={onCancelDelete}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,21 +5,29 @@ import { useTranslation } from 'react-i18next'
|
|||||||
type OperationsProps = {
|
type OperationsProps = {
|
||||||
openEditModal: () => void
|
openEditModal: () => void
|
||||||
onDelete: () => void
|
onDelete: () => void
|
||||||
|
onExport: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const Operations = ({
|
const Operations = ({
|
||||||
openEditModal,
|
openEditModal,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
onExport,
|
||||||
}: OperationsProps) => {
|
}: OperationsProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const onClickEdit = async (e: React.MouseEvent<HTMLDivElement>) => {
|
const onClickEdit = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
openEditModal()
|
openEditModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClickDelete = async (e: React.MouseEvent<HTMLDivElement>) => {
|
const onClickExport = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
onExport()
|
||||||
|
}
|
||||||
|
|
||||||
|
const onClickDelete = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
onDelete()
|
onDelete()
|
||||||
@ -33,15 +41,15 @@ const Operations = ({
|
|||||||
onClick={onClickEdit}
|
onClick={onClickEdit}
|
||||||
>
|
>
|
||||||
<span className='system-md-regular px-1 text-text-secondary'>
|
<span className='system-md-regular px-1 text-text-secondary'>
|
||||||
Edit Info
|
{t('datasetPipeline.operations.editInfo')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className='flex cursor-pointer items-center gap-x-1 rounded-lg px-2 py-1.5 hover:bg-state-base-hover'
|
className='flex cursor-pointer items-center gap-x-1 rounded-lg px-2 py-1.5 hover:bg-state-base-hover'
|
||||||
onClick={() => { console.log('Export DSL') }}
|
onClick={onClickExport}
|
||||||
>
|
>
|
||||||
<span className='system-md-regular px-1 text-text-secondary'>
|
<span className='system-md-regular px-1 text-text-secondary'>
|
||||||
Export DSL
|
{t('datasetPipeline.operations.exportDSL')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,16 +10,32 @@ const translation = {
|
|||||||
description: 'Import from a DSL file',
|
description: 'Import from a DSL file',
|
||||||
},
|
},
|
||||||
createKnowledge: 'Create Knowledge',
|
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: {
|
tabs: {
|
||||||
builtInPipeline: 'Built-in pipeline',
|
builtInPipeline: 'Built-in pipeline',
|
||||||
customized: 'Customized',
|
customized: 'Customized',
|
||||||
},
|
},
|
||||||
|
operations: {
|
||||||
|
choose: 'Choose',
|
||||||
|
details: 'Details',
|
||||||
|
editInfo: 'Edit info',
|
||||||
|
exportDSL: 'Export DSL',
|
||||||
|
},
|
||||||
|
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',
|
||||||
|
editPipelineInfo: 'Edit pipeline info',
|
||||||
|
pipelineNameAndIcon: 'Pipeline name & icon',
|
||||||
|
deletePipeline: {
|
||||||
|
title: 'Are you sure to delete this pipeline template?',
|
||||||
|
content: 'Deleting the pipeline template is irreversible.',
|
||||||
|
},
|
||||||
|
exportDSL: {
|
||||||
|
successTip: 'Export pipeline DSL successfully',
|
||||||
|
errorTip: 'Failed to export pipeline DSL',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translation
|
export default translation
|
||||||
|
@ -10,16 +10,32 @@ const translation = {
|
|||||||
description: '从 DSL 文件导入',
|
description: '从 DSL 文件导入',
|
||||||
},
|
},
|
||||||
createKnowledge: '创建知识库',
|
createKnowledge: '创建知识库',
|
||||||
knowledgeNameAndIcon: '知识库名称和图标',
|
|
||||||
knowledgeNameAndIconPlaceholder: '请输入知识库名称',
|
|
||||||
knowledgeDescription: '知识库描述',
|
|
||||||
knowledgeDescriptionPlaceholder: '描述知识库中的内容。详细的描述可以让 AI 更准确地访问数据集的内容。如果为空,Dify 将使用默认的命中策略。(可选)',
|
|
||||||
knowledgePermissions: '权限',
|
|
||||||
},
|
},
|
||||||
tabs: {
|
tabs: {
|
||||||
builtInPipeline: '内置流水线',
|
builtInPipeline: '内置流水线',
|
||||||
customized: '自定义',
|
customized: '自定义',
|
||||||
},
|
},
|
||||||
|
operations: {
|
||||||
|
choose: '选择',
|
||||||
|
details: '详情',
|
||||||
|
editInfo: '编辑信息',
|
||||||
|
exportDSL: '导出 DSL',
|
||||||
|
},
|
||||||
|
knowledgeNameAndIcon: '知识库名称和图标',
|
||||||
|
knowledgeNameAndIconPlaceholder: '请输入知识库名称',
|
||||||
|
knowledgeDescription: '知识库描述',
|
||||||
|
knowledgeDescriptionPlaceholder: '描述知识库中的内容。详细的描述可以让 AI 更准确地访问数据集的内容。如果为空,Dify 将使用默认的命中策略。(可选)',
|
||||||
|
knowledgePermissions: '权限',
|
||||||
|
editPipelineInfo: '编辑流水线信息',
|
||||||
|
pipelineNameAndIcon: '流水线名称和图标',
|
||||||
|
deletePipeline: {
|
||||||
|
title: '要删除此流水线模板吗?',
|
||||||
|
content: '删除流水线模板是不可逆的。',
|
||||||
|
},
|
||||||
|
exportDSL: {
|
||||||
|
successTip: '成功导出流水线 DSL',
|
||||||
|
errorTip: '导出流水线 DSL 失败',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translation
|
export default translation
|
||||||
|
@ -24,13 +24,25 @@ export type PipelineTemplateByIdResponse = {
|
|||||||
export_data: string
|
export_data: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdatePipelineInfoPayload = {
|
export type UpdatePipelineInfoRequest = {
|
||||||
pipelineId: string
|
pipeline_id: string
|
||||||
name: string
|
name: string
|
||||||
icon_info: IconInfo
|
icon_info: IconInfo
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UpdatePipelineInfoResponse = {
|
||||||
|
pipeline_id: string
|
||||||
|
name: string
|
||||||
|
icon_info: IconInfo
|
||||||
|
description: string
|
||||||
|
position: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DeletePipelineResponse = {
|
||||||
|
code: number
|
||||||
|
}
|
||||||
|
|
||||||
export type ExportPipelineDSLResponse = {
|
export type ExportPipelineDSLResponse = {
|
||||||
data: string
|
data: string
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ import type {
|
|||||||
import type { DataSourceProvider, NotionPage } from '@/models/common'
|
import type { DataSourceProvider, NotionPage } from '@/models/common'
|
||||||
import { post } from '../base'
|
import { post } from '../base'
|
||||||
|
|
||||||
|
const NAME_SPACE = 'knowledge/create-dataset'
|
||||||
|
|
||||||
export const getNotionInfo = (
|
export const getNotionInfo = (
|
||||||
notionPages: NotionPage[],
|
notionPages: NotionPage[],
|
||||||
) => {
|
) => {
|
||||||
@ -242,6 +244,7 @@ export const useCreateDataset = (
|
|||||||
mutationOptions: MutationOptions<CreateDatasetResponse, Error, CreateDatasetReq> = {},
|
mutationOptions: MutationOptions<CreateDatasetResponse, Error, CreateDatasetReq> = {},
|
||||||
) => {
|
) => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
|
mutationKey: [NAME_SPACE, 'create-dataset'],
|
||||||
mutationFn: (req: CreateDatasetReq) => {
|
mutationFn: (req: CreateDatasetReq) => {
|
||||||
return post<CreateDatasetResponse>('/datasets', { body: req })
|
return post<CreateDatasetResponse>('/datasets', { body: req })
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
import type { MutationOptions } from '@tanstack/react-query'
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query'
|
import { useMutation, useQuery } from '@tanstack/react-query'
|
||||||
import { del, get, patch } from './base'
|
import { del, get, patch } from './base'
|
||||||
import type {
|
import type {
|
||||||
|
DeletePipelineResponse,
|
||||||
ExportPipelineDSLResponse,
|
ExportPipelineDSLResponse,
|
||||||
PipelineTemplateByIdResponse,
|
PipelineTemplateByIdResponse,
|
||||||
PipelineTemplateListParams,
|
PipelineTemplateListParams,
|
||||||
PipelineTemplateListResponse,
|
PipelineTemplateListResponse,
|
||||||
UpdatePipelineInfoPayload,
|
UpdatePipelineInfoRequest,
|
||||||
|
UpdatePipelineInfoResponse,
|
||||||
} from '@/models/pipeline'
|
} from '@/models/pipeline'
|
||||||
|
|
||||||
const NAME_SPACE = 'pipeline'
|
const NAME_SPACE = 'pipeline'
|
||||||
@ -28,48 +31,41 @@ export const usePipelineTemplateById = (templateId: string) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUpdatePipelineInfo = ({
|
export const useUpdatePipelineInfo = (
|
||||||
onSuccess,
|
mutationOptions: MutationOptions<UpdatePipelineInfoResponse, Error, UpdatePipelineInfoRequest> = {},
|
||||||
onError,
|
) => {
|
||||||
}: {
|
|
||||||
onSuccess?: () => void
|
|
||||||
onError?: (error: any) => void
|
|
||||||
}) => {
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationKey: [NAME_SPACE, 'template', 'update'],
|
mutationKey: [NAME_SPACE, 'template', 'update'],
|
||||||
mutationFn: (payload: UpdatePipelineInfoPayload) => {
|
mutationFn: (request: UpdatePipelineInfoRequest) => {
|
||||||
const { pipelineId, ...rest } = payload
|
const { pipeline_id, ...rest } = request
|
||||||
return patch(`/rag/pipeline/${pipelineId}`, {
|
return patch<UpdatePipelineInfoResponse>(`/rag/pipeline/${pipeline_id}`, {
|
||||||
body: rest,
|
body: rest,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSuccess,
|
...mutationOptions,
|
||||||
onError,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDeletePipeline = ({
|
export const useDeletePipeline = (
|
||||||
onSuccess,
|
mutationOptions: MutationOptions<DeletePipelineResponse, Error, string> = {},
|
||||||
onError,
|
) => {
|
||||||
}: {
|
|
||||||
onSuccess?: () => void
|
|
||||||
onError?: (error: any) => void
|
|
||||||
}) => {
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationKey: [NAME_SPACE, 'template', 'delete'],
|
mutationKey: [NAME_SPACE, 'template', 'delete'],
|
||||||
mutationFn: (pipelineId: string) => {
|
mutationFn: (pipelineId: string) => {
|
||||||
return del(`/rag/pipeline/${pipelineId}`)
|
return del<DeletePipelineResponse>(`/rag/pipeline/${pipelineId}`)
|
||||||
},
|
},
|
||||||
onSuccess,
|
...mutationOptions,
|
||||||
onError,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useExportPipelineDSL = (pipelineId: string) => {
|
export const useExportPipelineDSL = (
|
||||||
return useQuery<ExportPipelineDSLResponse>({
|
mutationOptions: MutationOptions<ExportPipelineDSLResponse, Error, string> = {},
|
||||||
queryKey: [NAME_SPACE, 'template', 'export', pipelineId],
|
) => {
|
||||||
queryFn: () => {
|
return useMutation({
|
||||||
|
mutationKey: [NAME_SPACE, 'template', 'export'],
|
||||||
|
mutationFn: (pipelineId: string) => {
|
||||||
return get<ExportPipelineDSLResponse>(`/rag/pipeline/${pipelineId}`)
|
return get<ExportPipelineDSLResponse>(`/rag/pipeline/${pipelineId}`)
|
||||||
},
|
},
|
||||||
|
...mutationOptions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user