Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
58d94e10
authored
Aug 02, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
head ,csv template and limit content size
parent
ae95a890
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
9 deletions
+20
-9
client/src/pages/chat/index.tsx
+4
-0
client/src/pages/chat/share.tsx
+4
-0
client/src/pages/kb/detail/components/Import/Csv.tsx
+5
-3
client/src/pages/kb/detail/components/Import/FileSelect.tsx
+2
-2
client/src/service/utils/chat/saveChat.ts
+3
-2
client/src/utils/app.ts
+2
-2
No files found.
client/src/pages/chat/index.tsx
View file @
58d94e10
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
}
>
...
...
client/src/pages/chat/share.tsx
View file @
58d94e10
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
?
(
...
...
client/src/pages/kb/detail/components/Import/Csv.tsx
View file @
58d94e10
...
...
@@ -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=
{
()
=>
{
...
...
client/src/pages/kb/detail/components/Import/FileSelect.tsx
View file @
58d94e10
...
...
@@ -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
}
/>
...
...
client/src/service/utils/chat/saveChat.ts
View file @
58d94e10
...
...
@@ -35,12 +35,13 @@ export async function saveChat({
if
(
chatHistory
)
{
promise
.
push
(
Chat
.
findOneAndUpdat
e
(
Chat
.
updateOn
e
(
{
chatId
,
userId
},
{
$push
:
{
content
:
{
$each
:
content
$each
:
content
,
$slice
:
-
50
}
},
title
:
content
[
0
].
value
.
slice
(
0
,
20
),
...
...
client/src/utils/app.ts
View file @
58d94e10
...
...
@@ -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
},
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment