feat: chat model show

This commit is contained in:
archer
2023-07-25 16:11:16 +08:00
parent 35718b1f26
commit e5e720e87e
13 changed files with 72 additions and 53 deletions

View File

@@ -7,7 +7,7 @@ import { ChatItemType } from '@/types/chat';
import { authApp } from '@/service/utils/auth';
import mongoose from 'mongoose';
import type { ChatSchema } from '@/types/mongoSchema';
import { getSpecialModule } from '@/components/ChatBox';
import { getSpecialModule, getChatModelNameList } from '@/components/ChatBox/utils';
import { TaskResponseKeyEnum } from '@/constants/chat';
/* 初始化我的聊天框,需要身份验证 */
@@ -90,6 +90,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
appId,
app: {
...getSpecialModule(app.modules),
chatModels: getChatModelNameList(app.modules),
name: app.name,
avatar: app.avatar,
intro: app.intro,

View File

@@ -4,7 +4,7 @@ import { connectToDatabase, ShareChat, User } from '@/service/mongo';
import type { InitShareChatResponse } from '@/api/response/chat';
import { authApp } from '@/service/utils/auth';
import { HUMAN_ICON } from '@/constants/chat';
import { getSpecialModule } from '@/components/ChatBox';
import { getChatModelNameList, getSpecialModule } from '@/components/ChatBox/utils';
/* 初始化我的聊天框,需要身份验证 */
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -44,6 +44,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
userAvatar: user?.avatar || HUMAN_ICON,
app: {
...getSpecialModule(app.modules),
chatModels: getChatModelNameList(app.modules),
name: app.name,
avatar: app.avatar,
intro: app.intro

View File

@@ -14,11 +14,8 @@ import { FlowModuleTypeEnum } from '@/constants/flow';
import { streamFetch } from '@/api/fetch';
import MyTooltip from '@/components/MyTooltip';
import { useUserStore } from '@/store/user';
import ChatBox, {
getSpecialModule,
type ComponentRef,
type StartChatFnProps
} from '@/components/ChatBox';
import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox';
import { getSpecialModule } from '@/components/ChatBox/utils';
export type ChatTestComponentRef = {
resetChatTest: () => void;

View File

@@ -51,11 +51,9 @@ import MySlider from '@/components/Slider';
import MyTooltip from '@/components/MyTooltip';
import Avatar from '@/components/Avatar';
import MyIcon from '@/components/Icon';
import ChatBox, {
getSpecialModule,
type ComponentRef,
type StartChatFnProps
} from '@/components/ChatBox';
import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox';
import { getSpecialModule } from '@/components/ChatBox/utils';
import { addVariable } from '../VariableEditModal';
import { KBSelectModal, KbParamsModal } from '../KBSelectModal';

View File

@@ -11,16 +11,21 @@ const ChatHeader = ({
history,
appName,
appAvatar,
chatModels,
onOpenSlider
}: {
history: ChatItemType[];
appName: string;
appAvatar: string;
chatModels?: string[];
onOpenSlider: () => void;
}) => {
const theme = useTheme();
const { isPc } = useGlobalStore();
const title = useMemo(() => {}, []);
const title = useMemo(
() => history[history.length - 2]?.value?.slice(0, 8) || appName || '新对话',
[appName, history]
);
return (
<Flex
@@ -34,12 +39,18 @@ const ChatHeader = ({
{isPc ? (
<>
<Box mr={3} color={'myGray.1000'}>
{appName}
{title}
</Box>
<Tag display={'flex'}>
<Tag>
<MyIcon name={'history'} w={'14px'} />
<Box ml={1}>{history.length === 0 ? '新的对话' : `${history.length}条记录`}</Box>
</Tag>
{!!chatModels && (
<Tag ml={2} colorSchema={'green'}>
<MyIcon name={'chatModelTag'} w={'14px'} />
<Box ml={1}>{chatModels.join(',')}</Box>
</Tag>
)}
<Box flex={1} />
</>
) : (

View File

@@ -307,6 +307,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
appAvatar={chatData.app.avatar}
appName={chatData.app.name}
history={chatData.history}
chatModels={chatData.app.chatModels}
onOpenSlider={onOpenSlider}
/>