feat: add KeywordExtractForm and BaiduForm and DuckDuckGoForm #918 (#1477)

### 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)
This commit is contained in:
balibabu 2024-07-12 11:37:31 +08:00 committed by GitHub
parent ddeac9ab3d
commit 575099df2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 99 additions and 28 deletions

View File

@ -598,6 +598,15 @@ The above is the content you need to summarize.`,
addItem: 'Add Item',
nameRequiredMsg: 'Name is required',
nameRepeatedMsg: 'The name cannot be repeated',
keywordExtract: 'KeywordExtract',
keywordExtractDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
baidu: 'Baidu',
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.`,
duckDuckGo: 'DuckDuckGo',
duckDuckGoDescription:
'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.',
channel: 'Channel',
channelTip: 'channelTip',
},
footer: {
profile: 'All rights reserved @ React',

View File

@ -0,0 +1,20 @@
import TopNItem from '@/components/top-n-item';
import { Form } from 'antd';
import { IOperatorForm } from '../interface';
const BaiduForm = ({ onValuesChange, form }: IOperatorForm) => {
return (
<Form
name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
form={form}
onValuesChange={onValuesChange}
>
<TopNItem></TopNItem>
</Form>
);
};
export default BaiduForm;

View File

@ -1,5 +1,4 @@
import { useTranslate } from '@/hooks/commonHooks';
import type { FormProps } from 'antd';
import { Form, Input } from 'antd';
import { IOperatorForm } from '../interface';
@ -7,14 +6,6 @@ type FieldType = {
prologue?: string;
};
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
console.log('Success:', values);
};
const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
console.log('Failed:', errorInfo);
};
const BeginForm = ({ onValuesChange, form }: IOperatorForm) => {
const { t } = useTranslate('chat');
@ -23,10 +14,6 @@ const BeginForm = ({ onValuesChange, form }: IOperatorForm) => {
name="basic"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
style={{ maxWidth: 600 }}
initialValues={{ remember: true }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
onValuesChange={onValuesChange}
autoComplete="off"
form={form}

View File

@ -52,11 +52,11 @@ export function RagNode({
>
<OperatorIcon
name={data.label as Operator}
fontSize={style['iconFontSize'] ?? 24}
fontSize={style?.iconFontSize ?? 24}
></OperatorIcon>
<span
className={styles.type}
style={{ fontSize: style.fontSize ?? 14 }}
style={{ fontSize: style?.fontSize ?? 14 }}
>
{t(lowerFirst(data.label))}
</span>

View File

@ -125,18 +125,18 @@ export const componentMenuList = [
name: Operator.RewriteQuestion,
description: operatorMap[Operator.RewriteQuestion].description,
},
// {
// name: Operator.KeywordExtract,
// description: operatorMap[Operator.Message].description,
// },
// {
// name: Operator.DuckDuckGo,
// description: operatorMap[Operator.Relevant].description,
// },
// {
// name: Operator.Baidu,
// description: operatorMap[Operator.RewriteQuestion].description,
// },
{
name: Operator.KeywordExtract,
description: operatorMap[Operator.Message].description,
},
{
name: Operator.DuckDuckGo,
description: operatorMap[Operator.Relevant].description,
},
{
name: Operator.Baidu,
description: operatorMap[Operator.RewriteQuestion].description,
},
];
export const initialRetrievalValues = {

View File

@ -0,0 +1,30 @@
import TopNItem from '@/components/top-n-item';
import { useTranslate } from '@/hooks/commonHooks';
import { Form, Input } from 'antd';
import { IOperatorForm } from '../interface';
const DuckDuckGoForm = ({ onValuesChange, form }: IOperatorForm) => {
const { t } = useTranslate('flow');
return (
<Form
name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
form={form}
onValuesChange={onValuesChange}
>
<TopNItem></TopNItem>
<Form.Item
label={t('channel')}
name={'channel'}
tooltip={t('channelTip')}
>
<Input.TextArea rows={5} />
</Form.Item>
</Form>
);
};
export default DuckDuckGoForm;

View File

@ -4,11 +4,14 @@ import { Drawer, Flex, Form, Input } from 'antd';
import { useEffect } from 'react';
import { Node } from 'reactflow';
import AnswerForm from '../answer-form';
import BaiduForm from '../baidu-form';
import BeginForm from '../begin-form';
import CategorizeForm from '../categorize-form';
import { Operator } from '../constant';
import DuckDuckGoForm from '../duckduckgo-form';
import GenerateForm from '../generate-form';
import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
import KeywordExtractForm from '../keyword-extract-form';
import MessageForm from '../message-form';
import OperatorIcon from '../operator-icon';
import RelevantForm from '../relevant-form';
@ -30,6 +33,9 @@ const FormMap = {
[Operator.Message]: MessageForm,
[Operator.Relevant]: RelevantForm,
[Operator.RewriteQuestion]: RewriteQuestionForm,
[Operator.Baidu]: BaiduForm,
[Operator.DuckDuckGo]: DuckDuckGoForm,
[Operator.KeywordExtract]: KeywordExtractForm,
};
const EmptyContent = () => <div>empty</div>;

View File

@ -0,0 +1,20 @@
import TopNItem from '@/components/top-n-item';
import { Form } from 'antd';
import { IOperatorForm } from '../interface';
const KeywordExtractForm = ({ onValuesChange, form }: IOperatorForm) => {
return (
<Form
name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
form={form}
onValuesChange={onValuesChange}
>
<TopNItem></TopNItem>
</Form>
);
};
export default KeywordExtractForm;

View File

@ -27,7 +27,6 @@ const MessageForm = ({ onValuesChange, form }: IOperatorForm) => {
<Form
name="basic"
{...formItemLayoutWithOutLabel}
initialValues={{ remember: true }}
onValuesChange={onValuesChange}
autoComplete="off"
form={form}