From 4158697fe6343540621615857818f23a9d1d326c Mon Sep 17 00:00:00 2001 From: balibabu Date: Thu, 12 Sep 2024 17:58:05 +0800 Subject: [PATCH] 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) --- web/src/assets/svg/akshare.svg | 847 ++++++++++++++++++++++ web/src/assets/svg/wencai.svg | 2 +- web/src/locales/en.ts | 3 + web/src/locales/zh-traditional.ts | 2 + web/src/locales/zh.ts | 2 + web/src/pages/flow/akshare-form/index.tsx | 20 + web/src/pages/flow/constant.tsx | 11 + web/src/pages/flow/flow-drawer/index.tsx | 2 + web/src/pages/flow/hooks.ts | 2 + web/src/pages/flow/wencai-form/index.tsx | 2 +- 10 files changed, 891 insertions(+), 2 deletions(-) create mode 100644 web/src/assets/svg/akshare.svg create mode 100644 web/src/pages/flow/akshare-form/index.tsx diff --git a/web/src/assets/svg/akshare.svg b/web/src/assets/svg/akshare.svg new file mode 100644 index 00000000000..debaf04bf6f --- /dev/null +++ b/web/src/assets/svg/akshare.svg @@ -0,0 +1,847 @@ + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/wencai.svg b/web/src/assets/svg/wencai.svg index e70658fa228..0010ed8af18 100644 --- a/web/src/assets/svg/wencai.svg +++ b/web/src/assets/svg/wencai.svg @@ -1,7 +1,7 @@ + y="0px" width="24px" height="24px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve"> + + + ); +}; + +export default AkShareForm; diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx index 30781dc9921..7f45bf7340f 100644 --- a/web/src/pages/flow/constant.tsx +++ b/web/src/pages/flow/constant.tsx @@ -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 = [ diff --git a/web/src/pages/flow/flow-drawer/index.tsx b/web/src/pages/flow/flow-drawer/index.tsx index 626be068a6c..f763749049e 100644 --- a/web/src/pages/flow/flow-drawer/index.tsx +++ b/web/src/pages/flow/flow-drawer/index.tsx @@ -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 = () =>
empty
; diff --git a/web/src/pages/flow/hooks.ts b/web/src/pages/flow/hooks.ts index db6c64ec4bd..508619f7198 100644 --- a/web/src/pages/flow/hooks.ts +++ b/web/src/pages/flow/hooks.ts @@ -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]); diff --git a/web/src/pages/flow/wencai-form/index.tsx b/web/src/pages/flow/wencai-form/index.tsx index 969379f01d5..14842984274 100644 --- a/web/src/pages/flow/wencai-form/index.tsx +++ b/web/src/pages/flow/wencai-form/index.tsx @@ -24,7 +24,7 @@ const WenCaiForm = ({ onValuesChange, form }: IOperatorForm) => { form={form} onValuesChange={onValuesChange} > - +