### 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):tags/v0.12.0
| import { ISystemStatus, IUserInfo } from '@/interfaces/database/user-setting'; | import { ISystemStatus, IUserInfo } from '@/interfaces/database/user-setting'; | ||||
| import userService from '@/services/user-service'; | import userService from '@/services/user-service'; | ||||
| import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | 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 { useCallback, useMemo, useState } from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||
| }; | }; | ||||
| export const useFetchTenantInfo = (): ResponseGetType<ITenantInfo> => { | export const useFetchTenantInfo = (): ResponseGetType<ITenantInfo> => { | ||||
| const { t } = useTranslation(); | |||||
| const { data, isFetching: loading } = useQuery({ | const { data, isFetching: loading } = useQuery({ | ||||
| queryKey: ['tenantInfo'], | queryKey: ['tenantInfo'], | ||||
| initialData: {}, | initialData: {}, | ||||
| // llm_id is chat_id | // llm_id is chat_id | ||||
| // asr_id is speech2txt | // asr_id is speech2txt | ||||
| const { data } = res; | const { data } = res; | ||||
| if (isEmpty(data.embd_id) || isEmpty(data.llm_id)) { | |||||
| Modal.warning({ | |||||
| title: t('common.warn'), | |||||
| content: ( | |||||
| <div | |||||
| dangerouslySetInnerHTML={{ | |||||
| __html: DOMPurify.sanitize(t('setting.modelProvidersWarn')), | |||||
| }} | |||||
| ></div> | |||||
| ), | |||||
| }); | |||||
| } | |||||
| data.chat_id = data.llm_id; | data.chat_id = data.llm_id; | ||||
| data.speech2text_id = data.asr_id; | data.speech2text_id = data.asr_id; | ||||
| close: 'Close', | close: 'Close', | ||||
| preview: 'Preview', | preview: 'Preview', | ||||
| move: 'Move', | move: 'Move', | ||||
| warn: '提醒', | |||||
| }, | }, | ||||
| login: { | login: { | ||||
| login: 'Sign in', | login: 'Sign in', | ||||
| 'Please input Google Cloud Service Account Key in base64 format', | 'Please input Google Cloud Service Account Key in base64 format', | ||||
| addGoogleRegion: 'Google Cloud Region', | addGoogleRegion: 'Google Cloud Region', | ||||
| GoogleRegionMessage: 'Please input Google Cloud Region', | GoogleRegionMessage: 'Please input Google Cloud Region', | ||||
| modelProvidersWarn: | |||||
| 'Please add both embedding model and LLM in <b>Settings > Model</b> providers firstly.', | |||||
| }, | }, | ||||
| message: { | message: { | ||||
| registered: 'Registered!', | registered: 'Registered!', |
| close: '關閉', | close: '關閉', | ||||
| preview: '預覽', | preview: '預覽', | ||||
| move: '移動', | move: '移動', | ||||
| warn: '提醒', | |||||
| }, | }, | ||||
| login: { | login: { | ||||
| login: '登入', | login: '登入', | ||||
| '請輸入 Google Cloud Service Account Key in base64 format', | '請輸入 Google Cloud Service Account Key in base64 format', | ||||
| addGoogleRegion: 'Google Cloud 區域', | addGoogleRegion: 'Google Cloud 區域', | ||||
| GoogleRegionMessage: '請輸入 Google Cloud 區域', | GoogleRegionMessage: '請輸入 Google Cloud 區域', | ||||
| modelProvidersWarn: | |||||
| '請先在 <b>「設定」>「模型提供者」</b> 中新增嵌入模型和LLM。', | |||||
| }, | }, | ||||
| message: { | message: { | ||||
| registered: '註冊成功', | registered: '註冊成功', | ||||
| insurance: '保險', | insurance: '保險', | ||||
| futures: '期貨', | futures: '期貨', | ||||
| lccp: '理財', | lccp: '理財', | ||||
| foreign_exchange: '股票', | |||||
| foreign_exchange: '外匯', | |||||
| }, | }, | ||||
| akShare: 'AkShare', | akShare: 'AkShare', | ||||
| akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。', | akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。', |
| close: '关闭', | close: '关闭', | ||||
| preview: '预览', | preview: '预览', | ||||
| move: '移动', | move: '移动', | ||||
| warn: '提醒', | |||||
| }, | }, | ||||
| login: { | login: { | ||||
| login: '登录', | login: '登录', | ||||
| '请输入 Google Cloud Service Account Key in base64 format', | '请输入 Google Cloud Service Account Key in base64 format', | ||||
| addGoogleRegion: 'Google Cloud 区域', | addGoogleRegion: 'Google Cloud 区域', | ||||
| GoogleRegionMessage: '请输入 Google Cloud 区域', | GoogleRegionMessage: '请输入 Google Cloud 区域', | ||||
| modelProvidersWarn: | |||||
| '请首先在 <b>设置 > 模型提供商</b> 中添加嵌入模型和 LLM。', | |||||
| }, | }, | ||||
| message: { | message: { | ||||
| registered: '注册成功', | registered: '注册成功', | ||||
| insurance: '保险', | insurance: '保险', | ||||
| futures: '期货', | futures: '期货', | ||||
| lccp: '理财', | lccp: '理财', | ||||
| foreign_exchange: '股票', | |||||
| foreign_exchange: '外汇', | |||||
| }, | }, | ||||
| akShare: 'AkShare', | akShare: 'AkShare', | ||||
| akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。', | akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。', |