balibabu commited on
Commit
55e7b7a
·
1 Parent(s): 6d597a0

feat: Add component WenCai #1739 (#2388)

Browse files

### What problem does this PR solve?

feat: Add component WenCai #1739

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

web/src/assets/svg/wencai.svg ADDED
web/src/locales/en.ts CHANGED
@@ -875,6 +875,23 @@ The above is the content you need to summarize.`,
875
  operator: 'Operator',
876
  value: 'Value',
877
  useTemplate: 'Use this template',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
878
  },
879
  footer: {
880
  profile: 'All rights reserved @ React',
 
875
  operator: 'Operator',
876
  value: 'Value',
877
  useTemplate: 'Use this template',
878
+ wenCai: 'WenCai',
879
+ queryType: 'Query type',
880
+ wenCaiDescription:
881
+ 'The component can be used to obtain information on a wide range of financial areas, including but not limited to stocks, funds, etc...',
882
+ wenCaiQueryTypeOptions: {
883
+ stock: 'stock',
884
+ zhishu: 'index',
885
+ fund: 'fund',
886
+ hkstock: 'Hong Kong shares',
887
+ usstock: 'US stock market',
888
+ threeboard: 'New OTC Market',
889
+ conbond: 'Convertible Bond',
890
+ insurance: 'insurance',
891
+ futures: 'futures',
892
+ lccp: 'Financing',
893
+ foreign_exchange: 'Foreign currency',
894
+ },
895
  },
896
  footer: {
897
  profile: 'All rights reserved @ React',
web/src/locales/zh-traditional.ts CHANGED
@@ -829,6 +829,23 @@ export default {
829
  operator: '操作符',
830
  value: '值',
831
  useTemplate: '使用該模板',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
  },
833
  footer: {
834
  profile: '“保留所有權利 @ react”',
 
829
  operator: '操作符',
830
  value: '值',
831
  useTemplate: '使用該模板',
832
+ wenCai: '問財',
833
+ queryType: '查詢類型',
834
+ wenCaiDescription:
835
+ '該組件可用於獲取廣泛的金融領域的信息,包括但不限於股票、基金等...',
836
+ wenCaiQueryTypeOptions: {
837
+ stock: '股票',
838
+ zhishu: '指數',
839
+ fund: '基金',
840
+ hkstock: '港股',
841
+ usstock: '美股',
842
+ threeboard: '新三板',
843
+ conbond: '可轉債',
844
+ insurance: '保險',
845
+ futures: '期貨',
846
+ lccp: '理財',
847
+ foreign_exchange: '股票',
848
+ },
849
  },
850
  footer: {
851
  profile: '“保留所有權利 @ react”',
web/src/locales/zh.ts CHANGED
@@ -847,6 +847,23 @@ export default {
847
  operator: '操作符',
848
  value: '值',
849
  useTemplate: '使用该模板',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
850
  },
851
  footer: {
852
  profile: 'All rights reserved @ React',
 
847
  operator: '操作符',
848
  value: '值',
849
  useTemplate: '使用该模板',
850
+ wenCai: '问财',
851
+ queryType: '查询类型',
852
+ wenCaiDescription:
853
+ '该组件可用于获取广泛金融领域的信息,包括但不限于股票、基金等...',
854
+ wenCaiQueryTypeOptions: {
855
+ stock: '股票',
856
+ zhishu: '指数',
857
+ fund: '基金',
858
+ hkstock: '港股',
859
+ usstock: '美股',
860
+ threeboard: '新三板',
861
+ conbond: '可转债',
862
+ insurance: '保险',
863
+ futures: '期货',
864
+ lccp: '理财',
865
+ foreign_exchange: '股票',
866
+ },
867
  },
868
  footer: {
869
  profile: 'All rights reserved @ React',
web/src/pages/flow/constant.tsx CHANGED
@@ -12,6 +12,7 @@ import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
12
  import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
13
  import { ReactComponent as QWeatherIcon } from '@/assets/svg/qweather.svg';
14
  import { ReactComponent as SwitchIcon } from '@/assets/svg/switch.svg';
 
15
  import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
16
 
17
  import { variableEnabledFieldMap } from '@/constants/chat';
@@ -59,6 +60,7 @@ export enum Operator {
59
  QWeather = 'QWeather',
60
  ExeSQL = 'ExeSQL',
61
  Switch = 'Switch',
 
62
  }
63
 
64
  export const operatorIconMap = {
@@ -85,6 +87,7 @@ export const operatorIconMap = {
85
  [Operator.QWeather]: QWeatherIcon,
86
  [Operator.ExeSQL]: ExeSqlIcon,
87
  [Operator.Switch]: SwitchIcon,
 
88
  };
89
 
90
  export const operatorMap: Record<
@@ -194,6 +197,7 @@ export const operatorMap: Record<
194
  [Operator.QWeather]: { backgroundColor: '#a4bbf3' },
195
  [Operator.ExeSQL]: { backgroundColor: '#b9efe8' },
196
  [Operator.Switch]: { backgroundColor: '#dbaff6' },
 
197
  };
198
 
199
  export const componentMenuList = [
@@ -263,6 +267,9 @@ export const componentMenuList = [
263
  {
264
  name: Operator.ExeSQL,
265
  },
 
 
 
266
  ];
267
 
268
  export const initialRetrievalValues = {
@@ -402,6 +409,8 @@ export const initialExeSqlValues = {
402
 
403
  export const initialSwitchValues = { conditions: [] };
404
 
 
 
405
  export const CategorizeAnchorPointPositions = [
406
  { top: 1, right: 34 },
407
  { top: 8, right: 18 },
@@ -472,6 +481,7 @@ export const RestrictedUpstreamMap = {
472
  [Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
473
  [Operator.ExeSQL]: [Operator.Begin],
474
  [Operator.Switch]: [Operator.Begin],
 
475
  };
476
 
477
  export const NodeMap = {
@@ -498,6 +508,7 @@ export const NodeMap = {
498
  [Operator.QWeather]: 'ragNode',
499
  [Operator.ExeSQL]: 'ragNode',
500
  [Operator.Switch]: 'categorizeNode',
 
501
  };
502
 
503
  export const LanguageOptions = [
@@ -2652,3 +2663,17 @@ export const SwitchOperatorOptions = [
2652
  ];
2653
 
2654
  export const SwitchLogicOperatorOptions = ['and', 'or'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
13
  import { ReactComponent as QWeatherIcon } from '@/assets/svg/qweather.svg';
14
  import { ReactComponent as SwitchIcon } from '@/assets/svg/switch.svg';
15
+ import { ReactComponent as WenCaiIcon } from '@/assets/svg/wencai.svg';
16
  import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
17
 
18
  import { variableEnabledFieldMap } from '@/constants/chat';
 
60
  QWeather = 'QWeather',
61
  ExeSQL = 'ExeSQL',
62
  Switch = 'Switch',
63
+ WenCai = 'WenCai',
64
  }
65
 
66
  export const operatorIconMap = {
 
87
  [Operator.QWeather]: QWeatherIcon,
88
  [Operator.ExeSQL]: ExeSqlIcon,
89
  [Operator.Switch]: SwitchIcon,
90
+ [Operator.WenCai]: WenCaiIcon,
91
  };
92
 
93
  export const operatorMap: Record<
 
197
  [Operator.QWeather]: { backgroundColor: '#a4bbf3' },
198
  [Operator.ExeSQL]: { backgroundColor: '#b9efe8' },
199
  [Operator.Switch]: { backgroundColor: '#dbaff6' },
200
+ [Operator.WenCai]: { backgroundColor: '#faac5b' },
201
  };
202
 
203
  export const componentMenuList = [
 
267
  {
268
  name: Operator.ExeSQL,
269
  },
270
+ {
271
+ name: Operator.WenCai,
272
+ },
273
  ];
274
 
275
  export const initialRetrievalValues = {
 
409
 
410
  export const initialSwitchValues = { conditions: [] };
411
 
412
+ export const initialWenCaiValues = { top_n: 20, query_type: 'stock' };
413
+
414
  export const CategorizeAnchorPointPositions = [
415
  { top: 1, right: 34 },
416
  { top: 8, right: 18 },
 
481
  [Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
482
  [Operator.ExeSQL]: [Operator.Begin],
483
  [Operator.Switch]: [Operator.Begin],
484
+ [Operator.WenCai]: [Operator.Begin],
485
  };
486
 
487
  export const NodeMap = {
 
508
  [Operator.QWeather]: 'ragNode',
509
  [Operator.ExeSQL]: 'ragNode',
510
  [Operator.Switch]: 'categorizeNode',
511
+ [Operator.WenCai]: 'ragNode',
512
  };
513
 
514
  export const LanguageOptions = [
 
2663
  ];
2664
 
2665
  export const SwitchLogicOperatorOptions = ['and', 'or'];
2666
+
2667
+ export const WenCaiQueryTypeOptions = [
2668
+ 'stock',
2669
+ 'zhishu',
2670
+ 'fund',
2671
+ 'hkstock',
2672
+ 'usstock',
2673
+ 'threeboard',
2674
+ 'conbond',
2675
+ 'insurance',
2676
+ 'futures',
2677
+ 'lccp',
2678
+ 'foreign_exchange',
2679
+ ];
web/src/pages/flow/flow-drawer/index.tsx CHANGED
@@ -28,6 +28,7 @@ import RelevantForm from '../relevant-form';
28
  import RetrievalForm from '../retrieval-form';
29
  import RewriteQuestionForm from '../rewrite-question-form';
30
  import SwitchForm from '../switch-form';
 
31
  import WikipediaForm from '../wikipedia-form';
32
 
33
  import styles from './index.less';
@@ -60,6 +61,7 @@ const FormMap = {
60
  [Operator.QWeather]: QWeatherForm,
61
  [Operator.ExeSQL]: ExeSQLForm,
62
  [Operator.Switch]: SwitchForm,
 
63
  };
64
 
65
  const EmptyContent = () => <div>empty</div>;
 
28
  import RetrievalForm from '../retrieval-form';
29
  import RewriteQuestionForm from '../rewrite-question-form';
30
  import SwitchForm from '../switch-form';
31
+ import WenCaiForm from '../wencai-form';
32
  import WikipediaForm from '../wikipedia-form';
33
 
34
  import styles from './index.less';
 
61
  [Operator.QWeather]: QWeatherForm,
62
  [Operator.ExeSQL]: ExeSQLForm,
63
  [Operator.Switch]: SwitchForm,
64
+ [Operator.WenCai]: WenCaiForm,
65
  };
66
 
67
  const EmptyContent = () => <div>empty</div>;
web/src/pages/flow/hooks.ts CHANGED
@@ -52,6 +52,7 @@ import {
52
  initialRetrievalValues,
53
  initialRewriteQuestionValues,
54
  initialSwitchValues,
 
55
  initialWikipediaValues,
56
  } from './constant';
57
  import { ICategorizeForm, IRelevantForm, ISwitchForm } from './interface';
@@ -113,6 +114,7 @@ export const useInitializeOperatorParams = () => {
113
  [Operator.QWeather]: initialQWeatherValues,
114
  [Operator.ExeSQL]: initialExeSqlValues,
115
  [Operator.Switch]: initialSwitchValues,
 
116
  };
117
  }, [llmId]);
118
 
 
52
  initialRetrievalValues,
53
  initialRewriteQuestionValues,
54
  initialSwitchValues,
55
+ initialWenCaiValues,
56
  initialWikipediaValues,
57
  } from './constant';
58
  import { ICategorizeForm, IRelevantForm, ISwitchForm } from './interface';
 
114
  [Operator.QWeather]: initialQWeatherValues,
115
  [Operator.ExeSQL]: initialExeSqlValues,
116
  [Operator.Switch]: initialSwitchValues,
117
+ [Operator.WenCai]: initialWenCaiValues,
118
  };
119
  }, [llmId]);
120
 
web/src/pages/flow/wencai-form/index.tsx ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import TopNItem from '@/components/top-n-item';
2
+ import { useTranslate } from '@/hooks/common-hooks';
3
+ import { Form, Select } from 'antd';
4
+ import { useMemo } from 'react';
5
+ import { WenCaiQueryTypeOptions } from '../constant';
6
+ import { IOperatorForm } from '../interface';
7
+
8
+ const WenCaiForm = ({ onValuesChange, form }: IOperatorForm) => {
9
+ const { t } = useTranslate('flow');
10
+
11
+ const wenCaiQueryTypeOptions = useMemo(() => {
12
+ return WenCaiQueryTypeOptions.map((x) => ({
13
+ value: x,
14
+ label: t(`wenCaiQueryTypeOptions.${x}`),
15
+ }));
16
+ }, [t]);
17
+
18
+ return (
19
+ <Form
20
+ name="basic"
21
+ labelCol={{ span: 6 }}
22
+ wrapperCol={{ span: 18 }}
23
+ autoComplete="off"
24
+ form={form}
25
+ onValuesChange={onValuesChange}
26
+ >
27
+ <TopNItem initialValue={10} max={99}></TopNItem>
28
+ <Form.Item label={t('queryType')} name={'query_type'}>
29
+ <Select options={wenCaiQueryTypeOptions}></Select>
30
+ </Form.Item>
31
+ </Form>
32
+ );
33
+ };
34
+
35
+ export default WenCaiForm;