Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add component AkShare #1739 #2390

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
847 changes: 847 additions & 0 deletions web/src/assets/svg/akshare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/src/assets/svg/wencai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,9 @@ The above is the content you need to summarize.`,
lccp: 'Financing',
foreign_exchange: 'Foreign currency',
},
akShare: 'AkShare',
akShareDescription:
'This component can be used to obtain news information for the corresponding stock from the Eastmoney website.',
},
footer: {
profile: 'All rights reserved @ React',
Expand Down
2 changes: 2 additions & 0 deletions web/src/locales/zh-traditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ export default {
lccp: '理財',
foreign_exchange: '股票',
},
akShare: 'AkShare',
akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。',
},
footer: {
profile: '“保留所有權利 @ react”',
Expand Down
2 changes: 2 additions & 0 deletions web/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ export default {
lccp: '理财',
foreign_exchange: '股票',
},
akShare: 'AkShare',
akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。',
},
footer: {
profile: 'All rights reserved @ React',
Expand Down
20 changes: 20 additions & 0 deletions web/src/pages/flow/akshare-form/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions web/src/pages/flow/constant.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -61,6 +62,7 @@ export enum Operator {
ExeSQL = 'ExeSQL',
Switch = 'Switch',
WenCai = 'WenCai',
AkShare = 'AkShare',
}

export const operatorIconMap = {
Expand Down Expand Up @@ -88,6 +90,7 @@ export const operatorIconMap = {
[Operator.ExeSQL]: ExeSqlIcon,
[Operator.Switch]: SwitchIcon,
[Operator.WenCai]: WenCaiIcon,
[Operator.AkShare]: AkShareIcon,
};

export const operatorMap: Record<
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -270,6 +274,9 @@ export const componentMenuList = [
{
name: Operator.WenCai,
},
{
name: Operator.AkShare,
},
];

export const initialRetrievalValues = {
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -509,6 +519,7 @@ export const NodeMap = {
[Operator.ExeSQL]: 'ragNode',
[Operator.Switch]: 'categorizeNode',
[Operator.WenCai]: 'ragNode',
[Operator.AkShare]: 'ragNode',
};

export const LanguageOptions = [
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/flow/flow-drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -62,6 +63,7 @@ const FormMap = {
[Operator.ExeSQL]: ExeSQLForm,
[Operator.Switch]: SwitchForm,
[Operator.WenCai]: WenCaiForm,
[Operator.AkShare]: AkShareForm,
};

const EmptyContent = () => <div>empty</div>;
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/flow/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Operator,
RestrictedUpstreamMap,
SwitchElseTo,
initialAkShareValues,
initialArXivValues,
initialBaiduFanyiValues,
initialBaiduValues,
Expand Down Expand Up @@ -115,6 +116,7 @@ export const useInitializeOperatorParams = () => {
[Operator.ExeSQL]: initialExeSqlValues,
[Operator.Switch]: initialSwitchValues,
[Operator.WenCai]: initialWenCaiValues,
[Operator.AkShare]: initialAkShareValues,
};
}, [llmId]);

Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/flow/wencai-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down