head ,csv template and limit content size

This commit is contained in:
archer
2023-08-02 14:52:27 +08:00
parent ae95a8908e
commit 58d94e1018
6 changed files with 20 additions and 9 deletions

View File

@@ -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 (
<Flex h={'100%'}>
<Head>
<title>{chatData.app.name}</title>
</Head>
{/* pc show myself apps */}
{isPc && (
<Box p={5} borderRight={theme.borders.base} w={'220px'} flexShrink={0}>

View File

@@ -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 (
<PageContainer>
<Head>
<title>{shareChatData.app.name}</title>
</Head>
<Flex h={'100%'} flexDirection={['column', 'row']}>
{((children: React.ReactNode) => {
return isPc ? (

View File

@@ -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 }) => {
<Box px={3} py={'1px'} border={theme.borders.base} borderRadius={'md'}>
# {i + 1}
</Box>
{item.source && <Box ml={1}>({item.source})</Box>}
<Box flex={1} />
<DeleteIcon
onClick={() => {

View File

@@ -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
</Box>
)}
<FileSelectLoading loading={isLoading} fixed={false} />

View File

@@ -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),

View File

@@ -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
},
{