-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1585 from alibaba/xflow
Xflow
- Loading branch information
Showing
40 changed files
with
819 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
.yarn | ||
.turbo/cookies | ||
.turbo/daemon | ||
.turbo | ||
|
||
# turbo | ||
*/*/.turbo | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import XFlow from '@xrenders/xflow'; | ||
import settings from './setting'; | ||
import React from 'react'; | ||
|
||
const customWidget = ({ data, key, item }) => { | ||
return <p style={{ wordWrap: 'break-word' }}>{item?.value}</p>; | ||
}; | ||
|
||
export default () => { | ||
const nodes = [ | ||
{ | ||
type: 'Switch', | ||
id: '2', | ||
position: { x: 171.25, y: 218.75 }, | ||
data: { switchData:[{value:"条件1"}]} | ||
}, | ||
]; | ||
|
||
const edges = []; | ||
|
||
return ( | ||
<div style={{ height: '600px' }}> | ||
<XFlow | ||
initialValues={{ nodes, edges }} | ||
settings={settings} | ||
nodeSelector={{ | ||
showSearch: true, | ||
}} | ||
widgets={{ customWidget }} | ||
/> | ||
</div> | ||
); | ||
}; |
151 changes: 151 additions & 0 deletions
151
docs/xflow/demo/switchNode/customSwitchNode/setting.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
export default [ | ||
{ | ||
title: 'Switch', | ||
type: 'Switch', | ||
description: '允许你根据 if/else 条件将 workflow 拆分成两个分支', | ||
icon: { | ||
type: 'icon-fenzhi', | ||
bgColor: '#06AED4', | ||
}, | ||
nodeWidget: "customWidget" // 自定义节点面板渲染 | ||
}, | ||
{ | ||
title: '开始', | ||
type: 'Start', | ||
hidden: true, | ||
targetHandleHidden: true, | ||
icon: { | ||
type: 'icon-start', | ||
bgColor: '#17B26A', | ||
}, | ||
settingSchema: { | ||
type: 'object', | ||
properties: { | ||
input: { | ||
title: '变量一', | ||
type: 'string', | ||
widget: 'input', | ||
}, | ||
select: { | ||
title: '变量二', | ||
type: 'string', | ||
widget: 'select', | ||
props: { | ||
options: [ | ||
{ label: 'a', value: 'a' }, | ||
{ label: 'b', value: 'b' }, | ||
{ label: 'c', value: 'c' }, | ||
], | ||
}, | ||
}, | ||
radio1: { | ||
title: '点击单选', | ||
type: 'string', | ||
widget: 'radio', | ||
props: { | ||
options: [ | ||
{ label: '早', value: 'a' }, | ||
{ label: '中', value: 'b' }, | ||
{ label: '晚', value: 'c' } | ||
] | ||
} | ||
}, | ||
textarea1: { | ||
title: '长文本', | ||
type: 'string', | ||
widget: 'textArea' | ||
}, | ||
date1: { | ||
title: '日期选择', | ||
type: 'string', | ||
widget: 'datePicker' | ||
}, | ||
dateRange1: { | ||
title: '日期范围', | ||
type: 'range', | ||
widget: 'dateRange' | ||
}, | ||
time1: { | ||
title: '时间选择', | ||
type: 'string', | ||
widget: 'timePicker' | ||
}, | ||
timeRange1: { | ||
title: '时间范围', | ||
type: 'range', | ||
widget: 'timeRange' | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
title: '结束', | ||
type: 'End', | ||
hidden: true, | ||
sourceHandleHidden: true, | ||
icon: { | ||
type: 'icon-end', | ||
bgColor: '#F79009', | ||
}, | ||
settingSchema: { | ||
type: "object", | ||
properties: { | ||
input: { | ||
title: '变量一', | ||
type: 'string', | ||
widget: 'input', | ||
}, | ||
select: { | ||
title: '变量二', | ||
type: 'string', | ||
widget: 'select', | ||
props: { | ||
options: [ | ||
{ label: 'a', value: 'a' }, | ||
{ label: 'b', value: 'b' }, | ||
{ label: 'c', value: 'c' }, | ||
], | ||
}, | ||
}, | ||
} | ||
} | ||
}, | ||
{ | ||
title: 'Prompt', | ||
type: 'Prompt', | ||
description: '通过精心设计提示词,提升大语言模型回答效果', | ||
icon: { | ||
type: 'icon-prompt', | ||
bgColor: '#17B26A', | ||
}, | ||
settingSchema: { | ||
type: "object", | ||
properties: { | ||
input: { | ||
title: '提示词', | ||
type: 'string', | ||
widget: 'textArea', | ||
}, | ||
} | ||
}, | ||
}, | ||
{ | ||
title: '知识库', | ||
type: 'knowledge', | ||
description: '允许你从知识库中查询与用户问题相关的文本内容', | ||
icon: { | ||
type: 'icon-knowledge', | ||
bgColor: '#6172F3', | ||
}, | ||
settingSchema: { | ||
type: "object", | ||
properties: { | ||
input: { | ||
title: '知识库', | ||
type: 'string', | ||
widget: 'textArea', | ||
}, | ||
} | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.