From e4c9cf2264e38c156953fa4f44c85275c119d032 Mon Sep 17 00:00:00 2001 From: balibabu Date: Wed, 25 Sep 2024 11:16:00 +0800 Subject: [PATCH] feat: If the model is not set, a pop-up window will remind the user #2295 (#2574) ### 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): --- ...-setting-hooks.ts => user-setting-hooks.tsx} | 17 ++++++++++++++++- web/src/locales/en.ts | 3 +++ web/src/locales/zh-traditional.ts | 5 ++++- web/src/locales/zh.ts | 5 ++++- 4 files changed, 27 insertions(+), 3 deletions(-) rename web/src/hooks/{user-setting-hooks.ts => user-setting-hooks.tsx} (87%) diff --git a/web/src/hooks/user-setting-hooks.ts b/web/src/hooks/user-setting-hooks.tsx similarity index 87% rename from web/src/hooks/user-setting-hooks.ts rename to web/src/hooks/user-setting-hooks.tsx index b4c233db5..688da7172 100644 --- a/web/src/hooks/user-setting-hooks.ts +++ b/web/src/hooks/user-setting-hooks.tsx @@ -4,7 +4,9 @@ import { ITenantInfo } from '@/interfaces/database/knowledge'; import { ISystemStatus, IUserInfo } from '@/interfaces/database/user-setting'; import userService from '@/services/user-service'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { message } from 'antd'; +import { Modal, message } from 'antd'; +import DOMPurify from 'dompurify'; +import { isEmpty } from 'lodash'; import { useCallback, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -32,6 +34,7 @@ export const useFetchUserInfo = (): ResponseGetType => { }; export const useFetchTenantInfo = (): ResponseGetType => { + const { t } = useTranslation(); const { data, isFetching: loading } = useQuery({ queryKey: ['tenantInfo'], initialData: {}, @@ -42,6 +45,18 @@ export const useFetchTenantInfo = (): ResponseGetType => { // llm_id is chat_id // asr_id is speech2txt const { data } = res; + if (isEmpty(data.embd_id) || isEmpty(data.llm_id)) { + Modal.warning({ + title: t('common.warn'), + content: ( +
+ ), + }); + } data.chat_id = data.llm_id; data.speech2text_id = data.asr_id; diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 5e97c2bd4..103c5cec6 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -27,6 +27,7 @@ export default { close: 'Close', preview: 'Preview', move: 'Move', + warn: '提醒', }, login: { login: 'Sign in', @@ -578,6 +579,8 @@ The above is the content you need to summarize.`, 'Please input Google Cloud Service Account Key in base64 format', addGoogleRegion: 'Google Cloud Region', GoogleRegionMessage: 'Please input Google Cloud Region', + modelProvidersWarn: + 'Please add both embedding model and LLM in Settings > Model providers firstly.', }, message: { registered: 'Registered!', diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index 8ef4c1b5e..61dceaff4 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -27,6 +27,7 @@ export default { close: '關閉', preview: '預覽', move: '移動', + warn: '提醒', }, login: { login: '登入', @@ -537,6 +538,8 @@ export default { '請輸入 Google Cloud Service Account Key in base64 format', addGoogleRegion: 'Google Cloud 區域', GoogleRegionMessage: '請輸入 Google Cloud 區域', + modelProvidersWarn: + '請先在 「設定」>「模型提供者」 中新增嵌入模型和LLM。', }, message: { registered: '註冊成功', @@ -858,7 +861,7 @@ export default { insurance: '保險', futures: '期貨', lccp: '理財', - foreign_exchange: '股票', + foreign_exchange: '外匯', }, akShare: 'AkShare', akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 0b922c65a..3771c057b 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -27,6 +27,7 @@ export default { close: '关闭', preview: '预览', move: '移动', + warn: '提醒', }, login: { login: '登录', @@ -554,6 +555,8 @@ export default { '请输入 Google Cloud Service Account Key in base64 format', addGoogleRegion: 'Google Cloud 区域', GoogleRegionMessage: '请输入 Google Cloud 区域', + modelProvidersWarn: + '请首先在 设置 > 模型提供商 中添加嵌入模型和 LLM。', }, message: { registered: '注册成功', @@ -876,7 +879,7 @@ export default { insurance: '保险', futures: '期货', lccp: '理财', - foreign_exchange: '股票', + foreign_exchange: '外汇', }, akShare: 'AkShare', akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。',