mirror of
https://github.com/langgenius/dify.git
synced 2026-04-26 18:27:15 +08:00
Merge branch 'feat/rag-2' into fix-miss-import
This commit is contained in:
commit
8d0139bb21
@ -950,6 +950,12 @@ class RagPipelineTransformApi(Resource):
|
|||||||
@login_required
|
@login_required
|
||||||
@account_initialization_required
|
@account_initialization_required
|
||||||
def post(self, dataset_id):
|
def post(self, dataset_id):
|
||||||
|
if not isinstance(current_user, Account):
|
||||||
|
raise Forbidden()
|
||||||
|
|
||||||
|
if not (current_user.is_editor or current_user.is_dataset_operator):
|
||||||
|
raise Forbidden()
|
||||||
|
|
||||||
dataset_id = str(dataset_id)
|
dataset_id = str(dataset_id)
|
||||||
rag_pipeline_transform_service = RagPipelineTransformService()
|
rag_pipeline_transform_service = RagPipelineTransformService()
|
||||||
result = rag_pipeline_transform_service.transform_dataset(dataset_id)
|
result = rag_pipeline_transform_service.transform_dataset(dataset_id)
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
{"not_installed": [], "plugin_install_failed": []}
|
|
||||||
@ -19,26 +19,9 @@ export const useAvailableNodesMetaData = () => {
|
|||||||
...dataSourceDefault.defaultValue,
|
...dataSourceDefault.defaultValue,
|
||||||
_dataSourceStartToAdd: true,
|
_dataSourceStartToAdd: true,
|
||||||
},
|
},
|
||||||
metaData: {
|
|
||||||
...dataSourceDefault.metaData,
|
|
||||||
isStart: true,
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...knowledgeBaseDefault,
|
|
||||||
metaData: {
|
|
||||||
...knowledgeBaseDefault.metaData,
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...dataSourceEmptyDefault,
|
|
||||||
metaData: {
|
|
||||||
...dataSourceEmptyDefault.metaData,
|
|
||||||
isUndeletable: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
knowledgeBaseDefault,
|
||||||
|
dataSourceEmptyDefault,
|
||||||
], [])
|
], [])
|
||||||
|
|
||||||
const prefixLink = useMemo(() => {
|
const prefixLink = useMemo(() => {
|
||||||
|
|||||||
@ -15,35 +15,11 @@ export const useAvailableNodesMetaData = () => {
|
|||||||
|
|
||||||
const mergedNodesMetaData = useMemo(() => [
|
const mergedNodesMetaData = useMemo(() => [
|
||||||
...WORKFLOW_COMMON_NODES,
|
...WORKFLOW_COMMON_NODES,
|
||||||
{
|
StartDefault,
|
||||||
...StartDefault,
|
|
||||||
metaData: {
|
|
||||||
...StartDefault.metaData,
|
|
||||||
isStart: true,
|
|
||||||
isRequired: true,
|
|
||||||
isUndeletable: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...(
|
...(
|
||||||
isChatMode
|
isChatMode
|
||||||
? [
|
? [AnswerDefault]
|
||||||
{
|
: [EndDefault]
|
||||||
...AnswerDefault,
|
|
||||||
metaData: {
|
|
||||||
...AnswerDefault.metaData,
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: [
|
|
||||||
{
|
|
||||||
...EndDefault,
|
|
||||||
metaData: {
|
|
||||||
...EndDefault.metaData,
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
], [isChatMode])
|
], [isChatMode])
|
||||||
|
|
||||||
|
|||||||
@ -1256,15 +1256,26 @@ export const useNodesInteractions = () => {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If no nodeId is provided, fall back to the current behavior
|
// If no nodeId is provided, fall back to the current behavior
|
||||||
const bundledNodes = nodes.filter(node => node.data._isBundled && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.DataSource && node.data.type !== BlockEnum.KnowledgeBase && node.data.type !== BlockEnum.DataSourceEmpty
|
const bundledNodes = nodes.filter((node) => {
|
||||||
&& !node.data.isInIteration && !node.data.isInLoop)
|
if (!node.data._isBundled)
|
||||||
|
return false
|
||||||
|
const { metaData } = nodesMetaDataMap![node.data.type as BlockEnum]
|
||||||
|
if (metaData.isSingleton)
|
||||||
|
return false
|
||||||
|
return !node.data.isInIteration && !node.data.isInLoop
|
||||||
|
})
|
||||||
|
|
||||||
if (bundledNodes.length) {
|
if (bundledNodes.length) {
|
||||||
setClipboardElements(bundledNodes)
|
setClipboardElements(bundledNodes)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedNode = nodes.find(node => node.data.selected && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.LoopEnd && node.data.type !== BlockEnum.DataSource)
|
const selectedNode = nodes.find((node) => {
|
||||||
|
if (!node.data.selected)
|
||||||
|
return false
|
||||||
|
const { metaData } = nodesMetaDataMap![node.data.type as BlockEnum]
|
||||||
|
return !metaData.isSingleton
|
||||||
|
})
|
||||||
|
|
||||||
if (selectedNode)
|
if (selectedNode)
|
||||||
setClipboardElements([selectedNode])
|
setClipboardElements([selectedNode])
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import {
|
|||||||
} from '@/app/components/workflow/hooks'
|
} from '@/app/components/workflow/hooks'
|
||||||
import ShortcutsName from '@/app/components/workflow/shortcuts-name'
|
import ShortcutsName from '@/app/components/workflow/shortcuts-name'
|
||||||
import type { Node } from '@/app/components/workflow/types'
|
import type { Node } from '@/app/components/workflow/types'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
|
||||||
|
|
||||||
type PanelOperatorPopupProps = {
|
type PanelOperatorPopupProps = {
|
||||||
id: string
|
id: string
|
||||||
@ -43,7 +42,7 @@ const PanelOperatorPopup = ({
|
|||||||
const { nodesReadOnly } = useNodesReadOnly()
|
const { nodesReadOnly } = useNodesReadOnly()
|
||||||
const edge = edges.find(edge => edge.target === id)
|
const edge = edges.find(edge => edge.target === id)
|
||||||
const nodeMetaData = useNodeMetaData({ id, data } as Node)
|
const nodeMetaData = useNodeMetaData({ id, data } as Node)
|
||||||
const showChangeBlock = data.type !== BlockEnum.Start && !nodesReadOnly && data.type !== BlockEnum.Iteration && data.type !== BlockEnum.Loop
|
const showChangeBlock = !nodeMetaData.isTypeFixed && !nodesReadOnly
|
||||||
const isChildNode = !!(data.isInIteration || data.isInLoop)
|
const isChildNode = !!(data.isInIteration || data.isInLoop)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -85,31 +84,37 @@ const PanelOperatorPopup = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
data.type !== BlockEnum.Start && !nodesReadOnly && (
|
!nodesReadOnly && (
|
||||||
<>
|
<>
|
||||||
<div className='p-1'>
|
{
|
||||||
<div
|
!nodeMetaData.isSingleton && (
|
||||||
className='flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary hover:bg-state-base-hover'
|
<>
|
||||||
onClick={() => {
|
<div className='p-1'>
|
||||||
onClosePopup()
|
<div
|
||||||
handleNodesCopy(id)
|
className='flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary hover:bg-state-base-hover'
|
||||||
}}
|
onClick={() => {
|
||||||
>
|
onClosePopup()
|
||||||
{t('workflow.common.copy')}
|
handleNodesCopy(id)
|
||||||
<ShortcutsName keys={['ctrl', 'c']} />
|
}}
|
||||||
</div>
|
>
|
||||||
<div
|
{t('workflow.common.copy')}
|
||||||
className='flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary hover:bg-state-base-hover'
|
<ShortcutsName keys={['ctrl', 'c']} />
|
||||||
onClick={() => {
|
</div>
|
||||||
onClosePopup()
|
<div
|
||||||
handleNodesDuplicate(id)
|
className='flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary hover:bg-state-base-hover'
|
||||||
}}
|
onClick={() => {
|
||||||
>
|
onClosePopup()
|
||||||
{t('workflow.common.duplicate')}
|
handleNodesDuplicate(id)
|
||||||
<ShortcutsName keys={['ctrl', 'd']} />
|
}}
|
||||||
</div>
|
>
|
||||||
</div>
|
{t('workflow.common.duplicate')}
|
||||||
<div className='h-px bg-divider-regular'></div>
|
<ShortcutsName keys={['ctrl', 'd']} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='h-px bg-divider-regular'></div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
{
|
{
|
||||||
!nodeMetaData.isUndeletable && (
|
!nodeMetaData.isUndeletable && (
|
||||||
<>
|
<>
|
||||||
@ -117,7 +122,7 @@ const PanelOperatorPopup = ({
|
|||||||
<div
|
<div
|
||||||
className={`
|
className={`
|
||||||
flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary
|
flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary
|
||||||
hover:bg-state-destructive-hover hover:text-red-500
|
hover:bg-state-destructive-hover hover:text-text-destructive
|
||||||
`}
|
`}
|
||||||
onClick={() => handleNodeDelete(id)}
|
onClick={() => handleNodeDelete(id)}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
const metaData = genNodeMetaData({
|
const metaData = genNodeMetaData({
|
||||||
sort: 2.1,
|
sort: 2.1,
|
||||||
type: BlockEnum.Answer,
|
type: BlockEnum.Answer,
|
||||||
|
isRequired: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<AnswerNodeType> = {
|
const nodeDefault: NodeDefault<AnswerNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
const metaData = genNodeMetaData({
|
const metaData = genNodeMetaData({
|
||||||
sort: -1,
|
sort: -1,
|
||||||
type: BlockEnum.DataSourceEmpty,
|
type: BlockEnum.DataSourceEmpty,
|
||||||
|
isUndeletable: true,
|
||||||
|
isSingleton: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<DataSourceEmptyNodeType> = {
|
const nodeDefault: NodeDefault<DataSourceEmptyNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -15,6 +15,8 @@ const i18nPrefix = 'workflow.errorMsg'
|
|||||||
const metaData = genNodeMetaData({
|
const metaData = genNodeMetaData({
|
||||||
sort: -1,
|
sort: -1,
|
||||||
type: BlockEnum.DataSource,
|
type: BlockEnum.DataSource,
|
||||||
|
isStart: true,
|
||||||
|
isRequired: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
const metaData = genNodeMetaData({
|
const metaData = genNodeMetaData({
|
||||||
sort: 2.1,
|
sort: 2.1,
|
||||||
type: BlockEnum.End,
|
type: BlockEnum.End,
|
||||||
|
isRequired: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<EndNodeType> = {
|
const nodeDefault: NodeDefault<EndNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -9,6 +9,7 @@ const metaData = genNodeMetaData({
|
|||||||
classification: BlockClassificationEnum.Logic,
|
classification: BlockClassificationEnum.Logic,
|
||||||
sort: 2,
|
sort: 2,
|
||||||
type: BlockEnum.Iteration,
|
type: BlockEnum.Iteration,
|
||||||
|
isTypeFixed: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<IterationNodeType> = {
|
const nodeDefault: NodeDefault<IterationNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -6,6 +6,10 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
const metaData = genNodeMetaData({
|
const metaData = genNodeMetaData({
|
||||||
sort: 3.1,
|
sort: 3.1,
|
||||||
type: BlockEnum.KnowledgeBase,
|
type: BlockEnum.KnowledgeBase,
|
||||||
|
isRequired: true,
|
||||||
|
isUndeletable: true,
|
||||||
|
isSingleton: true,
|
||||||
|
isTypeFixed: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
|
const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const metaData = genNodeMetaData({
|
|||||||
classification: BlockClassificationEnum.Logic,
|
classification: BlockClassificationEnum.Logic,
|
||||||
sort: 2,
|
sort: 2,
|
||||||
type: BlockEnum.LoopEnd,
|
type: BlockEnum.LoopEnd,
|
||||||
|
isSingleton: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<SimpleNodeType> = {
|
const nodeDefault: NodeDefault<SimpleNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const metaData = genNodeMetaData({
|
|||||||
sort: 3,
|
sort: 3,
|
||||||
type: BlockEnum.Loop,
|
type: BlockEnum.Loop,
|
||||||
author: 'AICT-Team',
|
author: 'AICT-Team',
|
||||||
|
isTypeFixed: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<LoopNodeType> = {
|
const nodeDefault: NodeDefault<LoopNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -6,6 +6,11 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||||||
const metaData = genNodeMetaData({
|
const metaData = genNodeMetaData({
|
||||||
sort: 0.1,
|
sort: 0.1,
|
||||||
type: BlockEnum.Start,
|
type: BlockEnum.Start,
|
||||||
|
isStart: true,
|
||||||
|
isRequired: true,
|
||||||
|
isUndeletable: true,
|
||||||
|
isSingleton: true,
|
||||||
|
isTypeFixed: true,
|
||||||
})
|
})
|
||||||
const nodeDefault: NodeDefault<StartNodeType> = {
|
const nodeDefault: NodeDefault<StartNodeType> = {
|
||||||
metaData,
|
metaData,
|
||||||
|
|||||||
@ -329,6 +329,8 @@ export type NodeDefault<T = {}> = {
|
|||||||
isRequired?: boolean
|
isRequired?: boolean
|
||||||
isUndeletable?: boolean
|
isUndeletable?: boolean
|
||||||
isStart?: boolean
|
isStart?: boolean
|
||||||
|
isSingleton?: boolean
|
||||||
|
isTypeFixed?: boolean
|
||||||
}
|
}
|
||||||
defaultValue: Partial<T>
|
defaultValue: Partial<T>
|
||||||
defaultRunInputData?: Record<string, any>
|
defaultRunInputData?: Record<string, any>
|
||||||
|
|||||||
@ -8,6 +8,11 @@ export type GenNodeMetaDataParams = {
|
|||||||
title?: string
|
title?: string
|
||||||
author?: string
|
author?: string
|
||||||
helpLinkUri?: string
|
helpLinkUri?: string
|
||||||
|
isRequired?: boolean
|
||||||
|
isUndeletable?: boolean
|
||||||
|
isStart?: boolean
|
||||||
|
isSingleton?: boolean
|
||||||
|
isTypeFixed?: boolean
|
||||||
}
|
}
|
||||||
export const genNodeMetaData = ({
|
export const genNodeMetaData = ({
|
||||||
classification = BlockClassificationEnum.Default,
|
classification = BlockClassificationEnum.Default,
|
||||||
@ -16,6 +21,11 @@ export const genNodeMetaData = ({
|
|||||||
title = '',
|
title = '',
|
||||||
author = 'Dify',
|
author = 'Dify',
|
||||||
helpLinkUri,
|
helpLinkUri,
|
||||||
|
isRequired = false,
|
||||||
|
isUndeletable = false,
|
||||||
|
isStart = false,
|
||||||
|
isSingleton = false,
|
||||||
|
isTypeFixed = false,
|
||||||
}: GenNodeMetaDataParams) => {
|
}: GenNodeMetaDataParams) => {
|
||||||
return {
|
return {
|
||||||
classification,
|
classification,
|
||||||
@ -24,5 +34,10 @@ export const genNodeMetaData = ({
|
|||||||
title,
|
title,
|
||||||
author,
|
author,
|
||||||
helpLinkUri: helpLinkUri || type,
|
helpLinkUri: helpLinkUri || type,
|
||||||
|
isRequired,
|
||||||
|
isUndeletable,
|
||||||
|
isStart,
|
||||||
|
isSingleton,
|
||||||
|
isTypeFixed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user