-
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.
feat:1.新增nodewidgets自定义节点配置 2.内置switch条件节点
- Loading branch information
昔梦
committed
Dec 3, 2024
1 parent
04bda84
commit 6c07d3e
Showing
22 changed files
with
527 additions
and
80 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
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,53 @@ | ||
import React from 'react'; | ||
import XFlow from '@xrenders/xflow'; | ||
import settings from './setting'; | ||
import { Space, Tag, Typography } from 'antd'; | ||
|
||
|
||
const customNodeWidget = ({ data }) => { | ||
return <div style={{ wordWrap: "break-word" }}> | ||
<p>变量一:{data?.input}</p> | ||
<p>变量二:{data?.select}</p> | ||
</div> | ||
} | ||
|
||
|
||
const endNodeWidget = ({ data }) => { | ||
return <div style={{ wordWrap: "break-word" }}> | ||
{data?.input} | ||
</div> | ||
} | ||
|
||
|
||
const LLMNodeWidget = ({ data }) => { | ||
const labels = Object.keys(data) || []; | ||
return <Space direction='vertical'> | ||
{labels?.map(item => <Tag color='geekblue' ><Typography.Text style={{ maxWidth: 216 }} ellipsis={true}>{data[item]}</Typography.Text></Tag>)} | ||
</Space> | ||
} | ||
|
||
export default () => { | ||
const nodes = [ | ||
{ id: '1', type: 'Start', data: { input: '开始节点', select: "b" }, position: { x: 40, y: 240 } }, | ||
{ id: '2', type: 'LLM', data: { input1: 'input1' }, position: { x: 400, y: 240 } }, | ||
{ id: '3', type: 'End', data: { input: '通过nodeWidget自定义配置展示' }, position: { x: 800, y: 240 } } | ||
]; | ||
|
||
const edges = [ | ||
{ source: '1', target: '2', id: '234123' }, | ||
{ source: '2', target: '3', id: '56891' } | ||
] | ||
|
||
return ( | ||
<div style={{ height: '600px' }}> | ||
<XFlow | ||
initialValues={{ nodes, edges }} | ||
settings={settings} | ||
nodeSelector={{ | ||
showSearch: true, | ||
}} | ||
widgets={{ customNodeWidget, endNodeWidget, LLMNodeWidget }} | ||
/> | ||
</div> | ||
); | ||
} |
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,90 @@ | ||
export default [ | ||
{ | ||
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' }, | ||
], | ||
}, | ||
}, | ||
} | ||
}, | ||
nodeWidget:'customNodeWidget' | ||
}, | ||
{ | ||
title: '结束', | ||
type: 'End', | ||
hidden: true, | ||
sourceHandleHidden: true, | ||
icon: { | ||
type: 'icon-end', | ||
bgColor: '#F79009', | ||
}, | ||
settingSchema: { | ||
type: "object", | ||
properties: { | ||
input: { | ||
title: '结束原因', | ||
type: 'string', | ||
widget: 'textArea', | ||
}, | ||
} | ||
}, | ||
nodeWidget: 'endNodeWidget', | ||
}, | ||
{ | ||
title: 'LLM', | ||
type: 'LLM', | ||
description: '调用大语言模型回答问题或者对自然语言进行处理', | ||
icon: { | ||
type: 'icon-model', | ||
bgColor: '#6172F3', | ||
}, | ||
settingSchema: { | ||
type: 'object', | ||
displayType: 'row', | ||
labelCol: 6, | ||
fieldCol:18, | ||
properties: { | ||
input1: { | ||
title: 'Field A', | ||
type: 'string', | ||
}, | ||
input2: { | ||
title: 'Field B', | ||
type: 'string' | ||
}, | ||
input3: { | ||
title: 'Field C', | ||
type: 'string' | ||
}, | ||
input4: { | ||
title: 'Field D', | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
nodeWidget: 'LLMNodeWidget', | ||
}, | ||
]; |
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,23 @@ | ||
import React from 'react'; | ||
import XFlow from '@xrenders/xflow'; | ||
import settings from './setting'; | ||
|
||
export default () => { | ||
const nodes = [ | ||
{ id: '1', type: 'Switch', data: { input: '开始节点', select: "b" }, position: { x: 40, y: 240 } }, | ||
]; | ||
|
||
const edges = [] | ||
|
||
return ( | ||
<div style={{ height: '600px' }}> | ||
<XFlow | ||
initialValues={{ nodes, edges }} | ||
settings={settings} | ||
nodeSelector={{ | ||
showSearch: true, | ||
}} | ||
/> | ||
</div> | ||
); | ||
} |
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,29 @@ | ||
export default [ | ||
{ | ||
title: 'Switch', | ||
type: 'Switch', | ||
description: '允许你根据 if/else 条件将 workflow 拆分成两个分支', | ||
icon: { | ||
type: 'icon-switch', | ||
bgColor: '#06AED4', | ||
}, | ||
}, | ||
{ | ||
title: 'Prompt', | ||
type: 'Prompt', | ||
description: '通过精心设计提示词,提升大语言模型回答效果', | ||
icon: { | ||
type: 'icon-prompt', | ||
bgColor: '#17B26A', | ||
}, | ||
}, | ||
{ | ||
title: '知识库', | ||
type: 'knowledge', | ||
description: '允许你从知识库中查询与用户问题相关的文本内容', | ||
icon: { | ||
type: 'icon-knowledge', | ||
bgColor: '#6172F3', | ||
}, | ||
}, | ||
]; |
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,13 @@ | ||
--- | ||
order: 4 | ||
title: '内置节点' | ||
mobile: false | ||
group: | ||
title: 最佳展示 | ||
order: 2 | ||
--- | ||
# 内置节点 | ||
|
||
## 条件内置节点 | ||
SwitchNode | ||
<code src="./demo/switchNode/index.tsx"></code> |
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.