perf: app type
This commit is contained in:
parent
e190ee92e8
commit
2f614ac40d
@ -2,12 +2,13 @@
|
|||||||
"App": "App",
|
"App": "App",
|
||||||
"Cancel": "No",
|
"Cancel": "No",
|
||||||
"Confirm": "Yes",
|
"Confirm": "Yes",
|
||||||
"Warning": "Warning",
|
|
||||||
"Running": "Running",
|
"Running": "Running",
|
||||||
|
"Warning": "Warning",
|
||||||
"app": {
|
"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",
|
"App Detail": "App Detail",
|
||||||
"Confirm Del App Tip": "Confirm to delete the app and all its chats",
|
"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 is invalid": "Connecting is invalid",
|
||||||
"Connection type is different": "Connection type is different",
|
"Connection type is different": "Connection type is different",
|
||||||
"Input Field Settings": "Input Field Settings",
|
"Input Field Settings": "Input Field Settings",
|
||||||
@ -31,11 +32,11 @@
|
|||||||
"file": {
|
"file": {
|
||||||
"Click to download CSV template": "Click to download CSV template",
|
"Click to download CSV template": "Click to download CSV template",
|
||||||
"Drag and drop": "Drag and drop files here, or click",
|
"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",
|
"Release the mouse to upload the file": "Release the mouse to upload the file",
|
||||||
"select a document": "select a document",
|
"select a document": "select a document",
|
||||||
"support": "support {{fileExtension}} file",
|
"support": "support {{fileExtension}} file",
|
||||||
"upload error description": "Only upload multiple files or one folder at a time",
|
"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"
|
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"Quickly build AI question and answer library": "Quickly build AI question and answer library",
|
"Quickly build AI question and answer library": "Quickly build AI question and answer library",
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
"App": "应用",
|
"App": "应用",
|
||||||
"Cancel": "取消",
|
"Cancel": "取消",
|
||||||
"Confirm": "确认",
|
"Confirm": "确认",
|
||||||
"Warning": "提示",
|
|
||||||
"Running": "运行中",
|
"Running": "运行中",
|
||||||
|
"Warning": "提示",
|
||||||
"app": {
|
"app": {
|
||||||
|
"Advance App TestTip": "当前应用为高级编排模式\n如需切换为【简易模式】请点击左侧保存按键",
|
||||||
"App Detail": "应用详情",
|
"App Detail": "应用详情",
|
||||||
"Confirm Del App Tip": "确认删除该应用及其所有聊天记录?",
|
"Confirm Del App Tip": "确认删除该应用及其所有聊天记录?",
|
||||||
"Confirm Save App Tip": "保存后将会覆盖高级编排配置,请确保该应用未使用高级编排功能。",
|
"Confirm Save App Tip": "该应用可能为高级编排模式,保存后将会覆盖高级编排配置,请确认!",
|
||||||
"Connection is invalid": "连接无效",
|
"Connection is invalid": "连接无效",
|
||||||
"Connection type is different": "连接的类型不一致",
|
"Connection type is different": "连接的类型不一致",
|
||||||
"Input Field Settings": "输入字段编辑",
|
"Input Field Settings": "输入字段编辑",
|
||||||
@ -31,11 +32,11 @@
|
|||||||
"file": {
|
"file": {
|
||||||
"Click to download CSV template": "点击下载 CSV 模板",
|
"Click to download CSV template": "点击下载 CSV 模板",
|
||||||
"Drag and drop": "拖拽文件至此,或点击",
|
"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": "松开鼠标上传文件",
|
"Release the mouse to upload the file": "松开鼠标上传文件",
|
||||||
"select a document": "选择文件",
|
"select a document": "选择文件",
|
||||||
"support": "支持 {{fileExtension}} 文件",
|
"support": "支持 {{fileExtension}} 文件",
|
||||||
"upload error description": "单次只支持上传多个文件或者一个文件夹",
|
"upload error description": "单次只支持上传多个文件或者一个文件夹"
|
||||||
"If the imported file is garbled, please convert CSV to UTF-8 encoding format": "如果导入文件乱码,请将 CSV 转成 UTF-8 编码格式"
|
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"Quickly build AI question and answer library": "快速搭建 AI 问答系统",
|
"Quickly build AI question and answer library": "快速搭建 AI 问答系统",
|
||||||
|
|||||||
@ -11,3 +11,8 @@ export enum VariableInputEnum {
|
|||||||
input = 'input',
|
input = 'input',
|
||||||
select = 'select'
|
select = 'select'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum AppTypeEnum {
|
||||||
|
basic = 'basic',
|
||||||
|
advanced = 'advanced'
|
||||||
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ export const defaultApp: AppSchema = {
|
|||||||
_id: '',
|
_id: '',
|
||||||
userId: 'userId',
|
userId: 'userId',
|
||||||
name: '模型加载中',
|
name: '模型加载中',
|
||||||
|
type: 'basic',
|
||||||
avatar: '/icon/logo.png',
|
avatar: '/icon/logo.png',
|
||||||
intro: '',
|
intro: '',
|
||||||
updateTime: Date.now(),
|
updateTime: Date.now(),
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { authApp } from '@/service/utils/auth';
|
|||||||
/* 获取我的模型 */
|
/* 获取我的模型 */
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||||
try {
|
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 };
|
const { appId } = req.query as { appId: string };
|
||||||
|
|
||||||
if (!appId) {
|
if (!appId) {
|
||||||
@ -34,6 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
|
type,
|
||||||
avatar,
|
avatar,
|
||||||
intro,
|
intro,
|
||||||
chat,
|
chat,
|
||||||
|
|||||||
@ -77,6 +77,7 @@ const NodeHttp = dynamic(() => import('./components/Nodes/NodeHttp'), {
|
|||||||
|
|
||||||
import 'reactflow/dist/style.css';
|
import 'reactflow/dist/style.css';
|
||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss';
|
||||||
|
import { AppTypeEnum } from '@/constants/app';
|
||||||
|
|
||||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
|
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
|
||||||
|
|
||||||
@ -347,7 +348,8 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
|||||||
const { mutate: onclickSave, isLoading } = useRequest({
|
const { mutate: onclickSave, isLoading } = useRequest({
|
||||||
mutationFn: () => {
|
mutationFn: () => {
|
||||||
return updateAppDetail(app._id, {
|
return updateAppDetail(app._id, {
|
||||||
modules: flow2AppModules()
|
modules: flow2AppModules(),
|
||||||
|
type: AppTypeEnum.advanced
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
successToast: '保存配置成功',
|
successToast: '保存配置成功',
|
||||||
|
|||||||
@ -44,6 +44,8 @@ import { useRouter } from 'next/router';
|
|||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
import { AppSchema } from '@/types/mongoSchema';
|
import { AppSchema } from '@/types/mongoSchema';
|
||||||
import { delModelById } from '@/api/app';
|
import { delModelById } from '@/api/app';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { getSpecialModule } from '@/components/ChatBox/utils';
|
||||||
|
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import MySelect from '@/components/Select';
|
import MySelect from '@/components/Select';
|
||||||
@ -52,11 +54,10 @@ import MyTooltip from '@/components/MyTooltip';
|
|||||||
import Avatar from '@/components/Avatar';
|
import Avatar from '@/components/Avatar';
|
||||||
import MyIcon from '@/components/Icon';
|
import MyIcon from '@/components/Icon';
|
||||||
import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox';
|
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 { addVariable } from '../VariableEditModal';
|
||||||
import { KBSelectModal, KbParamsModal } from '../KBSelectModal';
|
import { KBSelectModal, KbParamsModal } from '../KBSelectModal';
|
||||||
|
import { AppTypeEnum } from '@/constants/app';
|
||||||
|
|
||||||
const VariableEditModal = dynamic(() => import('../VariableEditModal'));
|
const VariableEditModal = dynamic(() => import('../VariableEditModal'));
|
||||||
const InfoModal = dynamic(() => import('../InfoModal'));
|
const InfoModal = dynamic(() => import('../InfoModal'));
|
||||||
@ -154,7 +155,8 @@ const Settings = ({ appId }: { appId: string }) => {
|
|||||||
const modules = appForm2Modules(data);
|
const modules = appForm2Modules(data);
|
||||||
|
|
||||||
await updateAppDetail(appDetail._id, {
|
await updateAppDetail(appDetail._id, {
|
||||||
modules
|
modules,
|
||||||
|
type: AppTypeEnum.basic
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
successToast: '保存成功',
|
successToast: '保存成功',
|
||||||
@ -290,7 +292,13 @@ const Settings = ({ appId }: { appId: string }) => {
|
|||||||
isLoading={isSaving}
|
isLoading={isSaving}
|
||||||
fontSize={'sm'}
|
fontSize={'sm'}
|
||||||
size={['sm', 'md']}
|
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 ? '保存并预览' : '保存'}
|
{isPc ? '保存并预览' : '保存'}
|
||||||
</Button>
|
</Button>
|
||||||
@ -558,6 +566,7 @@ const Settings = ({ appId }: { appId: string }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ChatTest = ({ appId }: { appId: string }) => {
|
const ChatTest = ({ appId }: { appId: string }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { appDetail, userInfo } = useUserStore();
|
const { appDetail, userInfo } = useUserStore();
|
||||||
const ChatBoxRef = useRef<ComponentRef>(null);
|
const ChatBoxRef = useRef<ComponentRef>(null);
|
||||||
const [modules, setModules] = useState<AppModuleItemType[]>([]);
|
const [modules, setModules] = useState<AppModuleItemType[]>([]);
|
||||||
@ -602,7 +611,7 @@ const ChatTest = ({ appId }: { appId: string }) => {
|
|||||||
}, [appDetail, resetChatBox]);
|
}, [appDetail, resetChatBox]);
|
||||||
|
|
||||||
return (
|
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]}>
|
<Flex px={[2, 5]}>
|
||||||
<Box fontSize={['md', 'xl']} fontWeight={'bold'} flex={1}>
|
<Box fontSize={['md', 'xl']} fontWeight={'bold'} flex={1}>
|
||||||
调试预览
|
调试预览
|
||||||
@ -632,6 +641,25 @@ const ChatTest = ({ appId }: { appId: string }) => {
|
|||||||
onDelMessage={() => {}}
|
onDelMessage={() => {}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</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>
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -208,9 +208,7 @@ const DataCard = ({ kbId }: { kbId: string }) => {
|
|||||||
<Box color={'myGray.1000'} mb={2}>
|
<Box color={'myGray.1000'} mb={2}>
|
||||||
{item.q}
|
{item.q}
|
||||||
</Box>
|
</Box>
|
||||||
<Box color={'myGray.600'} className={'textEllipsis3'}>
|
<Box color={'myGray.600'}>{item.a}</Box>
|
||||||
{item.a}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Flex py={2} px={4} h={'36px'} alignItems={'flex-end'} fontSize={'sm'}>
|
<Flex py={2} px={4} h={'36px'} alignItems={'flex-end'} fontSize={'sm'}>
|
||||||
<Box className={'textEllipsis'} flex={1}>
|
<Box className={'textEllipsis'} flex={1}>
|
||||||
|
|||||||
@ -11,6 +11,11 @@ const AppSchema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'advanced',
|
||||||
|
enum: ['basic', 'advanced']
|
||||||
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '/icon/logo.png'
|
default: '/icon/logo.png'
|
||||||
@ -51,6 +56,7 @@ const AppSchema = new Schema({
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: []
|
default: []
|
||||||
},
|
},
|
||||||
|
// 弃
|
||||||
chat: {
|
chat: {
|
||||||
relatedKbs: {
|
relatedKbs: {
|
||||||
type: [Schema.Types.ObjectId],
|
type: [Schema.Types.ObjectId],
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export const defaultHistory: ShareChatHistoryItemType = {
|
|||||||
const defaultShareChatData: ShareChatType = {
|
const defaultShareChatData: ShareChatType = {
|
||||||
userAvatar: HUMAN_ICON,
|
userAvatar: HUMAN_ICON,
|
||||||
app: {
|
app: {
|
||||||
name: 'AI',
|
name: '',
|
||||||
avatar: '/icon/logo.png',
|
avatar: '/icon/logo.png',
|
||||||
intro: ''
|
intro: ''
|
||||||
},
|
},
|
||||||
|
|||||||
2
client/src/types/app.d.ts
vendored
2
client/src/types/app.d.ts
vendored
@ -2,6 +2,7 @@ import { FlowModuleTypeEnum } from '@/constants/flow';
|
|||||||
import { XYPosition } from 'reactflow';
|
import { XYPosition } from 'reactflow';
|
||||||
import {
|
import {
|
||||||
AppModuleItemTypeEnum,
|
AppModuleItemTypeEnum,
|
||||||
|
AppTypeEnum,
|
||||||
ModulesInputItemTypeEnum,
|
ModulesInputItemTypeEnum,
|
||||||
VariableInputEnum
|
VariableInputEnum
|
||||||
} from '../constants/app';
|
} from '../constants/app';
|
||||||
@ -19,6 +20,7 @@ export type AppListItemType = {
|
|||||||
|
|
||||||
export interface AppUpdateParams {
|
export interface AppUpdateParams {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
type?: `${AppTypeEnum}`;
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
intro?: string;
|
intro?: string;
|
||||||
chat?: AppSchema['chat'];
|
chat?: AppSchema['chat'];
|
||||||
|
|||||||
2
client/src/types/mongoSchema.d.ts
vendored
2
client/src/types/mongoSchema.d.ts
vendored
@ -5,6 +5,7 @@ import { BillSourceEnum, InformTypeEnum } from '@/constants/user';
|
|||||||
import { TrainingModeEnum } from '@/constants/plugin';
|
import { TrainingModeEnum } from '@/constants/plugin';
|
||||||
import type { AppModuleItemType } from './app';
|
import type { AppModuleItemType } from './app';
|
||||||
import { ChatSourceEnum, OutLinkTypeEnum } from '@/constants/chat';
|
import { ChatSourceEnum, OutLinkTypeEnum } from '@/constants/chat';
|
||||||
|
import { AppTypeEnum } from '@/constants/app';
|
||||||
|
|
||||||
export interface UserModelSchema {
|
export interface UserModelSchema {
|
||||||
_id: string;
|
_id: string;
|
||||||
@ -37,6 +38,7 @@ export interface AppSchema {
|
|||||||
_id: string;
|
_id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
type: `${AppTypeEnum}`;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
intro: string;
|
intro: string;
|
||||||
updateTime: number;
|
updateTime: number;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user