balibabu
commited on
Commit
·
6e0d24d
1
Parent(s):
f6c384e
feat: add KeywordExtractForm and BaiduForm and DuckDuckGoForm #918 (#1477)
Browse files### What problem does this PR solve?
feat: add KeywordExtractForm and BaiduForm and DuckDuckGoForm #918
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/locales/en.ts +9 -0
- web/src/pages/flow/baidu-form/index.tsx +20 -0
- web/src/pages/flow/begin-form/index.tsx +0 -13
- web/src/pages/flow/canvas/node/index.tsx +2 -2
- web/src/pages/flow/constant.tsx +12 -12
- web/src/pages/flow/duckduckgo-form/index.tsx +30 -0
- web/src/pages/flow/flow-drawer/index.tsx +6 -0
- web/src/pages/flow/keyword-extract-form/index.tsx +20 -0
- web/src/pages/flow/message-form/index.tsx +0 -1
web/src/locales/en.ts
CHANGED
|
@@ -598,6 +598,15 @@ The above is the content you need to summarize.`,
|
|
| 598 |
addItem: 'Add Item',
|
| 599 |
nameRequiredMsg: 'Name is required',
|
| 600 |
nameRepeatedMsg: 'The name cannot be repeated',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
},
|
| 602 |
footer: {
|
| 603 |
profile: 'All rights reserved @ React',
|
|
|
|
| 598 |
addItem: 'Add Item',
|
| 599 |
nameRequiredMsg: 'Name is required',
|
| 600 |
nameRepeatedMsg: 'The name cannot be repeated',
|
| 601 |
+
keywordExtract: 'KeywordExtract',
|
| 602 |
+
keywordExtractDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
|
| 603 |
+
baidu: 'Baidu',
|
| 604 |
+
baiduDescription: `This component is used to get search result from www.baidu.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.`,
|
| 605 |
+
duckDuckGo: 'DuckDuckGo',
|
| 606 |
+
duckDuckGoDescription:
|
| 607 |
+
'This component is used to get search result from www.duckduckgo.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.',
|
| 608 |
+
channel: 'Channel',
|
| 609 |
+
channelTip: 'channelTip',
|
| 610 |
},
|
| 611 |
footer: {
|
| 612 |
profile: 'All rights reserved @ React',
|
web/src/pages/flow/baidu-form/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import TopNItem from '@/components/top-n-item';
|
| 2 |
+
import { Form } from 'antd';
|
| 3 |
+
import { IOperatorForm } from '../interface';
|
| 4 |
+
|
| 5 |
+
const BaiduForm = ({ onValuesChange, form }: IOperatorForm) => {
|
| 6 |
+
return (
|
| 7 |
+
<Form
|
| 8 |
+
name="basic"
|
| 9 |
+
labelCol={{ span: 6 }}
|
| 10 |
+
wrapperCol={{ span: 18 }}
|
| 11 |
+
autoComplete="off"
|
| 12 |
+
form={form}
|
| 13 |
+
onValuesChange={onValuesChange}
|
| 14 |
+
>
|
| 15 |
+
<TopNItem></TopNItem>
|
| 16 |
+
</Form>
|
| 17 |
+
);
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
export default BaiduForm;
|
web/src/pages/flow/begin-form/index.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import { useTranslate } from '@/hooks/commonHooks';
|
| 2 |
-
import type { FormProps } from 'antd';
|
| 3 |
import { Form, Input } from 'antd';
|
| 4 |
import { IOperatorForm } from '../interface';
|
| 5 |
|
|
@@ -7,14 +6,6 @@ type FieldType = {
|
|
| 7 |
prologue?: string;
|
| 8 |
};
|
| 9 |
|
| 10 |
-
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
| 11 |
-
console.log('Success:', values);
|
| 12 |
-
};
|
| 13 |
-
|
| 14 |
-
const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
|
| 15 |
-
console.log('Failed:', errorInfo);
|
| 16 |
-
};
|
| 17 |
-
|
| 18 |
const BeginForm = ({ onValuesChange, form }: IOperatorForm) => {
|
| 19 |
const { t } = useTranslate('chat');
|
| 20 |
|
|
@@ -23,10 +14,6 @@ const BeginForm = ({ onValuesChange, form }: IOperatorForm) => {
|
|
| 23 |
name="basic"
|
| 24 |
labelCol={{ span: 8 }}
|
| 25 |
wrapperCol={{ span: 16 }}
|
| 26 |
-
style={{ maxWidth: 600 }}
|
| 27 |
-
initialValues={{ remember: true }}
|
| 28 |
-
onFinish={onFinish}
|
| 29 |
-
onFinishFailed={onFinishFailed}
|
| 30 |
onValuesChange={onValuesChange}
|
| 31 |
autoComplete="off"
|
| 32 |
form={form}
|
|
|
|
| 1 |
import { useTranslate } from '@/hooks/commonHooks';
|
|
|
|
| 2 |
import { Form, Input } from 'antd';
|
| 3 |
import { IOperatorForm } from '../interface';
|
| 4 |
|
|
|
|
| 6 |
prologue?: string;
|
| 7 |
};
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
const BeginForm = ({ onValuesChange, form }: IOperatorForm) => {
|
| 10 |
const { t } = useTranslate('chat');
|
| 11 |
|
|
|
|
| 14 |
name="basic"
|
| 15 |
labelCol={{ span: 8 }}
|
| 16 |
wrapperCol={{ span: 16 }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
onValuesChange={onValuesChange}
|
| 18 |
autoComplete="off"
|
| 19 |
form={form}
|
web/src/pages/flow/canvas/node/index.tsx
CHANGED
|
@@ -52,11 +52,11 @@ export function RagNode({
|
|
| 52 |
>
|
| 53 |
<OperatorIcon
|
| 54 |
name={data.label as Operator}
|
| 55 |
-
fontSize={style
|
| 56 |
></OperatorIcon>
|
| 57 |
<span
|
| 58 |
className={styles.type}
|
| 59 |
-
style={{ fontSize: style
|
| 60 |
>
|
| 61 |
{t(lowerFirst(data.label))}
|
| 62 |
</span>
|
|
|
|
| 52 |
>
|
| 53 |
<OperatorIcon
|
| 54 |
name={data.label as Operator}
|
| 55 |
+
fontSize={style?.iconFontSize ?? 24}
|
| 56 |
></OperatorIcon>
|
| 57 |
<span
|
| 58 |
className={styles.type}
|
| 59 |
+
style={{ fontSize: style?.fontSize ?? 14 }}
|
| 60 |
>
|
| 61 |
{t(lowerFirst(data.label))}
|
| 62 |
</span>
|
web/src/pages/flow/constant.tsx
CHANGED
|
@@ -125,18 +125,18 @@ export const componentMenuList = [
|
|
| 125 |
name: Operator.RewriteQuestion,
|
| 126 |
description: operatorMap[Operator.RewriteQuestion].description,
|
| 127 |
},
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
];
|
| 141 |
|
| 142 |
export const initialRetrievalValues = {
|
|
|
|
| 125 |
name: Operator.RewriteQuestion,
|
| 126 |
description: operatorMap[Operator.RewriteQuestion].description,
|
| 127 |
},
|
| 128 |
+
{
|
| 129 |
+
name: Operator.KeywordExtract,
|
| 130 |
+
description: operatorMap[Operator.Message].description,
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
name: Operator.DuckDuckGo,
|
| 134 |
+
description: operatorMap[Operator.Relevant].description,
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
name: Operator.Baidu,
|
| 138 |
+
description: operatorMap[Operator.RewriteQuestion].description,
|
| 139 |
+
},
|
| 140 |
];
|
| 141 |
|
| 142 |
export const initialRetrievalValues = {
|
web/src/pages/flow/duckduckgo-form/index.tsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import TopNItem from '@/components/top-n-item';
|
| 2 |
+
import { useTranslate } from '@/hooks/commonHooks';
|
| 3 |
+
import { Form, Input } from 'antd';
|
| 4 |
+
import { IOperatorForm } from '../interface';
|
| 5 |
+
|
| 6 |
+
const DuckDuckGoForm = ({ onValuesChange, form }: IOperatorForm) => {
|
| 7 |
+
const { t } = useTranslate('flow');
|
| 8 |
+
|
| 9 |
+
return (
|
| 10 |
+
<Form
|
| 11 |
+
name="basic"
|
| 12 |
+
labelCol={{ span: 6 }}
|
| 13 |
+
wrapperCol={{ span: 18 }}
|
| 14 |
+
autoComplete="off"
|
| 15 |
+
form={form}
|
| 16 |
+
onValuesChange={onValuesChange}
|
| 17 |
+
>
|
| 18 |
+
<TopNItem></TopNItem>
|
| 19 |
+
<Form.Item
|
| 20 |
+
label={t('channel')}
|
| 21 |
+
name={'channel'}
|
| 22 |
+
tooltip={t('channelTip')}
|
| 23 |
+
>
|
| 24 |
+
<Input.TextArea rows={5} />
|
| 25 |
+
</Form.Item>
|
| 26 |
+
</Form>
|
| 27 |
+
);
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
export default DuckDuckGoForm;
|
web/src/pages/flow/flow-drawer/index.tsx
CHANGED
|
@@ -4,11 +4,14 @@ import { Drawer, Flex, Form, Input } from 'antd';
|
|
| 4 |
import { useEffect } from 'react';
|
| 5 |
import { Node } from 'reactflow';
|
| 6 |
import AnswerForm from '../answer-form';
|
|
|
|
| 7 |
import BeginForm from '../begin-form';
|
| 8 |
import CategorizeForm from '../categorize-form';
|
| 9 |
import { Operator } from '../constant';
|
|
|
|
| 10 |
import GenerateForm from '../generate-form';
|
| 11 |
import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
|
|
|
|
| 12 |
import MessageForm from '../message-form';
|
| 13 |
import OperatorIcon from '../operator-icon';
|
| 14 |
import RelevantForm from '../relevant-form';
|
|
@@ -30,6 +33,9 @@ const FormMap = {
|
|
| 30 |
[Operator.Message]: MessageForm,
|
| 31 |
[Operator.Relevant]: RelevantForm,
|
| 32 |
[Operator.RewriteQuestion]: RewriteQuestionForm,
|
|
|
|
|
|
|
|
|
|
| 33 |
};
|
| 34 |
|
| 35 |
const EmptyContent = () => <div>empty</div>;
|
|
|
|
| 4 |
import { useEffect } from 'react';
|
| 5 |
import { Node } from 'reactflow';
|
| 6 |
import AnswerForm from '../answer-form';
|
| 7 |
+
import BaiduForm from '../baidu-form';
|
| 8 |
import BeginForm from '../begin-form';
|
| 9 |
import CategorizeForm from '../categorize-form';
|
| 10 |
import { Operator } from '../constant';
|
| 11 |
+
import DuckDuckGoForm from '../duckduckgo-form';
|
| 12 |
import GenerateForm from '../generate-form';
|
| 13 |
import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
|
| 14 |
+
import KeywordExtractForm from '../keyword-extract-form';
|
| 15 |
import MessageForm from '../message-form';
|
| 16 |
import OperatorIcon from '../operator-icon';
|
| 17 |
import RelevantForm from '../relevant-form';
|
|
|
|
| 33 |
[Operator.Message]: MessageForm,
|
| 34 |
[Operator.Relevant]: RelevantForm,
|
| 35 |
[Operator.RewriteQuestion]: RewriteQuestionForm,
|
| 36 |
+
[Operator.Baidu]: BaiduForm,
|
| 37 |
+
[Operator.DuckDuckGo]: DuckDuckGoForm,
|
| 38 |
+
[Operator.KeywordExtract]: KeywordExtractForm,
|
| 39 |
};
|
| 40 |
|
| 41 |
const EmptyContent = () => <div>empty</div>;
|
web/src/pages/flow/keyword-extract-form/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import TopNItem from '@/components/top-n-item';
|
| 2 |
+
import { Form } from 'antd';
|
| 3 |
+
import { IOperatorForm } from '../interface';
|
| 4 |
+
|
| 5 |
+
const KeywordExtractForm = ({ onValuesChange, form }: IOperatorForm) => {
|
| 6 |
+
return (
|
| 7 |
+
<Form
|
| 8 |
+
name="basic"
|
| 9 |
+
labelCol={{ span: 6 }}
|
| 10 |
+
wrapperCol={{ span: 18 }}
|
| 11 |
+
autoComplete="off"
|
| 12 |
+
form={form}
|
| 13 |
+
onValuesChange={onValuesChange}
|
| 14 |
+
>
|
| 15 |
+
<TopNItem></TopNItem>
|
| 16 |
+
</Form>
|
| 17 |
+
);
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
export default KeywordExtractForm;
|
web/src/pages/flow/message-form/index.tsx
CHANGED
|
@@ -27,7 +27,6 @@ const MessageForm = ({ onValuesChange, form }: IOperatorForm) => {
|
|
| 27 |
<Form
|
| 28 |
name="basic"
|
| 29 |
{...formItemLayoutWithOutLabel}
|
| 30 |
-
initialValues={{ remember: true }}
|
| 31 |
onValuesChange={onValuesChange}
|
| 32 |
autoComplete="off"
|
| 33 |
form={form}
|
|
|
|
| 27 |
<Form
|
| 28 |
name="basic"
|
| 29 |
{...formItemLayoutWithOutLabel}
|
|
|
|
| 30 |
onValuesChange={onValuesChange}
|
| 31 |
autoComplete="off"
|
| 32 |
form={form}
|