mirror of https://github.com/langgenius/dify.git
init
This commit is contained in:
parent
783f7a9b13
commit
072f5caa06
|
|
@ -26,7 +26,7 @@ const CustomConnectionLine = ({ fromX, fromY, toX, toY }: ConnectionLineComponen
|
|||
d={edgePath}
|
||||
/>
|
||||
<rect
|
||||
x={toX - 2}
|
||||
x={toX}
|
||||
y={toY - 4}
|
||||
width={2}
|
||||
height={8}
|
||||
|
|
|
|||
|
|
@ -138,15 +138,17 @@ const WorkflowWrap: FC<WorkflowProps> = ({
|
|||
useStore.setState({ draftUpdatedAt: data.updated_at })
|
||||
}, [data])
|
||||
|
||||
const startNode = {
|
||||
id: `${Date.now()}`,
|
||||
type: 'custom',
|
||||
data: nodesInitialData.start,
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100,
|
||||
},
|
||||
}
|
||||
const startNode = useMemo(() => {
|
||||
return {
|
||||
id: `${Date.now()}`,
|
||||
type: 'custom',
|
||||
data: nodesInitialData.start,
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100,
|
||||
},
|
||||
}
|
||||
}, [nodesInitialData])
|
||||
|
||||
const nodesData = useMemo(() => {
|
||||
if (nodes)
|
||||
|
|
@ -156,7 +158,7 @@ const WorkflowWrap: FC<WorkflowProps> = ({
|
|||
return data.graph.nodes
|
||||
|
||||
return [startNode]
|
||||
}, [data, nodes])
|
||||
}, [data, nodes, startNode])
|
||||
const edgesData = useMemo(() => {
|
||||
if (edges)
|
||||
return edges
|
||||
|
|
@ -165,7 +167,7 @@ const WorkflowWrap: FC<WorkflowProps> = ({
|
|||
return data.graph.edges
|
||||
|
||||
return []
|
||||
}, [data, nodes])
|
||||
}, [data, edges])
|
||||
|
||||
const handleFetchCollectionList = async () => {
|
||||
const toolsets = await fetchCollectionList()
|
||||
|
|
@ -183,16 +185,22 @@ const WorkflowWrap: FC<WorkflowProps> = ({
|
|||
handleFetchCollectionList()
|
||||
}, [])
|
||||
|
||||
if (error && appDetail) {
|
||||
syncWorkflowDraft({
|
||||
url: `/apps/${appDetail.id}/workflows/draft`,
|
||||
params: {
|
||||
graph: {
|
||||
nodes: [startNode],
|
||||
edges: [],
|
||||
},
|
||||
features: {},
|
||||
},
|
||||
if (error && !error.bodyUsed && appDetail) {
|
||||
error.json().then((err: any) => {
|
||||
if (err.code === 'draft_workflow_not_exist') {
|
||||
syncWorkflowDraft({
|
||||
url: `/apps/${appDetail.id}/workflows/draft`,
|
||||
params: {
|
||||
graph: {
|
||||
nodes: [startNode],
|
||||
edges: [],
|
||||
},
|
||||
features: {},
|
||||
},
|
||||
}).then((res) => {
|
||||
useStore.setState({ draftUpdatedAt: res.updated_at })
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -204,6 +212,9 @@ const WorkflowWrap: FC<WorkflowProps> = ({
|
|||
)
|
||||
}
|
||||
|
||||
if (!data)
|
||||
return null
|
||||
|
||||
const features = data?.features || {}
|
||||
const initialFeatures: FeaturesData = {
|
||||
opening: {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {
|
|||
memo,
|
||||
useCallback,
|
||||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import type {
|
||||
CommonNodeType,
|
||||
OnSelectBlock,
|
||||
|
|
@ -23,6 +24,7 @@ const Item = ({
|
|||
branchName,
|
||||
data,
|
||||
}: ItemProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { handleNodeChange } = useWorkflow()
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
handleNodeChange(nodeId, type, sourceHandle, toolDefaultValue)
|
||||
|
|
@ -35,10 +37,10 @@ const Item = ({
|
|||
${open && '!bg-gray-100 !flex'}
|
||||
`}
|
||||
>
|
||||
Change
|
||||
{t('workflow.panel.change')}
|
||||
</Button>
|
||||
)
|
||||
}, [])
|
||||
}, [t])
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -144,10 +144,13 @@ export const getLayoutByDagre = (nodes: Node[], edges: Edge[]) => {
|
|||
export const canRunBySingle = (nodeType: BlockEnum) => {
|
||||
return nodeType === BlockEnum.LLM
|
||||
|| nodeType === BlockEnum.KnowledgeRetrieval
|
||||
|| nodeType === BlockEnum.IfElse
|
||||
|| nodeType === BlockEnum.Code
|
||||
|| nodeType === BlockEnum.TemplateTransform
|
||||
|| nodeType === BlockEnum.QuestionClassifier
|
||||
|| nodeType === BlockEnum.HttpRequest
|
||||
|| nodeType === BlockEnum.Tool
|
||||
}
|
||||
|
||||
export const getVariables = () => {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ const translation = {
|
|||
checklist: 'Checklist',
|
||||
checklistTip: 'Make sure all issues are resolved before publishing',
|
||||
organizeBlocks: 'Organize blocks',
|
||||
change: 'Change',
|
||||
},
|
||||
nodes: {
|
||||
common: {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const translation = {
|
|||
blocks: {
|
||||
'start': '开始',
|
||||
'end': '结束',
|
||||
'direct-answer': '直接回答',
|
||||
'direct-answer': '直接回复',
|
||||
'llm': 'LLM',
|
||||
'knowledge-retrieval': '知识检索',
|
||||
'question-classifier': '问题分类器',
|
||||
|
|
@ -70,6 +70,7 @@ const translation = {
|
|||
checklist: '检查清单',
|
||||
checklistTip: '发布前确保所有问题均已解决',
|
||||
organizeBlocks: '整理节点',
|
||||
change: '更改',
|
||||
},
|
||||
nodes: {
|
||||
common: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue