Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

assistant-setting.tsx 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { PlusOutlined } from '@ant-design/icons';
  2. import { Form, Input, message, Select, Switch, Upload } from 'antd';
  3. import classNames from 'classnames';
  4. import { ISegmentedContentProps } from '../interface';
  5. import KnowledgeBaseItem from '@/components/knowledge-base-item';
  6. import { useTranslate } from '@/hooks/common-hooks';
  7. import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
  8. import { useCallback } from 'react';
  9. import styles from './index.less';
  10. const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
  11. const { t } = useTranslate('chat');
  12. const { data } = useFetchTenantInfo();
  13. const normFile = (e: any) => {
  14. if (Array.isArray(e)) {
  15. return e;
  16. }
  17. return e?.fileList;
  18. };
  19. const handleTtsChange = useCallback(
  20. (checked: boolean) => {
  21. if (checked && !data.tts_id) {
  22. message.error(`Please set TTS model firstly.
  23. Setting >> Model providers >> System model settings`);
  24. form.setFieldValue(['prompt_config', 'tts'], false);
  25. }
  26. },
  27. [data, form],
  28. );
  29. const uploadButtion = (
  30. <button style={{ border: 0, background: 'none' }} type="button">
  31. <PlusOutlined />
  32. <div style={{ marginTop: 8 }}>{t('upload', { keyPrefix: 'common' })}</div>
  33. </button>
  34. );
  35. return (
  36. <section
  37. className={classNames({
  38. [styles.segmentedHidden]: !show,
  39. })}
  40. >
  41. <Form.Item
  42. name={'name'}
  43. label={t('assistantName')}
  44. rules={[{ required: true, message: t('assistantNameMessage') }]}
  45. >
  46. <Input placeholder={t('namePlaceholder')} />
  47. </Form.Item>
  48. <Form.Item name={'description'} label={t('description')}>
  49. <Input placeholder={t('descriptionPlaceholder')} />
  50. </Form.Item>
  51. <Form.Item
  52. name="icon"
  53. label={t('assistantAvatar')}
  54. valuePropName="fileList"
  55. getValueFromEvent={normFile}
  56. >
  57. <Upload
  58. listType="picture-card"
  59. maxCount={1}
  60. beforeUpload={() => false}
  61. showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
  62. >
  63. {show ? uploadButtion : null}
  64. </Upload>
  65. </Form.Item>
  66. <Form.Item
  67. name={'language'}
  68. label={t('language')}
  69. initialValue={'English'}
  70. tooltip="coming soon"
  71. style={{ display: 'none' }}
  72. >
  73. <Select
  74. options={[
  75. { value: 'Chinese', label: t('chinese', { keyPrefix: 'common' }) },
  76. { value: 'English', label: t('english', { keyPrefix: 'common' }) },
  77. ]}
  78. />
  79. </Form.Item>
  80. <Form.Item
  81. name={['prompt_config', 'empty_response']}
  82. label={t('emptyResponse')}
  83. tooltip={t('emptyResponseTip')}
  84. >
  85. <Input placeholder="" />
  86. </Form.Item>
  87. <Form.Item
  88. name={['prompt_config', 'prologue']}
  89. label={t('setAnOpener')}
  90. tooltip={t('setAnOpenerTip')}
  91. initialValue={t('setAnOpenerInitial')}
  92. >
  93. <Input.TextArea autoSize={{ minRows: 5 }} />
  94. </Form.Item>
  95. <Form.Item
  96. label={t('quote')}
  97. valuePropName="checked"
  98. name={['prompt_config', 'quote']}
  99. tooltip={t('quoteTip')}
  100. initialValue={true}
  101. >
  102. <Switch />
  103. </Form.Item>
  104. <Form.Item
  105. label={t('keyword')}
  106. valuePropName="checked"
  107. name={['prompt_config', 'keyword']}
  108. tooltip={t('keywordTip')}
  109. initialValue={false}
  110. >
  111. <Switch />
  112. </Form.Item>
  113. {/* <Form.Item
  114. label={t('selfRag')}
  115. valuePropName="checked"
  116. name={['prompt_config', 'self_rag']}
  117. tooltip={t('selfRagTip')}
  118. initialValue={false}
  119. >
  120. <Switch />
  121. </Form.Item> */}
  122. <Form.Item
  123. label={t('tts')}
  124. valuePropName="checked"
  125. name={['prompt_config', 'tts']}
  126. tooltip={t('ttsTip')}
  127. initialValue={false}
  128. >
  129. <Switch onChange={handleTtsChange} />
  130. </Form.Item>
  131. <KnowledgeBaseItem></KnowledgeBaseItem>
  132. </section>
  133. );
  134. };
  135. export default AssistantSetting;