balibabu
commited on
Commit
·
613b83b
1
Parent(s):
8ee1238
feat: If the model is not set, a pop-up window will remind the user #2295 (#2574)
Browse files### What problem does this PR solve?
feat: If the model is not set, a pop-up window will remind the user
#2295
### Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
web/src/hooks/{user-setting-hooks.ts → user-setting-hooks.tsx}
RENAMED
|
@@ -4,7 +4,9 @@ import { ITenantInfo } from '@/interfaces/database/knowledge';
|
|
| 4 |
import { ISystemStatus, IUserInfo } from '@/interfaces/database/user-setting';
|
| 5 |
import userService from '@/services/user-service';
|
| 6 |
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
| 7 |
-
import { message } from 'antd';
|
|
|
|
|
|
|
| 8 |
import { useCallback, useMemo, useState } from 'react';
|
| 9 |
import { useTranslation } from 'react-i18next';
|
| 10 |
|
|
@@ -32,6 +34,7 @@ export const useFetchUserInfo = (): ResponseGetType<IUserInfo> => {
|
|
| 32 |
};
|
| 33 |
|
| 34 |
export const useFetchTenantInfo = (): ResponseGetType<ITenantInfo> => {
|
|
|
|
| 35 |
const { data, isFetching: loading } = useQuery({
|
| 36 |
queryKey: ['tenantInfo'],
|
| 37 |
initialData: {},
|
|
@@ -42,6 +45,18 @@ export const useFetchTenantInfo = (): ResponseGetType<ITenantInfo> => {
|
|
| 42 |
// llm_id is chat_id
|
| 43 |
// asr_id is speech2txt
|
| 44 |
const { data } = res;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
data.chat_id = data.llm_id;
|
| 46 |
data.speech2text_id = data.asr_id;
|
| 47 |
|
|
|
|
| 4 |
import { ISystemStatus, IUserInfo } from '@/interfaces/database/user-setting';
|
| 5 |
import userService from '@/services/user-service';
|
| 6 |
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
| 7 |
+
import { Modal, message } from 'antd';
|
| 8 |
+
import DOMPurify from 'dompurify';
|
| 9 |
+
import { isEmpty } from 'lodash';
|
| 10 |
import { useCallback, useMemo, useState } from 'react';
|
| 11 |
import { useTranslation } from 'react-i18next';
|
| 12 |
|
|
|
|
| 34 |
};
|
| 35 |
|
| 36 |
export const useFetchTenantInfo = (): ResponseGetType<ITenantInfo> => {
|
| 37 |
+
const { t } = useTranslation();
|
| 38 |
const { data, isFetching: loading } = useQuery({
|
| 39 |
queryKey: ['tenantInfo'],
|
| 40 |
initialData: {},
|
|
|
|
| 45 |
// llm_id is chat_id
|
| 46 |
// asr_id is speech2txt
|
| 47 |
const { data } = res;
|
| 48 |
+
if (isEmpty(data.embd_id) || isEmpty(data.llm_id)) {
|
| 49 |
+
Modal.warning({
|
| 50 |
+
title: t('common.warn'),
|
| 51 |
+
content: (
|
| 52 |
+
<div
|
| 53 |
+
dangerouslySetInnerHTML={{
|
| 54 |
+
__html: DOMPurify.sanitize(t('setting.modelProvidersWarn')),
|
| 55 |
+
}}
|
| 56 |
+
></div>
|
| 57 |
+
),
|
| 58 |
+
});
|
| 59 |
+
}
|
| 60 |
data.chat_id = data.llm_id;
|
| 61 |
data.speech2text_id = data.asr_id;
|
| 62 |
|
web/src/locales/en.ts
CHANGED
|
@@ -27,6 +27,7 @@ export default {
|
|
| 27 |
close: 'Close',
|
| 28 |
preview: 'Preview',
|
| 29 |
move: 'Move',
|
|
|
|
| 30 |
},
|
| 31 |
login: {
|
| 32 |
login: 'Sign in',
|
|
@@ -578,6 +579,8 @@ The above is the content you need to summarize.`,
|
|
| 578 |
'Please input Google Cloud Service Account Key in base64 format',
|
| 579 |
addGoogleRegion: 'Google Cloud Region',
|
| 580 |
GoogleRegionMessage: 'Please input Google Cloud Region',
|
|
|
|
|
|
|
| 581 |
},
|
| 582 |
message: {
|
| 583 |
registered: 'Registered!',
|
|
|
|
| 27 |
close: 'Close',
|
| 28 |
preview: 'Preview',
|
| 29 |
move: 'Move',
|
| 30 |
+
warn: '提醒',
|
| 31 |
},
|
| 32 |
login: {
|
| 33 |
login: 'Sign in',
|
|
|
|
| 579 |
'Please input Google Cloud Service Account Key in base64 format',
|
| 580 |
addGoogleRegion: 'Google Cloud Region',
|
| 581 |
GoogleRegionMessage: 'Please input Google Cloud Region',
|
| 582 |
+
modelProvidersWarn:
|
| 583 |
+
'Please add both embedding model and LLM in <b>Settings > Model</b> providers firstly.',
|
| 584 |
},
|
| 585 |
message: {
|
| 586 |
registered: 'Registered!',
|
web/src/locales/zh-traditional.ts
CHANGED
|
@@ -27,6 +27,7 @@ export default {
|
|
| 27 |
close: '關閉',
|
| 28 |
preview: '預覽',
|
| 29 |
move: '移動',
|
|
|
|
| 30 |
},
|
| 31 |
login: {
|
| 32 |
login: '登入',
|
|
@@ -537,6 +538,8 @@ export default {
|
|
| 537 |
'請輸入 Google Cloud Service Account Key in base64 format',
|
| 538 |
addGoogleRegion: 'Google Cloud 區域',
|
| 539 |
GoogleRegionMessage: '請輸入 Google Cloud 區域',
|
|
|
|
|
|
|
| 540 |
},
|
| 541 |
message: {
|
| 542 |
registered: '註冊成功',
|
|
@@ -858,7 +861,7 @@ export default {
|
|
| 858 |
insurance: '保險',
|
| 859 |
futures: '期貨',
|
| 860 |
lccp: '理財',
|
| 861 |
-
foreign_exchange: '
|
| 862 |
},
|
| 863 |
akShare: 'AkShare',
|
| 864 |
akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。',
|
|
|
|
| 27 |
close: '關閉',
|
| 28 |
preview: '預覽',
|
| 29 |
move: '移動',
|
| 30 |
+
warn: '提醒',
|
| 31 |
},
|
| 32 |
login: {
|
| 33 |
login: '登入',
|
|
|
|
| 538 |
'請輸入 Google Cloud Service Account Key in base64 format',
|
| 539 |
addGoogleRegion: 'Google Cloud 區域',
|
| 540 |
GoogleRegionMessage: '請輸入 Google Cloud 區域',
|
| 541 |
+
modelProvidersWarn:
|
| 542 |
+
'請先在 <b>「設定」>「模型提供者」</b> 中新增嵌入模型和LLM。',
|
| 543 |
},
|
| 544 |
message: {
|
| 545 |
registered: '註冊成功',
|
|
|
|
| 861 |
insurance: '保險',
|
| 862 |
futures: '期貨',
|
| 863 |
lccp: '理財',
|
| 864 |
+
foreign_exchange: '外匯',
|
| 865 |
},
|
| 866 |
akShare: 'AkShare',
|
| 867 |
akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。',
|
web/src/locales/zh.ts
CHANGED
|
@@ -27,6 +27,7 @@ export default {
|
|
| 27 |
close: '关闭',
|
| 28 |
preview: '预览',
|
| 29 |
move: '移动',
|
|
|
|
| 30 |
},
|
| 31 |
login: {
|
| 32 |
login: '登录',
|
|
@@ -554,6 +555,8 @@ export default {
|
|
| 554 |
'请输入 Google Cloud Service Account Key in base64 format',
|
| 555 |
addGoogleRegion: 'Google Cloud 区域',
|
| 556 |
GoogleRegionMessage: '请输入 Google Cloud 区域',
|
|
|
|
|
|
|
| 557 |
},
|
| 558 |
message: {
|
| 559 |
registered: '注册成功',
|
|
@@ -876,7 +879,7 @@ export default {
|
|
| 876 |
insurance: '保险',
|
| 877 |
futures: '期货',
|
| 878 |
lccp: '理财',
|
| 879 |
-
foreign_exchange: '
|
| 880 |
},
|
| 881 |
akShare: 'AkShare',
|
| 882 |
akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。',
|
|
|
|
| 27 |
close: '关闭',
|
| 28 |
preview: '预览',
|
| 29 |
move: '移动',
|
| 30 |
+
warn: '提醒',
|
| 31 |
},
|
| 32 |
login: {
|
| 33 |
login: '登录',
|
|
|
|
| 555 |
'请输入 Google Cloud Service Account Key in base64 format',
|
| 556 |
addGoogleRegion: 'Google Cloud 区域',
|
| 557 |
GoogleRegionMessage: '请输入 Google Cloud 区域',
|
| 558 |
+
modelProvidersWarn:
|
| 559 |
+
'请首先在 <b>设置 > 模型提供商</b> 中添加嵌入模型和 LLM。',
|
| 560 |
},
|
| 561 |
message: {
|
| 562 |
registered: '注册成功',
|
|
|
|
| 879 |
insurance: '保险',
|
| 880 |
futures: '期货',
|
| 881 |
lccp: '理财',
|
| 882 |
+
foreign_exchange: '外汇',
|
| 883 |
},
|
| 884 |
akShare: 'AkShare',
|
| 885 |
akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。',
|