feat: Add component AkShare #1739 (#2390)

### What problem does this PR solve?

 feat: Add component AkShare #1739

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-09-12 17:58:05 +08:00
committed by GitHub
parent 5f9cb16a3c
commit 4158697fe6
10 changed files with 891 additions and 2 deletions

View File

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

View File

@@ -1,3 +1,4 @@
import { ReactComponent as AkShareIcon } from '@/assets/svg/akshare.svg';
import { ReactComponent as ArXivIcon } from '@/assets/svg/arxiv.svg';
import { ReactComponent as baiduFanyiIcon } from '@/assets/svg/baidu-fanyi.svg';
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
@@ -61,6 +62,7 @@ export enum Operator {
ExeSQL = 'ExeSQL',
Switch = 'Switch',
WenCai = 'WenCai',
AkShare = 'AkShare',
}
export const operatorIconMap = {
@@ -88,6 +90,7 @@ export const operatorIconMap = {
[Operator.ExeSQL]: ExeSqlIcon,
[Operator.Switch]: SwitchIcon,
[Operator.WenCai]: WenCaiIcon,
[Operator.AkShare]: AkShareIcon,
};
export const operatorMap: Record<
@@ -198,6 +201,7 @@ export const operatorMap: Record<
[Operator.ExeSQL]: { backgroundColor: '#b9efe8' },
[Operator.Switch]: { backgroundColor: '#dbaff6' },
[Operator.WenCai]: { backgroundColor: '#faac5b' },
[Operator.AkShare]: { backgroundColor: '#8085f5' },
};
export const componentMenuList = [
@@ -270,6 +274,9 @@ export const componentMenuList = [
{
name: Operator.WenCai,
},
{
name: Operator.AkShare,
},
];
export const initialRetrievalValues = {
@@ -411,6 +418,8 @@ export const initialSwitchValues = { conditions: [] };
export const initialWenCaiValues = { top_n: 20, query_type: 'stock' };
export const initialAkShareValues = { top_n: 10 };
export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 },
{ top: 8, right: 18 },
@@ -482,6 +491,7 @@ export const RestrictedUpstreamMap = {
[Operator.ExeSQL]: [Operator.Begin],
[Operator.Switch]: [Operator.Begin],
[Operator.WenCai]: [Operator.Begin],
[Operator.AkShare]: [Operator.Begin],
};
export const NodeMap = {
@@ -509,6 +519,7 @@ export const NodeMap = {
[Operator.ExeSQL]: 'ragNode',
[Operator.Switch]: 'categorizeNode',
[Operator.WenCai]: 'ragNode',
[Operator.AkShare]: 'ragNode',
};
export const LanguageOptions = [

View File

@@ -3,6 +3,7 @@ import { IModalProps } from '@/interfaces/common';
import { Drawer, Flex, Form, Input } from 'antd';
import { useEffect } from 'react';
import { Node } from 'reactflow';
import AkShareForm from '../akshare-form';
import AnswerForm from '../answer-form';
import ArXivForm from '../arxiv-form';
import BaiduFanyiForm from '../baidu-fanyi-form';
@@ -62,6 +63,7 @@ const FormMap = {
[Operator.ExeSQL]: ExeSQLForm,
[Operator.Switch]: SwitchForm,
[Operator.WenCai]: WenCaiForm,
[Operator.AkShare]: AkShareForm,
};
const EmptyContent = () => <div>empty</div>;

View File

@@ -31,6 +31,7 @@ import {
Operator,
RestrictedUpstreamMap,
SwitchElseTo,
initialAkShareValues,
initialArXivValues,
initialBaiduFanyiValues,
initialBaiduValues,
@@ -115,6 +116,7 @@ export const useInitializeOperatorParams = () => {
[Operator.ExeSQL]: initialExeSqlValues,
[Operator.Switch]: initialSwitchValues,
[Operator.WenCai]: initialWenCaiValues,
[Operator.AkShare]: initialAkShareValues,
};
}, [llmId]);

View File

@@ -24,7 +24,7 @@ const WenCaiForm = ({ onValuesChange, form }: IOperatorForm) => {
form={form}
onValuesChange={onValuesChange}
>
<TopNItem initialValue={10} max={99}></TopNItem>
<TopNItem initialValue={20} max={99}></TopNItem>
<Form.Item label={t('queryType')} name={'query_type'}>
<Select options={wenCaiQueryTypeOptions}></Select>
</Form.Item>