perf: app type

This commit is contained in:
archer
2023-08-07 12:59:52 +08:00
parent e190ee92e8
commit 2f614ac40d
12 changed files with 66 additions and 19 deletions

View File

@@ -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",

View File

@@ -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 问答系统",

View File

@@ -11,3 +11,8 @@ export enum VariableInputEnum {
input = 'input',
select = 'select'
}
export enum AppTypeEnum {
basic = 'basic',
advanced = 'advanced'
}

View File

@@ -12,6 +12,7 @@ export const defaultApp: AppSchema = {
_id: '',
userId: 'userId',
name: '模型加载中',
type: 'basic',
avatar: '/icon/logo.png',
intro: '',
updateTime: Date.now(),

View File

@@ -9,7 +9,7 @@ import { authApp } from '@/service/utils/auth';
/* 获取我的模型 */
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
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,

View File

@@ -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: '保存配置成功',

View File

@@ -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 ? '保存并预览' : '保存'}
</Button>
@@ -558,6 +566,7 @@ const Settings = ({ appId }: { appId: string }) => {
};
const ChatTest = ({ appId }: { appId: string }) => {
const { t } = useTranslation();
const { appDetail, userInfo } = useUserStore();
const ChatBoxRef = useRef<ComponentRef>(null);
const [modules, setModules] = useState<AppModuleItemType[]>([]);
@@ -602,7 +611,7 @@ const ChatTest = ({ appId }: { appId: string }) => {
}, [appDetail, resetChatBox]);
return (
<Flex flexDirection={'column'} h={'100%'} py={4} overflowX={'auto'}>
<Flex position={'relative'} flexDirection={'column'} h={'100%'} py={4} overflowX={'auto'}>
<Flex px={[2, 5]}>
<Box fontSize={['md', 'xl']} fontWeight={'bold'} flex={1}>
@@ -632,6 +641,25 @@ const ChatTest = ({ appId }: { appId: string }) => {
onDelMessage={() => {}}
/>
</Box>
{appDetail.type !== AppTypeEnum.basic && (
<Flex
position={'absolute'}
top={0}
right={0}
left={0}
bottom={0}
bg={'rgba(255,255,255,0.6)'}
alignItems={'center'}
justifyContent={'center'}
flexDirection={'column'}
fontSize={'lg'}
color={'black'}
whiteSpace={'pre-wrap'}
textAlign={'center'}
>
<Box>{t('app.Advance App TestTip')}</Box>
</Flex>
)}
</Flex>
);
};

View File

@@ -208,9 +208,7 @@ const DataCard = ({ kbId }: { kbId: string }) => {
<Box color={'myGray.1000'} mb={2}>
{item.q}
</Box>
<Box color={'myGray.600'} className={'textEllipsis3'}>
{item.a}
</Box>
<Box color={'myGray.600'}>{item.a}</Box>
</Box>
<Flex py={2} px={4} h={'36px'} alignItems={'flex-end'} fontSize={'sm'}>
<Box className={'textEllipsis'} flex={1}>

View File

@@ -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],

View File

@@ -30,7 +30,7 @@ export const defaultHistory: ShareChatHistoryItemType = {
const defaultShareChatData: ShareChatType = {
userAvatar: HUMAN_ICON,
app: {
name: 'AI',
name: '',
avatar: '/icon/logo.png',
intro: ''
},

View File

@@ -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'];

View File

@@ -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;