balibabu commited on
Commit
457df3d
·
1 Parent(s): ed19e93

feat: add RelevantForm #918 (#1313)

Browse files

### What problem does this PR solve?

feat: add RelevantForm #918

### Type of change


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

web/src/locales/en.ts CHANGED
@@ -556,6 +556,7 @@ The above is the content you need to summarize.`,
556
  messagePlaceholder: 'message',
557
  messageMsg: 'Please input message or delete this field.',
558
  addField: 'Add field',
 
559
  },
560
  footer: {
561
  profile: 'All rights reserved @ React',
 
556
  messagePlaceholder: 'message',
557
  messageMsg: 'Please input message or delete this field.',
558
  addField: 'Add field',
559
+ loop: 'Loop',
560
  },
561
  footer: {
562
  profile: 'All rights reserved @ React',
web/src/locales/zh-traditional.ts CHANGED
@@ -517,6 +517,7 @@ export default {
517
  messagePlaceholder: '訊息',
518
  messageMsg: '請輸入訊息或刪除此欄位。',
519
  addField: '新增字段',
 
520
  },
521
  footer: {
522
  profile: '“保留所有權利 @ react”',
 
517
  messagePlaceholder: '訊息',
518
  messageMsg: '請輸入訊息或刪除此欄位。',
519
  addField: '新增字段',
520
+ loop: '環',
521
  },
522
  footer: {
523
  profile: '“保留所有權利 @ react”',
web/src/locales/zh.ts CHANGED
@@ -535,6 +535,7 @@ export default {
535
  messagePlaceholder: '消息',
536
  messageMsg: '请输入消息或删除此字段。',
537
  addField: '新增字段',
 
538
  },
539
  footer: {
540
  profile: 'All rights reserved @ React',
 
535
  messagePlaceholder: '消息',
536
  messageMsg: '请输入消息或删除此字段。',
537
  addField: '新增字段',
538
+ loop: '环',
539
  },
540
  footer: {
541
  profile: 'All rights reserved @ React',
web/src/pages/flow/constant.tsx CHANGED
@@ -1,7 +1,9 @@
1
  import {
 
2
  DatabaseOutlined,
3
  MergeCellsOutlined,
4
  MessageOutlined,
 
5
  RocketOutlined,
6
  SendOutlined,
7
  SlidersOutlined,
@@ -14,6 +16,8 @@ export enum Operator {
14
  Answer = 'Answer',
15
  Categorize = 'Categorize',
16
  Message = 'Message',
 
 
17
  }
18
 
19
  export const operatorIconMap = {
@@ -23,6 +27,8 @@ export const operatorIconMap = {
23
  [Operator.Begin]: SlidersOutlined,
24
  [Operator.Categorize]: DatabaseOutlined,
25
  [Operator.Message]: MessageOutlined,
 
 
26
  };
27
 
28
  export const operatorMap = {
@@ -34,6 +40,8 @@ export const operatorMap = {
34
  [Operator.Begin]: { description: 'Begin description' },
35
  [Operator.Categorize]: { description: 'Categorize description' },
36
  [Operator.Message]: { description: 'Message description' },
 
 
37
  };
38
 
39
  export const componentMenuList = [
@@ -57,6 +65,14 @@ export const componentMenuList = [
57
  name: Operator.Message,
58
  description: operatorMap[Operator.Message].description,
59
  },
 
 
 
 
 
 
 
 
60
  ];
61
 
62
  export const initialRetrievalValues = {
@@ -115,6 +131,8 @@ export const RestrictedUpstreamMap = {
115
  [Operator.Retrieval]: [],
116
  [Operator.Generate]: [],
117
  [Operator.Message]: [],
 
 
118
  };
119
 
120
  export const NodeMap = {
@@ -124,4 +142,6 @@ export const NodeMap = {
124
  [Operator.Generate]: 'ragNode',
125
  [Operator.Answer]: 'ragNode',
126
  [Operator.Message]: 'ragNode',
 
 
127
  };
 
1
  import {
2
+ BranchesOutlined,
3
  DatabaseOutlined,
4
  MergeCellsOutlined,
5
  MessageOutlined,
6
+ QuestionOutlined,
7
  RocketOutlined,
8
  SendOutlined,
9
  SlidersOutlined,
 
16
  Answer = 'Answer',
17
  Categorize = 'Categorize',
18
  Message = 'Message',
19
+ Relevant = 'Relevant',
20
+ RewriteQuestion = 'RewriteQuestion',
21
  }
22
 
23
  export const operatorIconMap = {
 
27
  [Operator.Begin]: SlidersOutlined,
28
  [Operator.Categorize]: DatabaseOutlined,
29
  [Operator.Message]: MessageOutlined,
30
+ [Operator.Relevant]: BranchesOutlined,
31
+ [Operator.RewriteQuestion]: QuestionOutlined,
32
  };
33
 
34
  export const operatorMap = {
 
40
  [Operator.Begin]: { description: 'Begin description' },
41
  [Operator.Categorize]: { description: 'Categorize description' },
42
  [Operator.Message]: { description: 'Message description' },
43
+ [Operator.Relevant]: { description: 'BranchesOutlined description' },
44
+ [Operator.RewriteQuestion]: { description: 'RewriteQuestion description' },
45
  };
46
 
47
  export const componentMenuList = [
 
65
  name: Operator.Message,
66
  description: operatorMap[Operator.Message].description,
67
  },
68
+ {
69
+ name: Operator.Relevant,
70
+ description: operatorMap[Operator.Relevant].description,
71
+ },
72
+ {
73
+ name: Operator.RewriteQuestion,
74
+ description: operatorMap[Operator.RewriteQuestion].description,
75
+ },
76
  ];
77
 
78
  export const initialRetrievalValues = {
 
131
  [Operator.Retrieval]: [],
132
  [Operator.Generate]: [],
133
  [Operator.Message]: [],
134
+ [Operator.Relevant]: [],
135
+ [Operator.RewriteQuestion]: [],
136
  };
137
 
138
  export const NodeMap = {
 
142
  [Operator.Generate]: 'ragNode',
143
  [Operator.Answer]: 'ragNode',
144
  [Operator.Message]: 'ragNode',
145
+ [Operator.Relevant]: 'ragNode',
146
+ [Operator.RewriteQuestion]: 'ragNode',
147
  };
web/src/pages/flow/flow-drawer/index.tsx CHANGED
@@ -9,7 +9,9 @@ import { Operator } from '../constant';
9
  import GenerateForm from '../generate-form';
10
  import { useHandleFormValuesChange } from '../hooks';
11
  import MessageForm from '../message-form';
 
12
  import RetrievalForm from '../retrieval-form';
 
13
 
14
  interface IProps {
15
  node?: Node;
@@ -22,6 +24,8 @@ const FormMap = {
22
  [Operator.Answer]: AnswerForm,
23
  [Operator.Categorize]: CategorizeForm,
24
  [Operator.Message]: MessageForm,
 
 
25
  };
26
 
27
  const FlowDrawer = ({
 
9
  import GenerateForm from '../generate-form';
10
  import { useHandleFormValuesChange } from '../hooks';
11
  import MessageForm from '../message-form';
12
+ import RelevantForm from '../relevant-form';
13
  import RetrievalForm from '../retrieval-form';
14
+ import RewriteQuestionForm from '../rewrite-question-form';
15
 
16
  interface IProps {
17
  node?: Node;
 
24
  [Operator.Answer]: AnswerForm,
25
  [Operator.Categorize]: CategorizeForm,
26
  [Operator.Message]: MessageForm,
27
+ [Operator.Relevant]: RelevantForm,
28
+ [Operator.RewriteQuestion]: RewriteQuestionForm,
29
  };
30
 
31
  const FlowDrawer = ({
web/src/pages/flow/relevant-form/index.tsx ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import LLMSelect from '@/components/llm-select';
2
+ import { useTranslate } from '@/hooks/commonHooks';
3
+ import { Form } from 'antd';
4
+ import { useSetLlmSetting } from '../hooks';
5
+ import { IOperatorForm } from '../interface';
6
+
7
+ const RelevantForm = ({ onValuesChange, form }: IOperatorForm) => {
8
+ const { t } = useTranslate('chat');
9
+ useSetLlmSetting(form);
10
+
11
+ return (
12
+ <Form
13
+ name="basic"
14
+ labelCol={{ span: 8 }}
15
+ wrapperCol={{ span: 16 }}
16
+ style={{ maxWidth: 600 }}
17
+ initialValues={{ remember: true }}
18
+ onValuesChange={onValuesChange}
19
+ autoComplete="off"
20
+ form={form}
21
+ >
22
+ <Form.Item
23
+ name={'llm_id'}
24
+ label={t('model', { keyPrefix: 'chat' })}
25
+ tooltip={t('modelTip', { keyPrefix: 'chat' })}
26
+ >
27
+ <LLMSelect></LLMSelect>
28
+ </Form.Item>
29
+ </Form>
30
+ );
31
+ };
32
+
33
+ export default RelevantForm;
web/src/pages/flow/rewrite-question-form/index.tsx ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import LLMSelect from '@/components/llm-select';
2
+ import { useTranslate } from '@/hooks/commonHooks';
3
+ import { Form, InputNumber } from 'antd';
4
+ import { useSetLlmSetting } from '../hooks';
5
+ import { IOperatorForm } from '../interface';
6
+
7
+ const RewriteQuestionForm = ({ onValuesChange, form }: IOperatorForm) => {
8
+ const { t } = useTranslate('chat');
9
+ useSetLlmSetting(form);
10
+
11
+ return (
12
+ <Form
13
+ name="basic"
14
+ labelCol={{ span: 8 }}
15
+ wrapperCol={{ span: 16 }}
16
+ onValuesChange={onValuesChange}
17
+ autoComplete="off"
18
+ form={form}
19
+ >
20
+ <Form.Item
21
+ name={'llm_id'}
22
+ label={t('model', { keyPrefix: 'chat' })}
23
+ tooltip={t('modelTip', { keyPrefix: 'chat' })}
24
+ >
25
+ <LLMSelect></LLMSelect>
26
+ </Form.Item>
27
+ <Form.Item label={t('loop', { keyPrefix: 'flow' })} name="loop">
28
+ <InputNumber />
29
+ </Form.Item>
30
+ </Form>
31
+ );
32
+ };
33
+
34
+ export default RewriteQuestionForm;