balibabu
commited on
Commit
·
391120b
1
Parent(s):
95863fc
feat: Add InvokeNode #1908 (#3081)
Browse files### What problem does this PR solve?
feat: Add InvokeNode #1908
### Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- web/src/components/editable-cell.tsx +2 -2
- web/src/locales/en.ts +1 -0
- web/src/locales/zh-traditional.ts +1 -0
- web/src/locales/zh.ts +1 -0
- web/src/pages/flow/canvas/index.tsx +2 -0
- web/src/pages/flow/canvas/node/invoke-node.tsx +56 -0
- web/src/pages/flow/constant.tsx +2 -1
- web/src/pages/flow/flow-drawer/index.tsx +3 -3
- web/src/pages/flow/form/invoke-form/dynamic-variables.tsx +0 -1
- web/src/pages/flow/form/invoke-form/index.tsx +4 -1
web/src/components/editable-cell.tsx
CHANGED
|
@@ -78,7 +78,7 @@ export const EditableCell: React.FC<EditableCellProps> = ({
|
|
| 78 |
if (editable) {
|
| 79 |
childNode = editing ? (
|
| 80 |
<Form.Item
|
| 81 |
-
style={{ margin: 0, width:
|
| 82 |
name={dataIndex}
|
| 83 |
rules={[
|
| 84 |
{
|
|
@@ -95,7 +95,7 @@ export const EditableCell: React.FC<EditableCellProps> = ({
|
|
| 95 |
// style={{ paddingRight: 24 }}
|
| 96 |
onClick={toggleEdit}
|
| 97 |
>
|
| 98 |
-
<Text ellipsis={{ tooltip: children }} style={{ width:
|
| 99 |
{children}
|
| 100 |
</Text>
|
| 101 |
</div>
|
|
|
|
| 78 |
if (editable) {
|
| 79 |
childNode = editing ? (
|
| 80 |
<Form.Item
|
| 81 |
+
style={{ margin: 0, width: 70 }}
|
| 82 |
name={dataIndex}
|
| 83 |
rules={[
|
| 84 |
{
|
|
|
|
| 95 |
// style={{ paddingRight: 24 }}
|
| 96 |
onClick={toggleEdit}
|
| 97 |
>
|
| 98 |
+
<Text ellipsis={{ tooltip: children }} style={{ width: 70 }}>
|
| 99 |
{children}
|
| 100 |
</Text>
|
| 101 |
</div>
|
web/src/locales/en.ts
CHANGED
|
@@ -1023,6 +1023,7 @@ The above is the content you need to summarize.`,
|
|
| 1023 |
method: 'Method',
|
| 1024 |
timeout: 'Timeout',
|
| 1025 |
headers: 'Headers',
|
|
|
|
| 1026 |
},
|
| 1027 |
footer: {
|
| 1028 |
profile: 'All rights reserved @ React',
|
|
|
|
| 1023 |
method: 'Method',
|
| 1024 |
timeout: 'Timeout',
|
| 1025 |
headers: 'Headers',
|
| 1026 |
+
cleanHtml: 'Clean html',
|
| 1027 |
},
|
| 1028 |
footer: {
|
| 1029 |
profile: 'All rights reserved @ React',
|
web/src/locales/zh-traditional.ts
CHANGED
|
@@ -972,6 +972,7 @@ export default {
|
|
| 972 |
method: '方法',
|
| 973 |
timeout: '超時',
|
| 974 |
headers: '請求頭',
|
|
|
|
| 975 |
},
|
| 976 |
footer: {
|
| 977 |
profile: '“保留所有權利 @ react”',
|
|
|
|
| 972 |
method: '方法',
|
| 973 |
timeout: '超時',
|
| 974 |
headers: '請求頭',
|
| 975 |
+
cleanHtml: '清除 html',
|
| 976 |
},
|
| 977 |
footer: {
|
| 978 |
profile: '“保留所有權利 @ react”',
|
web/src/locales/zh.ts
CHANGED
|
@@ -992,6 +992,7 @@ export default {
|
|
| 992 |
method: '方法',
|
| 993 |
timeout: '超时',
|
| 994 |
headers: '请求头',
|
|
|
|
| 995 |
},
|
| 996 |
footer: {
|
| 997 |
profile: 'All rights reserved @ React',
|
|
|
|
| 992 |
method: '方法',
|
| 993 |
timeout: '超时',
|
| 994 |
headers: '请求头',
|
| 995 |
+
cleanHtml: '清除 html',
|
| 996 |
},
|
| 997 |
footer: {
|
| 998 |
profile: 'All rights reserved @ React',
|
web/src/pages/flow/canvas/index.tsx
CHANGED
|
@@ -23,6 +23,7 @@ import { RagNode } from './node';
|
|
| 23 |
import { BeginNode } from './node/begin-node';
|
| 24 |
import { CategorizeNode } from './node/categorize-node';
|
| 25 |
import { GenerateNode } from './node/generate-node';
|
|
|
|
| 26 |
import { KeywordNode } from './node/keyword-node';
|
| 27 |
import { LogicNode } from './node/logic-node';
|
| 28 |
import { MessageNode } from './node/message-node';
|
|
@@ -45,6 +46,7 @@ const nodeTypes = {
|
|
| 45 |
messageNode: MessageNode,
|
| 46 |
rewriteNode: RewriteNode,
|
| 47 |
keywordNode: KeywordNode,
|
|
|
|
| 48 |
};
|
| 49 |
|
| 50 |
const edgeTypes = {
|
|
|
|
| 23 |
import { BeginNode } from './node/begin-node';
|
| 24 |
import { CategorizeNode } from './node/categorize-node';
|
| 25 |
import { GenerateNode } from './node/generate-node';
|
| 26 |
+
import { InvokeNode } from './node/invoke-node';
|
| 27 |
import { KeywordNode } from './node/keyword-node';
|
| 28 |
import { LogicNode } from './node/logic-node';
|
| 29 |
import { MessageNode } from './node/message-node';
|
|
|
|
| 46 |
messageNode: MessageNode,
|
| 47 |
rewriteNode: RewriteNode,
|
| 48 |
keywordNode: KeywordNode,
|
| 49 |
+
invokeNode: InvokeNode,
|
| 50 |
};
|
| 51 |
|
| 52 |
const edgeTypes = {
|
web/src/pages/flow/canvas/node/invoke-node.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Flex } from 'antd';
|
| 2 |
+
import classNames from 'classnames';
|
| 3 |
+
import { get } from 'lodash';
|
| 4 |
+
import { useTranslation } from 'react-i18next';
|
| 5 |
+
import { Handle, NodeProps, Position } from 'reactflow';
|
| 6 |
+
import { NodeData } from '../../interface';
|
| 7 |
+
import { LeftHandleStyle, RightHandleStyle } from './handle-icon';
|
| 8 |
+
import styles from './index.less';
|
| 9 |
+
import NodeHeader from './node-header';
|
| 10 |
+
import NodePopover from './popover';
|
| 11 |
+
|
| 12 |
+
export function InvokeNode({
|
| 13 |
+
id,
|
| 14 |
+
data,
|
| 15 |
+
isConnectable = true,
|
| 16 |
+
selected,
|
| 17 |
+
}: NodeProps<NodeData>) {
|
| 18 |
+
const { t } = useTranslation();
|
| 19 |
+
const url = get(data, 'form.url');
|
| 20 |
+
return (
|
| 21 |
+
<NodePopover nodeId={id}>
|
| 22 |
+
<section
|
| 23 |
+
className={classNames(styles.ragNode, {
|
| 24 |
+
[styles.selectedNode]: selected,
|
| 25 |
+
})}
|
| 26 |
+
>
|
| 27 |
+
<Handle
|
| 28 |
+
id="c"
|
| 29 |
+
type="source"
|
| 30 |
+
position={Position.Left}
|
| 31 |
+
isConnectable={isConnectable}
|
| 32 |
+
className={styles.handle}
|
| 33 |
+
style={LeftHandleStyle}
|
| 34 |
+
></Handle>
|
| 35 |
+
<Handle
|
| 36 |
+
type="source"
|
| 37 |
+
position={Position.Right}
|
| 38 |
+
isConnectable={isConnectable}
|
| 39 |
+
className={styles.handle}
|
| 40 |
+
id="b"
|
| 41 |
+
style={RightHandleStyle}
|
| 42 |
+
></Handle>
|
| 43 |
+
<NodeHeader
|
| 44 |
+
id={id}
|
| 45 |
+
name={data.name}
|
| 46 |
+
label={data.label}
|
| 47 |
+
className={styles.nodeHeader}
|
| 48 |
+
></NodeHeader>
|
| 49 |
+
<Flex vertical>
|
| 50 |
+
<div>{t('flow.url')}</div>
|
| 51 |
+
<div className={styles.nodeText}>{url}</div>
|
| 52 |
+
</Flex>
|
| 53 |
+
</section>
|
| 54 |
+
</NodePopover>
|
| 55 |
+
);
|
| 56 |
+
}
|
web/src/pages/flow/constant.tsx
CHANGED
|
@@ -528,6 +528,7 @@ export const initialInvokeValues = {
|
|
| 528 |
"Connection": "keep-alive"
|
| 529 |
}`,
|
| 530 |
proxy: 'http://',
|
|
|
|
| 531 |
};
|
| 532 |
|
| 533 |
export const CategorizeAnchorPointPositions = [
|
|
@@ -643,7 +644,7 @@ export const NodeMap = {
|
|
| 643 |
[Operator.TuShare]: 'ragNode',
|
| 644 |
[Operator.Note]: 'noteNode',
|
| 645 |
[Operator.Crawler]: 'ragNode',
|
| 646 |
-
[Operator.Invoke]: '
|
| 647 |
};
|
| 648 |
|
| 649 |
export const LanguageOptions = [
|
|
|
|
| 528 |
"Connection": "keep-alive"
|
| 529 |
}`,
|
| 530 |
proxy: 'http://',
|
| 531 |
+
clean_html: false,
|
| 532 |
};
|
| 533 |
|
| 534 |
export const CategorizeAnchorPointPositions = [
|
|
|
|
| 644 |
[Operator.TuShare]: 'ragNode',
|
| 645 |
[Operator.Note]: 'noteNode',
|
| 646 |
[Operator.Crawler]: 'ragNode',
|
| 647 |
+
[Operator.Invoke]: 'invokeNode',
|
| 648 |
};
|
| 649 |
|
| 650 |
export const LanguageOptions = [
|
web/src/pages/flow/flow-drawer/index.tsx
CHANGED
|
@@ -76,8 +76,8 @@ const FormMap = {
|
|
| 76 |
[Operator.TuShare]: TuShareForm,
|
| 77 |
[Operator.Crawler]: CrawlerForm,
|
| 78 |
[Operator.Invoke]: InvokeForm,
|
| 79 |
-
[Operator.Concentrator]: <></>,
|
| 80 |
-
[Operator.Note]: <></>,
|
| 81 |
};
|
| 82 |
|
| 83 |
const EmptyContent = () => <div></div>;
|
|
@@ -135,7 +135,7 @@ const FlowDrawer = ({
|
|
| 135 |
open={visible}
|
| 136 |
getContainer={false}
|
| 137 |
mask={false}
|
| 138 |
-
width={
|
| 139 |
closeIcon={null}
|
| 140 |
>
|
| 141 |
<section className={styles.formWrapper}>
|
|
|
|
| 76 |
[Operator.TuShare]: TuShareForm,
|
| 77 |
[Operator.Crawler]: CrawlerForm,
|
| 78 |
[Operator.Invoke]: InvokeForm,
|
| 79 |
+
[Operator.Concentrator]: () => <></>,
|
| 80 |
+
[Operator.Note]: () => <></>,
|
| 81 |
};
|
| 82 |
|
| 83 |
const EmptyContent = () => <div></div>;
|
|
|
|
| 135 |
open={visible}
|
| 136 |
getContainer={false}
|
| 137 |
mask={false}
|
| 138 |
+
width={500}
|
| 139 |
closeIcon={null}
|
| 140 |
>
|
| 141 |
<section className={styles.formWrapper}>
|
web/src/pages/flow/form/invoke-form/dynamic-variables.tsx
CHANGED
|
@@ -38,7 +38,6 @@ const DynamicVariables = ({ nodeId }: IProps) => {
|
|
| 38 |
title: t('key'),
|
| 39 |
dataIndex: 'key',
|
| 40 |
key: 'key',
|
| 41 |
-
// width: 40,
|
| 42 |
onCell: (record: IInvokeVariable) => ({
|
| 43 |
record,
|
| 44 |
editable: true,
|
|
|
|
| 38 |
title: t('key'),
|
| 39 |
dataIndex: 'key',
|
| 40 |
key: 'key',
|
|
|
|
| 41 |
onCell: (record: IInvokeVariable) => ({
|
| 42 |
record,
|
| 43 |
editable: true,
|
web/src/pages/flow/form/invoke-form/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import Editor from '@monaco-editor/react';
|
| 2 |
-
import { Form, Input, InputNumber, Select, Space } from 'antd';
|
| 3 |
import { useTranslation } from 'react-i18next';
|
| 4 |
import { useSetLlmSetting } from '../../hooks';
|
| 5 |
import { IOperatorForm } from '../../interface';
|
|
@@ -63,6 +63,9 @@ const InvokeForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
|
| 63 |
<Form.Item name={'proxy'} label={t('flow.proxy')}>
|
| 64 |
<Input />
|
| 65 |
</Form.Item>
|
|
|
|
|
|
|
|
|
|
| 66 |
<DynamicVariables nodeId={node?.id}></DynamicVariables>
|
| 67 |
</Form>
|
| 68 |
</>
|
|
|
|
| 1 |
import Editor from '@monaco-editor/react';
|
| 2 |
+
import { Form, Input, InputNumber, Select, Space, Switch } from 'antd';
|
| 3 |
import { useTranslation } from 'react-i18next';
|
| 4 |
import { useSetLlmSetting } from '../../hooks';
|
| 5 |
import { IOperatorForm } from '../../interface';
|
|
|
|
| 63 |
<Form.Item name={'proxy'} label={t('flow.proxy')}>
|
| 64 |
<Input />
|
| 65 |
</Form.Item>
|
| 66 |
+
<Form.Item name={'clean_html'} label={t('flow.cleanHtml')}>
|
| 67 |
+
<Switch />
|
| 68 |
+
</Form.Item>
|
| 69 |
<DynamicVariables nodeId={node?.id}></DynamicVariables>
|
| 70 |
</Form>
|
| 71 |
</>
|