diff --git a/client/public/locales/en/common.json b/client/public/locales/en/common.json index 2d71149ec..804b25c5b 100644 --- a/client/public/locales/en/common.json +++ b/client/public/locales/en/common.json @@ -2,12 +2,13 @@ "App": "App", "Cancel": "No", "Confirm": "Yes", - "Warning": "Warning", "Running": "Running", + "Warning": "Warning", "app": { + "Advance App TestTip": "The current application is advanced editing mode \n. If you need to switch to [simple mode], please click the save button on the left", "App Detail": "App Detail", "Confirm Del App Tip": "Confirm to delete the app and all its chats", - "Confirm Save App Tip": "After saving, the advanced orchestration configuration will be overwritten. Make sure that the application does not use advanced orchestration.", + "Confirm Save App Tip": "The application may be in advanced orchestration mode, and the advanced orchestration configuration will be overwritten after saving, please confirm!", "Connection is invalid": "Connecting is invalid", "Connection type is different": "Connection type is different", "Input Field Settings": "Input Field Settings", @@ -31,11 +32,11 @@ "file": { "Click to download CSV template": "Click to download CSV template", "Drag and drop": "Drag and drop files here, or click", + "If the imported file is garbled, please convert CSV to UTF-8 encoding format": "If the imported file is garbled, please convert CSV to UTF-8 encoding format", "Release the mouse to upload the file": "Release the mouse to upload the file", "select a document": "select a document", "support": "support {{fileExtension}} file", - "upload error description": "Only upload multiple files or one folder at a time", - "If the imported file is garbled, please convert CSV to UTF-8 encoding format": "If the imported file is garbled, please convert CSV to UTF-8 encoding format" + "upload error description": "Only upload multiple files or one folder at a time" }, "home": { "Quickly build AI question and answer library": "Quickly build AI question and answer library", diff --git a/client/public/locales/zh/common.json b/client/public/locales/zh/common.json index b7135f264..12d4551f5 100644 --- a/client/public/locales/zh/common.json +++ b/client/public/locales/zh/common.json @@ -2,12 +2,13 @@ "App": "应用", "Cancel": "取消", "Confirm": "确认", - "Warning": "提示", "Running": "运行中", + "Warning": "提示", "app": { + "Advance App TestTip": "当前应用为高级编排模式\n如需切换为【简易模式】请点击左侧保存按键", "App Detail": "应用详情", "Confirm Del App Tip": "确认删除该应用及其所有聊天记录?", - "Confirm Save App Tip": "保存后将会覆盖高级编排配置,请确保该应用未使用高级编排功能。", + "Confirm Save App Tip": "该应用可能为高级编排模式,保存后将会覆盖高级编排配置,请确认!", "Connection is invalid": "连接无效", "Connection type is different": "连接的类型不一致", "Input Field Settings": "输入字段编辑", @@ -31,11 +32,11 @@ "file": { "Click to download CSV template": "点击下载 CSV 模板", "Drag and drop": "拖拽文件至此,或点击", + "If the imported file is garbled, please convert CSV to UTF-8 encoding format": "如果导入文件乱码,请将 CSV 转成 UTF-8 编码格式", "Release the mouse to upload the file": "松开鼠标上传文件", "select a document": "选择文件", "support": "支持 {{fileExtension}} 文件", - "upload error description": "单次只支持上传多个文件或者一个文件夹", - "If the imported file is garbled, please convert CSV to UTF-8 encoding format": "如果导入文件乱码,请将 CSV 转成 UTF-8 编码格式" + "upload error description": "单次只支持上传多个文件或者一个文件夹" }, "home": { "Quickly build AI question and answer library": "快速搭建 AI 问答系统", diff --git a/client/src/constants/app.ts b/client/src/constants/app.ts index e950479a6..a9b070690 100644 --- a/client/src/constants/app.ts +++ b/client/src/constants/app.ts @@ -11,3 +11,8 @@ export enum VariableInputEnum { input = 'input', select = 'select' } + +export enum AppTypeEnum { + basic = 'basic', + advanced = 'advanced' +} diff --git a/client/src/constants/model.ts b/client/src/constants/model.ts index caedc84f0..16dab683b 100644 --- a/client/src/constants/model.ts +++ b/client/src/constants/model.ts @@ -12,6 +12,7 @@ export const defaultApp: AppSchema = { _id: '', userId: 'userId', name: '模型加载中', + type: 'basic', avatar: '/icon/logo.png', intro: '', updateTime: Date.now(), diff --git a/client/src/pages/api/app/update.ts b/client/src/pages/api/app/update.ts index b70842a41..ed887ed12 100644 --- a/client/src/pages/api/app/update.ts +++ b/client/src/pages/api/app/update.ts @@ -9,7 +9,7 @@ import { authApp } from '@/service/utils/auth'; /* 获取我的模型 */ export default async function handler(req: NextApiRequest, res: NextApiResponse) { try { - const { name, avatar, chat, share, intro, modules } = req.body as AppUpdateParams; + const { name, avatar, type, chat, share, intro, modules } = req.body as AppUpdateParams; const { appId } = req.query as { appId: string }; if (!appId) { @@ -34,6 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< }, { name, + type, avatar, intro, chat, diff --git a/client/src/pages/app/detail/components/AdEdit/index.tsx b/client/src/pages/app/detail/components/AdEdit/index.tsx index 97bc6a9c9..ac60798f5 100644 --- a/client/src/pages/app/detail/components/AdEdit/index.tsx +++ b/client/src/pages/app/detail/components/AdEdit/index.tsx @@ -77,6 +77,7 @@ const NodeHttp = dynamic(() => import('./components/Nodes/NodeHttp'), { import 'reactflow/dist/style.css'; import styles from './index.module.scss'; +import { AppTypeEnum } from '@/constants/app'; const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6); @@ -347,7 +348,8 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => { const { mutate: onclickSave, isLoading } = useRequest({ mutationFn: () => { return updateAppDetail(app._id, { - modules: flow2AppModules() + modules: flow2AppModules(), + type: AppTypeEnum.advanced }); }, successToast: '保存配置成功', diff --git a/client/src/pages/app/detail/components/BasicEdit/index.tsx b/client/src/pages/app/detail/components/BasicEdit/index.tsx index 30f688b8f..12dd7e68a 100644 --- a/client/src/pages/app/detail/components/BasicEdit/index.tsx +++ b/client/src/pages/app/detail/components/BasicEdit/index.tsx @@ -44,6 +44,8 @@ import { useRouter } from 'next/router'; import { useToast } from '@/hooks/useToast'; import { AppSchema } from '@/types/mongoSchema'; import { delModelById } from '@/api/app'; +import { useTranslation } from 'react-i18next'; +import { getSpecialModule } from '@/components/ChatBox/utils'; import dynamic from 'next/dynamic'; import MySelect from '@/components/Select'; @@ -52,11 +54,10 @@ import MyTooltip from '@/components/MyTooltip'; import Avatar from '@/components/Avatar'; import MyIcon from '@/components/Icon'; import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox'; -import { useTranslation } from 'react-i18next'; -import { getSpecialModule } from '@/components/ChatBox/utils'; import { addVariable } from '../VariableEditModal'; import { KBSelectModal, KbParamsModal } from '../KBSelectModal'; +import { AppTypeEnum } from '@/constants/app'; const VariableEditModal = dynamic(() => import('../VariableEditModal')); const InfoModal = dynamic(() => import('../InfoModal')); @@ -154,7 +155,8 @@ const Settings = ({ appId }: { appId: string }) => { const modules = appForm2Modules(data); await updateAppDetail(appDetail._id, { - modules + modules, + type: AppTypeEnum.basic }); }, successToast: '保存成功', @@ -290,7 +292,13 @@ const Settings = ({ appId }: { appId: string }) => { isLoading={isSaving} fontSize={'sm'} size={['sm', 'md']} - onClick={openConfirmSave(handleSubmit((data) => onSubmitSave(data)))} + onClick={() => { + if (appDetail.type !== AppTypeEnum.basic) { + openConfirmSave(handleSubmit((data) => onSubmitSave(data)))(); + } else { + handleSubmit((data) => onSubmitSave(data))(); + } + }} > {isPc ? '保存并预览' : '保存'} @@ -558,6 +566,7 @@ const Settings = ({ appId }: { appId: string }) => { }; const ChatTest = ({ appId }: { appId: string }) => { + const { t } = useTranslation(); const { appDetail, userInfo } = useUserStore(); const ChatBoxRef = useRef(null); const [modules, setModules] = useState([]); @@ -602,7 +611,7 @@ const ChatTest = ({ appId }: { appId: string }) => { }, [appDetail, resetChatBox]); return ( - + 调试预览 @@ -632,6 +641,25 @@ const ChatTest = ({ appId }: { appId: string }) => { onDelMessage={() => {}} /> + {appDetail.type !== AppTypeEnum.basic && ( + + {t('app.Advance App TestTip')} + + )} ); }; diff --git a/client/src/pages/kb/detail/components/DataCard.tsx b/client/src/pages/kb/detail/components/DataCard.tsx index 7bc0e7278..171e82ac5 100644 --- a/client/src/pages/kb/detail/components/DataCard.tsx +++ b/client/src/pages/kb/detail/components/DataCard.tsx @@ -208,9 +208,7 @@ const DataCard = ({ kbId }: { kbId: string }) => { {item.q} - - {item.a} - + {item.a} diff --git a/client/src/service/models/app.ts b/client/src/service/models/app.ts index b32e352f3..b6554466c 100644 --- a/client/src/service/models/app.ts +++ b/client/src/service/models/app.ts @@ -11,6 +11,11 @@ const AppSchema = new Schema({ type: String, required: true }, + type: { + type: String, + default: 'advanced', + enum: ['basic', 'advanced'] + }, avatar: { type: String, default: '/icon/logo.png' @@ -51,6 +56,7 @@ const AppSchema = new Schema({ type: Array, default: [] }, + // 弃 chat: { relatedKbs: { type: [Schema.Types.ObjectId], diff --git a/client/src/store/shareChat.ts b/client/src/store/shareChat.ts index fa0414b16..27f1c5745 100644 --- a/client/src/store/shareChat.ts +++ b/client/src/store/shareChat.ts @@ -30,7 +30,7 @@ export const defaultHistory: ShareChatHistoryItemType = { const defaultShareChatData: ShareChatType = { userAvatar: HUMAN_ICON, app: { - name: 'AI', + name: '', avatar: '/icon/logo.png', intro: '' }, diff --git a/client/src/types/app.d.ts b/client/src/types/app.d.ts index 17be68bdb..74b4c8f43 100644 --- a/client/src/types/app.d.ts +++ b/client/src/types/app.d.ts @@ -2,6 +2,7 @@ import { FlowModuleTypeEnum } from '@/constants/flow'; import { XYPosition } from 'reactflow'; import { AppModuleItemTypeEnum, + AppTypeEnum, ModulesInputItemTypeEnum, VariableInputEnum } from '../constants/app'; @@ -19,6 +20,7 @@ export type AppListItemType = { export interface AppUpdateParams { name?: string; + type?: `${AppTypeEnum}`; avatar?: string; intro?: string; chat?: AppSchema['chat']; diff --git a/client/src/types/mongoSchema.d.ts b/client/src/types/mongoSchema.d.ts index 0a052b249..f7608392b 100644 --- a/client/src/types/mongoSchema.d.ts +++ b/client/src/types/mongoSchema.d.ts @@ -5,6 +5,7 @@ import { BillSourceEnum, InformTypeEnum } from '@/constants/user'; import { TrainingModeEnum } from '@/constants/plugin'; import type { AppModuleItemType } from './app'; import { ChatSourceEnum, OutLinkTypeEnum } from '@/constants/chat'; +import { AppTypeEnum } from '@/constants/app'; export interface UserModelSchema { _id: string; @@ -37,6 +38,7 @@ export interface AppSchema { _id: string; userId: string; name: string; + type: `${AppTypeEnum}`; avatar: string; intro: string; updateTime: number;