balibabu commited on
Commit
99e5e05
·
1 Parent(s): 38ccbb8

feat: Add SwitchForm #1739 (#1994)

Browse files

### What problem does this PR solve?

feat: Add SwitchForm #1739

### Type of change


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

web/src/assets/svg/switch.svg ADDED
web/src/locales/en.ts CHANGED
@@ -806,6 +806,7 @@ The above is the content you need to summarize.`,
806
  host: 'Host',
807
  port: 'Port',
808
  password: 'Password',
 
809
  },
810
  footer: {
811
  profile: 'All rights reserved @ React',
 
806
  host: 'Host',
807
  port: 'Port',
808
  password: 'Password',
809
+ switch: 'Switch',
810
  },
811
  footer: {
812
  profile: 'All rights reserved @ React',
web/src/locales/zh-traditional.ts CHANGED
@@ -764,6 +764,7 @@ export default {
764
  host: '主機',
765
  port: '端口',
766
  password: '密碼',
 
767
  },
768
  footer: {
769
  profile: '“保留所有權利 @ react”',
 
764
  host: '主機',
765
  port: '端口',
766
  password: '密碼',
767
+ switch: '條件',
768
  },
769
  footer: {
770
  profile: '“保留所有權利 @ react”',
web/src/locales/zh.ts CHANGED
@@ -782,6 +782,7 @@ export default {
782
  host: '主机',
783
  port: '端口',
784
  password: '密码',
 
785
  },
786
  footer: {
787
  profile: 'All rights reserved @ React',
 
782
  host: '主机',
783
  port: '端口',
784
  password: '密码',
785
+ switch: '条件',
786
  },
787
  footer: {
788
  profile: 'All rights reserved @ React',
web/src/pages/flow/constant.tsx CHANGED
@@ -11,6 +11,7 @@ import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
11
  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 WikipediaIcon } from '@/assets/svg/wikipedia.svg';
15
 
16
  import { variableEnabledFieldMap } from '@/constants/chat';
@@ -57,6 +58,7 @@ export enum Operator {
57
  BaiduFanyi = 'BaiduFanyi',
58
  QWeather = 'QWeather',
59
  ExeSQL = 'ExeSQL',
 
60
  }
61
 
62
  export const operatorIconMap = {
@@ -82,6 +84,7 @@ export const operatorIconMap = {
82
  [Operator.BaiduFanyi]: baiduFanyiIcon,
83
  [Operator.QWeather]: QWeatherIcon,
84
  [Operator.ExeSQL]: ExeSqlIcon,
 
85
  };
86
 
87
  export const operatorMap = {
@@ -178,6 +181,7 @@ export const operatorMap = {
178
  [Operator.BaiduFanyi]: { backgroundColor: '#e5f2d3' },
179
  [Operator.QWeather]: { backgroundColor: '#a4bbf3' },
180
  [Operator.ExeSQL]: { backgroundColor: '#b9efe8' },
 
181
  };
182
 
183
  export const componentMenuList = [
@@ -205,6 +209,9 @@ export const componentMenuList = [
205
  {
206
  name: Operator.KeywordExtract,
207
  },
 
 
 
208
  {
209
  name: Operator.DuckDuckGo,
210
  },
@@ -381,6 +388,8 @@ export const initialExeSqlValues = {
381
  top_n: 30,
382
  };
383
 
 
 
384
  export const CategorizeAnchorPointPositions = [
385
  { top: 1, right: 34 },
386
  { top: 8, right: 18 },
@@ -450,6 +459,7 @@ export const RestrictedUpstreamMap = {
450
  [Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval],
451
  [Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
452
  [Operator.ExeSQL]: [Operator.Begin],
 
453
  };
454
 
455
  export const NodeMap = {
@@ -475,6 +485,7 @@ export const NodeMap = {
475
  [Operator.BaiduFanyi]: 'ragNode',
476
  [Operator.QWeather]: 'ragNode',
477
  [Operator.ExeSQL]: 'ragNode',
 
478
  };
479
 
480
  export const LanguageOptions = [
 
11
  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';
 
58
  BaiduFanyi = 'BaiduFanyi',
59
  QWeather = 'QWeather',
60
  ExeSQL = 'ExeSQL',
61
+ Switch = 'Switch',
62
  }
63
 
64
  export const operatorIconMap = {
 
84
  [Operator.BaiduFanyi]: baiduFanyiIcon,
85
  [Operator.QWeather]: QWeatherIcon,
86
  [Operator.ExeSQL]: ExeSqlIcon,
87
+ [Operator.Switch]: SwitchIcon,
88
  };
89
 
90
  export const operatorMap = {
 
181
  [Operator.BaiduFanyi]: { backgroundColor: '#e5f2d3' },
182
  [Operator.QWeather]: { backgroundColor: '#a4bbf3' },
183
  [Operator.ExeSQL]: { backgroundColor: '#b9efe8' },
184
+ [Operator.Switch]: { backgroundColor: '#dbaff6' },
185
  };
186
 
187
  export const componentMenuList = [
 
209
  {
210
  name: Operator.KeywordExtract,
211
  },
212
+ {
213
+ name: Operator.Switch,
214
+ },
215
  {
216
  name: Operator.DuckDuckGo,
217
  },
 
388
  top_n: 30,
389
  };
390
 
391
+ export const initialSwitchValues = {};
392
+
393
  export const CategorizeAnchorPointPositions = [
394
  { top: 1, right: 34 },
395
  { top: 8, right: 18 },
 
459
  [Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval],
460
  [Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
461
  [Operator.ExeSQL]: [Operator.Begin],
462
+ [Operator.Switch]: [Operator.Begin, Operator.Answer, Operator.Relevant],
463
  };
464
 
465
  export const NodeMap = {
 
485
  [Operator.BaiduFanyi]: 'ragNode',
486
  [Operator.QWeather]: 'ragNode',
487
  [Operator.ExeSQL]: 'ragNode',
488
+ [Operator.Switch]: 'logicNode',
489
  };
490
 
491
  export const LanguageOptions = [
web/src/pages/flow/flow-drawer/index.tsx CHANGED
@@ -27,7 +27,9 @@ import QWeatherForm from '../qweather-form';
27
  import RelevantForm from '../relevant-form';
28
  import RetrievalForm from '../retrieval-form';
29
  import RewriteQuestionForm from '../rewrite-question-form';
 
30
  import WikipediaForm from '../wikipedia-form';
 
31
  import styles from './index.less';
32
 
33
  interface IProps {
@@ -57,6 +59,7 @@ const FormMap = {
57
  [Operator.BaiduFanyi]: BaiduFanyiForm,
58
  [Operator.QWeather]: QWeatherForm,
59
  [Operator.ExeSQL]: ExeSQLForm,
 
60
  };
61
 
62
  const EmptyContent = () => <div>empty</div>;
 
27
  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';
34
 
35
  interface IProps {
 
59
  [Operator.BaiduFanyi]: BaiduFanyiForm,
60
  [Operator.QWeather]: QWeatherForm,
61
  [Operator.ExeSQL]: ExeSQLForm,
62
+ [Operator.Switch]: SwitchForm,
63
  };
64
 
65
  const EmptyContent = () => <div>empty</div>;
web/src/pages/flow/hooks.ts CHANGED
@@ -50,6 +50,7 @@ import {
50
  initialRelevantValues,
51
  initialRetrievalValues,
52
  initialRewriteQuestionValues,
 
53
  initialWikipediaValues,
54
  } from './constant';
55
  import { ICategorizeForm, IRelevantForm } from './interface';
@@ -109,6 +110,7 @@ export const useInitializeOperatorParams = () => {
109
  [Operator.BaiduFanyi]: initialBaiduFanyiValues,
110
  [Operator.QWeather]: initialQWeatherValues,
111
  [Operator.ExeSQL]: initialExeSqlValues,
 
112
  };
113
  }, [llmId]);
114
 
 
50
  initialRelevantValues,
51
  initialRetrievalValues,
52
  initialRewriteQuestionValues,
53
+ initialSwitchValues,
54
  initialWikipediaValues,
55
  } from './constant';
56
  import { ICategorizeForm, IRelevantForm } from './interface';
 
110
  [Operator.BaiduFanyi]: initialBaiduFanyiValues,
111
  [Operator.QWeather]: initialQWeatherValues,
112
  [Operator.ExeSQL]: initialExeSqlValues,
113
+ [Operator.Switch]: initialSwitchValues,
114
  };
115
  }, [llmId]);
116
 
web/src/pages/flow/switch-form/index.tsx ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ const SwitchForm = () => {
2
+ return <div>Switch</div>;
3
+ };
4
+
5
+ export default SwitchForm;