perf: attribute
This commit is contained in:
@@ -238,7 +238,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
|
||||
router.prefetch('/chat');
|
||||
await saveUpdateModel();
|
||||
} catch (error) {}
|
||||
router.push(`/chat?modelId=${modelId}`);
|
||||
router.push(`/chat?appId=${modelId}`);
|
||||
}}
|
||||
>
|
||||
对话
|
||||
|
||||
@@ -31,8 +31,8 @@ const ModuleStoreList = ({
|
||||
position={'fixed'}
|
||||
top={0}
|
||||
left={0}
|
||||
right={0}
|
||||
bottom={0}
|
||||
w={'360px'}
|
||||
></Box>
|
||||
<Flex
|
||||
zIndex={3}
|
||||
@@ -66,7 +66,7 @@ const ModuleStoreList = ({
|
||||
borderRadius={'md'}
|
||||
draggable
|
||||
onDragEnd={(e) => {
|
||||
// if (e.clientX < 400) return;
|
||||
if (e.clientX < 360) return;
|
||||
onAddNode({
|
||||
template: item,
|
||||
position: { x: e.clientX, y: e.clientY }
|
||||
|
||||
@@ -187,6 +187,7 @@ const AppEdit = ({ app, onBack }: Props) => {
|
||||
targets: [] as FlowOutputTargetItemType[]
|
||||
}))
|
||||
}));
|
||||
console.log(modules);
|
||||
|
||||
// update inputs and outputs
|
||||
modules.forEach((module) => {
|
||||
|
||||
@@ -83,7 +83,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
|
||||
<Box display={['block', 'flex']} h={'100%'}>
|
||||
{/* pc tab */}
|
||||
<Box display={['none', 'block']} p={4} w={'200px'} borderRight={theme.borders.base}>
|
||||
<Flex mb={4}>
|
||||
<Flex mb={4} alignItems={'center'}>
|
||||
<Avatar src={appDetail.avatar} w={'34px'} borderRadius={'lg'} />
|
||||
<Box ml={2} fontWeight={'bold'}>
|
||||
{appDetail.name}
|
||||
@@ -97,7 +97,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
|
||||
activeId={currentTab}
|
||||
onChange={(e: any) => {
|
||||
if (e === 'startChat') {
|
||||
router.push(`/chat?modelId=${appId}`);
|
||||
router.push(`/chat?appId=${appId}`);
|
||||
} else {
|
||||
setCurrentTab(e);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
|
||||
activeId={currentTab}
|
||||
onChange={(e: any) => {
|
||||
if (e === 'startChat') {
|
||||
router.push(`/chat?modelId=${appId}`);
|
||||
router.push(`/chat?appId=${appId}`);
|
||||
} else {
|
||||
setCurrentTab(e);
|
||||
}
|
||||
|
||||
@@ -21,47 +21,16 @@ import { getErrText } from '@/utils/tools';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { postCreateApp } from '@/api/app';
|
||||
import { useRouter } from 'next/router';
|
||||
import { chatAppDemo } from '@/constants/app';
|
||||
import { appTemplates } from '@/constants/app';
|
||||
import Avatar from '@/components/Avatar';
|
||||
import MyIcon from '@/components/Icon';
|
||||
|
||||
type FormType = {
|
||||
avatar: string;
|
||||
name: string;
|
||||
templateId: number;
|
||||
templateId: string;
|
||||
};
|
||||
|
||||
const templates = [
|
||||
{
|
||||
id: 0,
|
||||
icon: 'settings',
|
||||
name: '简单的对话',
|
||||
intro: '一个极其简单的 AI 对话应用',
|
||||
modules: chatAppDemo.modules
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
icon: 'settings',
|
||||
name: '基础知识库',
|
||||
intro: '每次提问时进行一次知识库搜索,将搜索结果注入 LLM 模型进行参考回答',
|
||||
modules: chatAppDemo.modules
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
icon: 'settings',
|
||||
name: '问答前引导',
|
||||
intro: '可以在每次对话开始前提示用户填写一些内容,作为本次对话的永久内容',
|
||||
modules: chatAppDemo.modules
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
icon: 'settings',
|
||||
name: '意图识别 + 知识库',
|
||||
intro: '先对用户的问题进行分类,再根据不同类型问题,执行不同的操作',
|
||||
modules: chatAppDemo.modules
|
||||
}
|
||||
];
|
||||
|
||||
const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: () => void }) => {
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [creating, setCreating] = useState(false);
|
||||
@@ -72,7 +41,7 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
|
||||
defaultValues: {
|
||||
avatar: '/icon/logo.png',
|
||||
name: '',
|
||||
templateId: 0
|
||||
templateId: appTemplates[0].id
|
||||
}
|
||||
});
|
||||
|
||||
@@ -110,7 +79,7 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
|
||||
const id = await postCreateApp({
|
||||
avatar: data.avatar,
|
||||
name: data.name,
|
||||
modules: templates.find((item) => item.id === data.templateId)?.modules || []
|
||||
modules: appTemplates.find((item) => item.id === data.templateId)?.modules || []
|
||||
});
|
||||
toast({
|
||||
title: '创建成功',
|
||||
@@ -163,7 +132,7 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
|
||||
gridTemplateColumns={['repeat(1,1fr)', 'repeat(2,1fr)']}
|
||||
gridGap={4}
|
||||
>
|
||||
{templates.map((item) => (
|
||||
{appTemplates.map((item) => (
|
||||
<Card
|
||||
key={item.id}
|
||||
border={theme.borders.base}
|
||||
@@ -186,7 +155,7 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
|
||||
}}
|
||||
>
|
||||
<Flex alignItems={'center'}>
|
||||
<MyIcon name={'apikey'} w={'16px'} />
|
||||
<Avatar src={item.avatar} borderRadius={'md'} w={'20px'} />
|
||||
<Box ml={3} fontWeight={'bold'}>
|
||||
{item.name}
|
||||
</Box>
|
||||
|
||||
@@ -89,22 +89,27 @@ const MyApps = () => {
|
||||
border={theme.borders.md}
|
||||
boxShadow={'none'}
|
||||
userSelect={'none'}
|
||||
position={'relative'}
|
||||
_hover={{
|
||||
boxShadow: '1px 1px 10px rgba(0,0,0,0.2)',
|
||||
borderColor: 'transparent',
|
||||
'& .delete': {
|
||||
display: 'block'
|
||||
},
|
||||
'& .chat': {
|
||||
display: 'block'
|
||||
}
|
||||
}}
|
||||
onClick={() => router.push(`/app/detail?appId=${app._id}`)}
|
||||
>
|
||||
<Flex alignItems={'center'} h={'38px'} position={'relative'}>
|
||||
<Flex alignItems={'center'} h={'38px'}>
|
||||
<Avatar src={app.avatar} borderRadius={'md'} w={'28px'} />
|
||||
<Box ml={3}>{app.name}</Box>
|
||||
<IconButton
|
||||
className="delete"
|
||||
position={'absolute'}
|
||||
right={0}
|
||||
top={4}
|
||||
right={4}
|
||||
size={'sm'}
|
||||
icon={<MyIcon name={'delete'} w={'14px'} />}
|
||||
variant={'base'}
|
||||
@@ -129,6 +134,25 @@ const MyApps = () => {
|
||||
>
|
||||
{app.intro || '这个应用还没写介绍~'}
|
||||
</Box>
|
||||
<IconButton
|
||||
className="chat"
|
||||
position={'absolute'}
|
||||
right={4}
|
||||
bottom={4}
|
||||
size={'sm'}
|
||||
icon={<MyIcon name={'chatLight'} w={'14px'} />}
|
||||
variant={'base'}
|
||||
borderRadius={'md'}
|
||||
aria-label={'delete'}
|
||||
display={['', 'none']}
|
||||
_hover={{
|
||||
bg: 'myGray.100'
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
router.push(`/chat?appId=${app._id}`);
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
))}
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user