diff --git a/client/src/pages/chat/index.tsx b/client/src/pages/chat/index.tsx index 7d06e54d1f..7add276efb 100644 --- a/client/src/pages/chat/index.tsx +++ b/client/src/pages/chat/index.tsx @@ -1,4 +1,5 @@ import React, { useCallback, useRef } from 'react'; +import Head from 'next/head'; import { useRouter } from 'next/router'; import { getInitChatSiteInfo, delChatRecordByIndex, putChatHistory } from '@/api/chat'; import { @@ -244,6 +245,9 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => { return ( + + {chatData.app.name} + {/* pc show myself apps */} {isPc && ( diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx index fd681dfda3..eb3606673d 100644 --- a/client/src/pages/chat/share.tsx +++ b/client/src/pages/chat/share.tsx @@ -1,4 +1,5 @@ import React, { useCallback, useMemo, useRef } from 'react'; +import Head from 'next/head'; import { useRouter } from 'next/router'; import { initShareChatInfo } from '@/api/chat'; import { Box, Flex, useDisclosure, Drawer, DrawerOverlay, DrawerContent } from '@chakra-ui/react'; @@ -146,6 +147,9 @@ const OutLink = ({ shareId, chatId }: { shareId: string; chatId: string }) => { return ( + + {shareChatData.app.name} + {((children: React.ReactNode) => { return isPc ? ( diff --git a/client/src/pages/kb/detail/components/Import/Csv.tsx b/client/src/pages/kb/detail/components/Import/Csv.tsx index 169bbfb3dc..3a0d9f0d60 100644 --- a/client/src/pages/kb/detail/components/Import/Csv.tsx +++ b/client/src/pages/kb/detail/components/Import/Csv.tsx @@ -20,7 +20,7 @@ const fileExtension = '.csv'; type FileItemType = { id: string; filename: string; - chunks: { q: string; a: string }[]; + chunks: { q: string; a: string; source?: string }[]; }; const CsvImport = ({ kbId }: { kbId: string }) => { @@ -61,7 +61,8 @@ const CsvImport = ({ kbId }: { kbId: string }) => { filename: file.name, chunks: data.map((item) => ({ q: item[0], - a: item[1] + a: item[1], + source: item[2] })) }, ...state @@ -88,7 +89,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => { file.chunks.forEach((chunk) => { chunks.push({ ...chunk, - source: file.filename + source: chunk.source || file.filename }); }) ); @@ -210,6 +211,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => { # {i + 1} + {item.source && ({item.source})} { diff --git a/client/src/pages/kb/detail/components/Import/FileSelect.tsx b/client/src/pages/kb/detail/components/Import/FileSelect.tsx index d190efcbcf..c97375fa4e 100644 --- a/client/src/pages/kb/detail/components/Import/FileSelect.tsx +++ b/client/src/pages/kb/detail/components/Import/FileSelect.tsx @@ -23,7 +23,7 @@ const FileSelect = ({ ...props }: Props) => { const { Loading: FileSelectLoading } = useLoading(); - const csvTemplate = `question,answer\n"什么是 laf","laf 是一个云函数开发平台……"\n"什么是 sealos","Sealos 是以 kubernetes 为内核的云操作系统发行版,可以……"`; + const csvTemplate = `question,answer,source\n"什么是 laf","laf 是一个云函数开发平台……","laf git doc"\n"什么是 sealos","Sealos 是以 kubernetes 为内核的云操作系统发行版,可以……","sealos git doc"`; const { File, onOpen } = useSelectFile({ fileType: fileExtension, @@ -72,7 +72,7 @@ const FileSelect = ({ }) } > - 点击下载csv模板 + 点击下载 CSV 模板 )} diff --git a/client/src/service/utils/chat/saveChat.ts b/client/src/service/utils/chat/saveChat.ts index 1ddf82474d..b63287b322 100644 --- a/client/src/service/utils/chat/saveChat.ts +++ b/client/src/service/utils/chat/saveChat.ts @@ -35,12 +35,13 @@ export async function saveChat({ if (chatHistory) { promise.push( - Chat.findOneAndUpdate( + Chat.updateOne( { chatId, userId }, { $push: { content: { - $each: content + $each: content, + $slice: -50 } }, title: content[0].value.slice(0, 20), diff --git a/client/src/utils/app.ts b/client/src/utils/app.ts index 3a81bac06a..9556612e0a 100644 --- a/client/src/utils/app.ts +++ b/client/src/utils/app.ts @@ -264,7 +264,7 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [ inputs: [ { key: 'maxContext', - value: 10, + value: 6, connected: true }, { @@ -340,7 +340,7 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [ inputs: [ { key: 'maxContext', - value: 10, + value: 6, connected: true }, {