head ,csv template and limit content size
This commit is contained in:
parent
ae95a8908e
commit
58d94e1018
@ -1,4 +1,5 @@
|
|||||||
import React, { useCallback, useRef } from 'react';
|
import React, { useCallback, useRef } from 'react';
|
||||||
|
import Head from 'next/head';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { getInitChatSiteInfo, delChatRecordByIndex, putChatHistory } from '@/api/chat';
|
import { getInitChatSiteInfo, delChatRecordByIndex, putChatHistory } from '@/api/chat';
|
||||||
import {
|
import {
|
||||||
@ -244,6 +245,9 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex h={'100%'}>
|
<Flex h={'100%'}>
|
||||||
|
<Head>
|
||||||
|
<title>{chatData.app.name}</title>
|
||||||
|
</Head>
|
||||||
{/* pc show myself apps */}
|
{/* pc show myself apps */}
|
||||||
{isPc && (
|
{isPc && (
|
||||||
<Box p={5} borderRight={theme.borders.base} w={'220px'} flexShrink={0}>
|
<Box p={5} borderRight={theme.borders.base} w={'220px'} flexShrink={0}>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import React, { useCallback, useMemo, useRef } from 'react';
|
import React, { useCallback, useMemo, useRef } from 'react';
|
||||||
|
import Head from 'next/head';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { initShareChatInfo } from '@/api/chat';
|
import { initShareChatInfo } from '@/api/chat';
|
||||||
import { Box, Flex, useDisclosure, Drawer, DrawerOverlay, DrawerContent } from '@chakra-ui/react';
|
import { Box, Flex, useDisclosure, Drawer, DrawerOverlay, DrawerContent } from '@chakra-ui/react';
|
||||||
@ -146,6 +147,9 @@ const OutLink = ({ shareId, chatId }: { shareId: string; chatId: string }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer>
|
<PageContainer>
|
||||||
|
<Head>
|
||||||
|
<title>{shareChatData.app.name}</title>
|
||||||
|
</Head>
|
||||||
<Flex h={'100%'} flexDirection={['column', 'row']}>
|
<Flex h={'100%'} flexDirection={['column', 'row']}>
|
||||||
{((children: React.ReactNode) => {
|
{((children: React.ReactNode) => {
|
||||||
return isPc ? (
|
return isPc ? (
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const fileExtension = '.csv';
|
|||||||
type FileItemType = {
|
type FileItemType = {
|
||||||
id: string;
|
id: string;
|
||||||
filename: string;
|
filename: string;
|
||||||
chunks: { q: string; a: string }[];
|
chunks: { q: string; a: string; source?: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const CsvImport = ({ kbId }: { kbId: string }) => {
|
const CsvImport = ({ kbId }: { kbId: string }) => {
|
||||||
@ -61,7 +61,8 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
|||||||
filename: file.name,
|
filename: file.name,
|
||||||
chunks: data.map((item) => ({
|
chunks: data.map((item) => ({
|
||||||
q: item[0],
|
q: item[0],
|
||||||
a: item[1]
|
a: item[1],
|
||||||
|
source: item[2]
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
...state
|
...state
|
||||||
@ -88,7 +89,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
|||||||
file.chunks.forEach((chunk) => {
|
file.chunks.forEach((chunk) => {
|
||||||
chunks.push({
|
chunks.push({
|
||||||
...chunk,
|
...chunk,
|
||||||
source: file.filename
|
source: chunk.source || file.filename
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -210,6 +211,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
|||||||
<Box px={3} py={'1px'} border={theme.borders.base} borderRadius={'md'}>
|
<Box px={3} py={'1px'} border={theme.borders.base} borderRadius={'md'}>
|
||||||
# {i + 1}
|
# {i + 1}
|
||||||
</Box>
|
</Box>
|
||||||
|
{item.source && <Box ml={1}>({item.source})</Box>}
|
||||||
<Box flex={1} />
|
<Box flex={1} />
|
||||||
<DeleteIcon
|
<DeleteIcon
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ const FileSelect = ({
|
|||||||
...props
|
...props
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { Loading: FileSelectLoading } = useLoading();
|
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({
|
const { File, onOpen } = useSelectFile({
|
||||||
fileType: fileExtension,
|
fileType: fileExtension,
|
||||||
@ -72,7 +72,7 @@ const FileSelect = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
点击下载csv模板
|
点击下载 CSV 模板
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<FileSelectLoading loading={isLoading} fixed={false} />
|
<FileSelectLoading loading={isLoading} fixed={false} />
|
||||||
|
|||||||
@ -35,12 +35,13 @@ export async function saveChat({
|
|||||||
|
|
||||||
if (chatHistory) {
|
if (chatHistory) {
|
||||||
promise.push(
|
promise.push(
|
||||||
Chat.findOneAndUpdate(
|
Chat.updateOne(
|
||||||
{ chatId, userId },
|
{ chatId, userId },
|
||||||
{
|
{
|
||||||
$push: {
|
$push: {
|
||||||
content: {
|
content: {
|
||||||
$each: content
|
$each: content,
|
||||||
|
$slice: -50
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: content[0].value.slice(0, 20),
|
title: content[0].value.slice(0, 20),
|
||||||
|
|||||||
@ -264,7 +264,7 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
|||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
key: 'maxContext',
|
key: 'maxContext',
|
||||||
value: 10,
|
value: 6,
|
||||||
connected: true
|
connected: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -340,7 +340,7 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
|||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
key: 'maxContext',
|
key: 'maxContext',
|
||||||
value: 10,
|
value: 6,
|
||||||
connected: true
|
connected: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user