|
|
|
|
@ -9,11 +9,8 @@ import { CUSTOM_NODE } from '@/app/components/workflow/constants'
|
|
|
|
|
|
|
|
|
|
export const processNodesWithoutDataSource = (nodes: Node[]) => {
|
|
|
|
|
let leftNode
|
|
|
|
|
let hasNoteBySystem
|
|
|
|
|
for (let i = 0; i < nodes.length; i++) {
|
|
|
|
|
const node = nodes[i]
|
|
|
|
|
if (node.type === CUSTOM_NOTE_NODE && node.data.noteBySystem)
|
|
|
|
|
hasNoteBySystem = true
|
|
|
|
|
|
|
|
|
|
if (node.data.type === BlockEnum.DataSource)
|
|
|
|
|
return nodes
|
|
|
|
|
@ -34,38 +31,36 @@ export const processNodesWithoutDataSource = (nodes: Node[]) => {
|
|
|
|
|
desc: '',
|
|
|
|
|
type: BlockEnum.DataSourceEmpty,
|
|
|
|
|
width: 240,
|
|
|
|
|
_isTempNode: true,
|
|
|
|
|
},
|
|
|
|
|
position: {
|
|
|
|
|
x: leftNode.position.x - 500,
|
|
|
|
|
y: leftNode.position.y,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
let newNoteNode
|
|
|
|
|
if (!hasNoteBySystem) {
|
|
|
|
|
newNoteNode = generateNewNode({
|
|
|
|
|
id: 'note',
|
|
|
|
|
type: CUSTOM_NOTE_NODE,
|
|
|
|
|
data: {
|
|
|
|
|
title: '',
|
|
|
|
|
desc: '',
|
|
|
|
|
type: '' as any,
|
|
|
|
|
text: '{"root":{"children":[{"children":[{"detail":0,"format":1,"mode":"normal","style":"font-size: 14px;","text":"Get started with a blank pipeline","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":1,"textStyle":"font-size: 14px;"},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":1,"textStyle":""},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A Knowledge Pipeline starts with Data Source as the starting node and ends with the knowledge base node. The general steps are: import documents from the data source → use extractor to extract document content → split and clean content into structured chunks → store in the knowledge base.","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":0,"textStyle":""},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":0,"textStyle":""},{"children":[{"children":[{"detail":0,"format":2,"mode":"normal","style":"","text":"Link to documentation","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"link","version":1,"textFormat":2,"rel":"noreferrer","target":null,"title":null,"url":"https://dify.ai"}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":2,"textStyle":""},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":0,"textStyle":""}],"direction":"ltr","format":"","indent":0,"type":"root","version":1,"textFormat":1,"textStyle":"font-size: 14px;"}}',
|
|
|
|
|
theme: NoteTheme.blue,
|
|
|
|
|
author: '',
|
|
|
|
|
showAuthor: true,
|
|
|
|
|
width: 240,
|
|
|
|
|
height: 300,
|
|
|
|
|
noteBySystem: true,
|
|
|
|
|
} as NoteNodeType,
|
|
|
|
|
position: {
|
|
|
|
|
x: leftNode.position.x - 500,
|
|
|
|
|
y: leftNode.position.y + 100,
|
|
|
|
|
},
|
|
|
|
|
}).newNode
|
|
|
|
|
}
|
|
|
|
|
const newNoteNode = generateNewNode({
|
|
|
|
|
id: 'note',
|
|
|
|
|
type: CUSTOM_NOTE_NODE,
|
|
|
|
|
data: {
|
|
|
|
|
title: '',
|
|
|
|
|
desc: '',
|
|
|
|
|
type: '' as any,
|
|
|
|
|
text: '{"root":{"children":[{"children":[{"detail":0,"format":1,"mode":"normal","style":"font-size: 14px;","text":"Get started with a blank pipeline","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":1,"textStyle":"font-size: 14px;"},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":1,"textStyle":""},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"A Knowledge Pipeline starts with Data Source as the starting node and ends with the knowledge base node. The general steps are: import documents from the data source → use extractor to extract document content → split and clean content into structured chunks → store in the knowledge base.","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":0,"textStyle":""},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":0,"textStyle":""},{"children":[{"children":[{"detail":0,"format":2,"mode":"normal","style":"","text":"Link to documentation","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"link","version":1,"textFormat":2,"rel":"noreferrer","target":"_blank","title":null,"url":"https://dify.ai"}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":2,"textStyle":""},{"children":[],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1,"textFormat":0,"textStyle":""}],"direction":"ltr","format":"","indent":0,"type":"root","version":1,"textFormat":1,"textStyle":"font-size: 14px;"}}',
|
|
|
|
|
theme: NoteTheme.blue,
|
|
|
|
|
author: '',
|
|
|
|
|
showAuthor: true,
|
|
|
|
|
width: 240,
|
|
|
|
|
height: 300,
|
|
|
|
|
_isTempNode: true,
|
|
|
|
|
} as NoteNodeType,
|
|
|
|
|
position: {
|
|
|
|
|
x: leftNode.position.x - 500,
|
|
|
|
|
y: leftNode.position.y + 100,
|
|
|
|
|
},
|
|
|
|
|
}).newNode
|
|
|
|
|
return [
|
|
|
|
|
newNode,
|
|
|
|
|
...(newNoteNode ? [newNoteNode] : []),
|
|
|
|
|
newNoteNode,
|
|
|
|
|
...nodes,
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|