balibabu commited on
Commit
c33b05f
·
1 Parent(s): f23d414

feat: Modify the modal style of creating an agent so that there are more templates in the field of view #2122 (#2123)

Browse files

### What problem does this PR solve?

feat: Modify the modal style of creating an agent so that there are more
templates in the field of view #2122

### Type of change


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

web/src/components/llm-setting-items/index.tsx CHANGED
@@ -272,7 +272,7 @@ const LlmSettingItems = ({ prefix, formItemLayout = {} }: IProps) => {
272
  >
273
  <Slider
274
  className={styles.variableSlider}
275
- max={2048}
276
  disabled={disabled}
277
  />
278
  </Form.Item>
@@ -281,7 +281,7 @@ const LlmSettingItems = ({ prefix, formItemLayout = {} }: IProps) => {
281
  <InputNumber
282
  disabled={disabled}
283
  className={styles.sliderInputNumber}
284
- max={2048}
285
  min={0}
286
  />
287
  </Form.Item>
 
272
  >
273
  <Slider
274
  className={styles.variableSlider}
275
+ max={8192}
276
  disabled={disabled}
277
  />
278
  </Form.Item>
 
281
  <InputNumber
282
  disabled={disabled}
283
  className={styles.sliderInputNumber}
284
+ max={8192}
285
  min={0}
286
  />
287
  </Form.Item>
web/src/locales/en.ts CHANGED
@@ -857,6 +857,7 @@ The above is the content you need to summarize.`,
857
  },
858
  operator: 'Operator',
859
  value: 'Value',
 
860
  },
861
  footer: {
862
  profile: 'All rights reserved @ React',
 
857
  },
858
  operator: 'Operator',
859
  value: 'Value',
860
+ useTemplate: 'Use this template',
861
  },
862
  footer: {
863
  profile: 'All rights reserved @ React',
web/src/locales/zh-traditional.ts CHANGED
@@ -812,6 +812,7 @@ export default {
812
  },
813
  operator: '操作符',
814
  value: '值',
 
815
  },
816
  footer: {
817
  profile: '“保留所有權利 @ react”',
 
812
  },
813
  operator: '操作符',
814
  value: '值',
815
+ useTemplate: '使用該模板',
816
  },
817
  footer: {
818
  profile: '“保留所有權利 @ react”',
web/src/locales/zh.ts CHANGED
@@ -830,6 +830,7 @@ export default {
830
  },
831
  operator: '操作符',
832
  value: '值',
 
833
  },
834
  footer: {
835
  profile: 'All rights reserved @ React',
 
830
  },
831
  operator: '操作符',
832
  value: '值',
833
+ useTemplate: '使用该模板',
834
  },
835
  footer: {
836
  profile: 'All rights reserved @ React',
web/src/pages/add-knowledge/components/knowledge-testing/testing-result/index.tsx CHANGED
@@ -86,10 +86,6 @@ const TestingResult = ({ handleTesting }: IProps) => {
86
  </span>
87
  {t('filesSelected')}
88
  </Space>
89
- <Space size={52}>
90
- <b>{t('hits')}</b>
91
- <b>{t('view')}</b>
92
- </Space>
93
  </Flex>
94
  ),
95
  children: (
 
86
  </span>
87
  {t('filesSelected')}
88
  </Space>
 
 
 
 
89
  </Flex>
90
  ),
91
  children: (
web/src/pages/flow/list/agent-template-modal.tsx ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { IModalManagerChildrenProps } from '@/components/modal-manager';
2
+ import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
3
+ import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
4
+ import { useSelectItem } from '@/hooks/logic-hooks';
5
+ import { Button, Card, Flex, List, Modal, Typography } from 'antd';
6
+ import { useCallback, useState } from 'react';
7
+ import CreateAgentModal from './create-agent-modal';
8
+ import GraphAvatar from './graph-avatar';
9
+
10
+ import styles from './index.less';
11
+
12
+ const { Title, Text, Paragraph } = Typography;
13
+ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
14
+ loading: boolean;
15
+ onOk: (name: string, templateId: string) => void;
16
+ showModal?(): void;
17
+ }
18
+
19
+ const AgentTemplateModal = ({ visible, hideModal, loading, onOk }: IProps) => {
20
+ const { t } = useTranslate('common');
21
+ const { data: list } = useFetchFlowTemplates();
22
+ const { selectedId, handleItemClick } = useSelectItem('');
23
+ const [checkedId, setCheckedId] = useState<string>('');
24
+
25
+ const {
26
+ visible: creatingVisible,
27
+ hideModal: hideCreatingModal,
28
+ showModal: showCreatingModal,
29
+ } = useSetModalState();
30
+
31
+ const handleOk = useCallback(
32
+ async (name: string) => {
33
+ return onOk(name, checkedId);
34
+ },
35
+ [onOk, checkedId],
36
+ );
37
+
38
+ const onShowCreatingModal = useCallback(
39
+ (id: string) => () => {
40
+ showCreatingModal();
41
+ setCheckedId(id);
42
+ },
43
+ [showCreatingModal],
44
+ );
45
+
46
+ return (
47
+ <Modal
48
+ title={t('createGraph', { keyPrefix: 'flow' })}
49
+ open={visible}
50
+ width={'100vw'}
51
+ onCancel={hideModal}
52
+ okButtonProps={{ loading }}
53
+ confirmLoading={loading}
54
+ className={styles.agentTemplateModal}
55
+ wrapClassName={styles.agentTemplateModalWrapper}
56
+ footer={null}
57
+ >
58
+ <section className={styles.createModalContent}>
59
+ <Title level={5}>
60
+ {t('createFromTemplates', { keyPrefix: 'flow' })}
61
+ </Title>
62
+ <List
63
+ grid={{ gutter: 16, column: 4 }}
64
+ dataSource={list}
65
+ renderItem={(x) => (
66
+ <List.Item>
67
+ <Card
68
+ key={x.id}
69
+ onMouseEnter={handleItemClick(x.id)}
70
+ onMouseLeave={handleItemClick('')}
71
+ className={styles.flowTemplateCard}
72
+ >
73
+ <Flex gap={'middle'} align="center">
74
+ <GraphAvatar avatar={x.avatar}></GraphAvatar>
75
+ <b className={styles.agentTitleWrapper}>
76
+ <Text
77
+ style={{ width: '96%' }}
78
+ ellipsis={{ tooltip: x.title }}
79
+ >
80
+ {x.title}
81
+ </Text>
82
+ </b>
83
+ </Flex>
84
+ <div className={styles.agentDescription}>
85
+ <Paragraph ellipsis={{ tooltip: x.description, rows: 5 }}>
86
+ {x.description}
87
+ </Paragraph>
88
+ </div>
89
+ {selectedId === x.id && (
90
+ <Button
91
+ type={'primary'}
92
+ block
93
+ onClick={onShowCreatingModal(x.id)}
94
+ className={styles.useButton}
95
+ >
96
+ {t('useTemplate', { keyPrefix: 'flow' })}
97
+ </Button>
98
+ )}
99
+ </Card>
100
+ </List.Item>
101
+ )}
102
+ />
103
+ </section>
104
+ {creatingVisible && (
105
+ <CreateAgentModal
106
+ loading={loading}
107
+ visible={creatingVisible}
108
+ hideModal={hideCreatingModal}
109
+ onOk={handleOk}
110
+ ></CreateAgentModal>
111
+ )}
112
+ </Modal>
113
+ );
114
+ };
115
+
116
+ export default AgentTemplateModal;
web/src/pages/flow/list/{create-flow-modal.tsx → create-agent-modal.tsx} RENAMED
@@ -1,32 +1,16 @@
1
  import { IModalManagerChildrenProps } from '@/components/modal-manager';
2
  import { useTranslate } from '@/hooks/common-hooks';
3
- import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
4
- import { useSelectItem } from '@/hooks/logic-hooks';
5
- import { Card, Flex, Form, Input, Modal, Space, Typography } from 'antd';
6
- import classNames from 'classnames';
7
- import { useEffect } from 'react';
8
- import GraphAvatar from './graph-avatar';
9
- import styles from './index.less';
10
 
11
- const { Title } = Typography;
12
  interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
13
  loading: boolean;
14
- initialName: string;
15
- onOk: (name: string, templateId: string) => void;
16
  showModal?(): void;
17
  }
18
 
19
- const CreateFlowModal = ({
20
- visible,
21
- hideModal,
22
- loading,
23
- initialName,
24
- onOk,
25
- }: IProps) => {
26
  const [form] = Form.useForm();
27
  const { t } = useTranslate('common');
28
- const { data: list } = useFetchFlowTemplates();
29
- const { selectedId, handleItemClick } = useSelectItem(list?.at(0)?.id);
30
 
31
  type FieldType = {
32
  name?: string;
@@ -35,21 +19,14 @@ const CreateFlowModal = ({
35
  const handleOk = async () => {
36
  const ret = await form.validateFields();
37
 
38
- return onOk(ret.name, selectedId);
39
  };
40
 
41
- useEffect(() => {
42
- if (visible) {
43
- form.setFieldValue('name', initialName);
44
- }
45
- }, [initialName, form, visible]);
46
-
47
  return (
48
  <Modal
49
  title={t('createGraph', { keyPrefix: 'flow' })}
50
  open={visible}
51
  onOk={handleOk}
52
- width={600}
53
  onCancel={hideModal}
54
  okButtonProps={{ loading }}
55
  confirmLoading={loading}
@@ -58,38 +35,20 @@ const CreateFlowModal = ({
58
  name="basic"
59
  labelCol={{ span: 4 }}
60
  wrapperCol={{ span: 20 }}
 
61
  autoComplete="off"
62
- layout={'vertical'}
63
  form={form}
64
  >
65
  <Form.Item<FieldType>
66
- label={<b>{t('name')}</b>}
67
  name="name"
68
  rules={[{ required: true, message: t('namePlaceholder') }]}
69
  >
70
  <Input />
71
  </Form.Item>
72
  </Form>
73
- <Title level={5}>{t('createFromTemplates', { keyPrefix: 'flow' })}</Title>
74
- <Flex vertical gap={16} className={styles.templatesBox}>
75
- {list?.map((x) => (
76
- <Card
77
- key={x.id}
78
- className={classNames(styles.flowTemplateCard, {
79
- [styles.selectedFlowTemplateCard]: selectedId === x.id,
80
- })}
81
- onClick={handleItemClick(x.id)}
82
- >
83
- <Space size={'middle'}>
84
- <GraphAvatar avatar={x.avatar}></GraphAvatar>
85
- <b>{x.title}</b>
86
- </Space>
87
- <p>{x.description}</p>
88
- </Card>
89
- ))}
90
- </Flex>
91
  </Modal>
92
  );
93
  };
94
 
95
- export default CreateFlowModal;
 
1
  import { IModalManagerChildrenProps } from '@/components/modal-manager';
2
  import { useTranslate } from '@/hooks/common-hooks';
3
+ import { Form, Input, Modal } from 'antd';
 
 
 
 
 
 
4
 
 
5
  interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
6
  loading: boolean;
7
+ onOk: (name: string) => void;
 
8
  showModal?(): void;
9
  }
10
 
11
+ const CreateAgentModal = ({ visible, hideModal, loading, onOk }: IProps) => {
 
 
 
 
 
 
12
  const [form] = Form.useForm();
13
  const { t } = useTranslate('common');
 
 
14
 
15
  type FieldType = {
16
  name?: string;
 
19
  const handleOk = async () => {
20
  const ret = await form.validateFields();
21
 
22
+ return onOk(ret.name);
23
  };
24
 
 
 
 
 
 
 
25
  return (
26
  <Modal
27
  title={t('createGraph', { keyPrefix: 'flow' })}
28
  open={visible}
29
  onOk={handleOk}
 
30
  onCancel={hideModal}
31
  okButtonProps={{ loading }}
32
  confirmLoading={loading}
 
35
  name="basic"
36
  labelCol={{ span: 4 }}
37
  wrapperCol={{ span: 20 }}
38
+ style={{ maxWidth: 600 }}
39
  autoComplete="off"
 
40
  form={form}
41
  >
42
  <Form.Item<FieldType>
43
+ label={t('name')}
44
  name="name"
45
  rules={[{ required: true, message: t('namePlaceholder') }]}
46
  >
47
  <Input />
48
  </Form.Item>
49
  </Form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  </Modal>
51
  );
52
  };
53
 
54
+ export default CreateAgentModal;
web/src/pages/flow/list/index.less CHANGED
@@ -47,15 +47,53 @@
47
  }
48
  }
49
 
50
- .flowTemplateCard {
51
- cursor: pointer;
 
52
  }
53
 
54
- .selectedFlowTemplateCard {
55
- background-color: @selectedBackgroundColor;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
- .templatesBox {
59
- max-height: 70vh;
60
- overflow: auto;
61
  }
 
47
  }
48
  }
49
 
50
+ .templatesBox {
51
+ max-height: 70vh;
52
+ overflow: auto;
53
  }
54
 
55
+ .agentTemplateModal {
56
+ top: 0;
57
+ margin: 0;
58
+ width: 100%;
59
+ max-width: 100%;
60
+ height: 100vh;
61
+ max-height: 100vh;
62
+ padding: 0;
63
+
64
+ :global(.ant-modal-content) {
65
+ // width: 100vw;
66
+ height: 100%;
67
+ border-radius: 0;
68
+ }
69
+ .agentDescription {
70
+ padding-top: 18px;
71
+ height: 110px;
72
+ }
73
+ .createModalContent {
74
+ height: 90vh;
75
+ }
76
+ .agentTitleWrapper {
77
+ width: 80%;
78
+ }
79
+ .flowTemplateCard {
80
+ position: relative;
81
+ cursor: pointer;
82
+ }
83
+
84
+ .selectedFlowTemplateCard {
85
+ background-color: @selectedBackgroundColor;
86
+ }
87
+ .useButton {
88
+ position: absolute;
89
+ width: 84%;
90
+ left: 0;
91
+ right: 0;
92
+ bottom: 10px;
93
+ margin: auto;
94
+ }
95
  }
96
 
97
+ .agentTemplateModalWrapper {
98
+ margin: 0;
 
99
  }
web/src/pages/flow/list/index.tsx CHANGED
@@ -1,6 +1,6 @@
1
  import { PlusOutlined } from '@ant-design/icons';
2
  import { Button, Empty, Flex, Spin } from 'antd';
3
- import CreateFlowModal from './create-flow-modal';
4
  import FlowCard from './flow-card';
5
  import { useFetchDataOnMount, useSaveFlow } from './hooks';
6
 
@@ -42,13 +42,12 @@ const FlowList = () => {
42
  </Flex>
43
  </Spin>
44
  {flowSettingVisible && (
45
- <CreateFlowModal
46
  visible={flowSettingVisible}
47
  onOk={onFlowOk}
48
  loading={flowSettingLoading}
49
  hideModal={hideFlowSettingModal}
50
- initialName=""
51
- ></CreateFlowModal>
52
  )}
53
  </Flex>
54
  );
 
1
  import { PlusOutlined } from '@ant-design/icons';
2
  import { Button, Empty, Flex, Spin } from 'antd';
3
+ import AgentTemplateModal from './agent-template-modal';
4
  import FlowCard from './flow-card';
5
  import { useFetchDataOnMount, useSaveFlow } from './hooks';
6
 
 
42
  </Flex>
43
  </Spin>
44
  {flowSettingVisible && (
45
+ <AgentTemplateModal
46
  visible={flowSettingVisible}
47
  onOk={onFlowOk}
48
  loading={flowSettingLoading}
49
  hideModal={hideFlowSettingModal}
50
+ ></AgentTemplateModal>
 
51
  )}
52
  </Flex>
53
  );