mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-09 04:08:10 +00:00
Merge remote-tracking branch 'origin/new-page-framework' into llm_framework
This commit is contained in:
commit
56cf51cbb7
@ -4,18 +4,18 @@ import { useSearchParams } from 'next/navigation'
|
|||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import { Table, Stack } from '@/lib/mui'
|
import { Table, Stack } from '@/lib/mui'
|
||||||
import { Popover, Pagination } from 'antd'
|
import { Popover, Pagination } from 'antd'
|
||||||
const page_size = 20;
|
const page_size = 20
|
||||||
|
|
||||||
const ChunkList = () => {
|
const ChunkList = () => {
|
||||||
const spaceName = useSearchParams().get('spacename')
|
const spaceName = useSearchParams().get('spacename')
|
||||||
const documentId = useSearchParams().get('documentid')
|
const documentId = useSearchParams().get('documentid')
|
||||||
const [total, setTotal] = useState<number>(0);
|
const [total, setTotal] = useState<number>(0)
|
||||||
const [current, setCurrent] = useState<number>(0);
|
const [current, setCurrent] = useState<number>(0)
|
||||||
const [chunkList, setChunkList] = useState<any>([])
|
const [chunkList, setChunkList] = useState<any>([])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchChunks() {
|
async function fetchChunks() {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/chunk/list`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/chunk/list`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -31,14 +31,16 @@ const ChunkList = () => {
|
|||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setChunkList(data.data.data)
|
setChunkList(data.data.data)
|
||||||
setTotal(data.data.total);
|
setTotal(data.data.total)
|
||||||
setCurrent(data.data.page);
|
setCurrent(data.data.page)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchChunks()
|
fetchChunks()
|
||||||
}, [])
|
}, [])
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
|
{chunkList.length ? (
|
||||||
|
<>
|
||||||
<Table color="neutral" stripe="odd" variant="outlined">
|
<Table color="neutral" stripe="odd" variant="outlined">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -77,9 +79,12 @@ const ChunkList = () => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
<Pagination current={current} total={total} onChange={async page => {
|
<Pagination
|
||||||
|
current={current}
|
||||||
|
total={total}
|
||||||
|
onChange={async (page) => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/chunk/list`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/chunk/list`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -95,11 +100,17 @@ const ChunkList = () => {
|
|||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setChunkList(data.data.data)
|
setChunkList(data.data.data)
|
||||||
setTotal(data.data.total);
|
setTotal(data.data.total)
|
||||||
setCurrent(data.data.page);
|
setCurrent(data.data.page)
|
||||||
}
|
}
|
||||||
}} hideOnSinglePage />
|
}}
|
||||||
|
hideOnSinglePage
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import {
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { InboxOutlined } from '@ant-design/icons'
|
import { InboxOutlined } from '@ant-design/icons'
|
||||||
import type { UploadProps } from 'antd'
|
import type { UploadProps } from 'antd'
|
||||||
import { Upload, message } from 'antd'
|
import { Upload, Pagination, message } from 'antd'
|
||||||
|
|
||||||
const { Dragger } = Upload
|
const { Dragger } = Upload
|
||||||
const Item = styled(Sheet)(({ theme }) => ({
|
const Item = styled(Sheet)(({ theme }) => ({
|
||||||
@ -51,6 +51,7 @@ const documentTypeList = [
|
|||||||
subTitle: 'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel'
|
subTitle: 'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
const page_size = 20;
|
||||||
|
|
||||||
const Documents = () => {
|
const Documents = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -62,9 +63,11 @@ const Documents = () => {
|
|||||||
const [documents, setDocuments] = useState<any>([])
|
const [documents, setDocuments] = useState<any>([])
|
||||||
const [webPageUrl, setWebPageUrl] = useState<string>('')
|
const [webPageUrl, setWebPageUrl] = useState<string>('')
|
||||||
const [documentName, setDocumentName] = useState<any>('')
|
const [documentName, setDocumentName] = useState<any>('')
|
||||||
const [textSource, setTextSource] = useState<string>('');
|
const [textSource, setTextSource] = useState<string>('')
|
||||||
const [text, setText] = useState<string>('');
|
const [text, setText] = useState<string>('')
|
||||||
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
||||||
|
const [total, setTotal] = useState<number>(0)
|
||||||
|
const [current, setCurrent] = useState<number>(0)
|
||||||
const props: UploadProps = {
|
const props: UploadProps = {
|
||||||
name: 'file',
|
name: 'file',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
@ -82,18 +85,23 @@ const Documents = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchDocuments() {
|
async function fetchDocuments() {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/list`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/list`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({
|
||||||
|
page: 1,
|
||||||
|
page_size
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setDocuments(data.data)
|
setDocuments(data.data.data)
|
||||||
|
setTotal(data.data.total)
|
||||||
|
setCurrent(data.data.page)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchDocuments()
|
fetchDocuments()
|
||||||
@ -113,6 +121,8 @@ const Documents = () => {
|
|||||||
+ Add Datasource
|
+ Add Datasource
|
||||||
</Button>
|
</Button>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
|
{documents.length ? (
|
||||||
|
<>
|
||||||
<Table color="neutral" stripe="odd" variant="outlined">
|
<Table color="neutral" stripe="odd" variant="outlined">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -157,7 +167,7 @@ const Documents = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/sync`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/sync`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -196,6 +206,38 @@ const Documents = () => {
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
|
<Pagination
|
||||||
|
current={current}
|
||||||
|
total={total}
|
||||||
|
onChange={async (page) => {
|
||||||
|
const res = await fetch(
|
||||||
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/list`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
page,
|
||||||
|
page_size
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
const data = await res.json()
|
||||||
|
if (data.success) {
|
||||||
|
setDocuments(data.data.data)
|
||||||
|
setTotal(data.data.total)
|
||||||
|
setCurrent(data.data.page)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
hideOnSinglePage
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -323,7 +365,7 @@ const Documents = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/add`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/add`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -341,18 +383,23 @@ const Documents = () => {
|
|||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddDocumentModalShow(false)
|
setIsAddDocumentModalShow(false)
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/list`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/list`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({
|
||||||
|
page: current,
|
||||||
|
page_size
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setDocuments(data.data)
|
setDocuments(data.data)
|
||||||
|
setTotal(data.data.total)
|
||||||
|
setCurrent(data.data.page)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed')
|
message.error(data.err_msg || 'failed')
|
||||||
@ -362,12 +409,12 @@ const Documents = () => {
|
|||||||
message.error('Please select a file')
|
message.error('Please select a file')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const formData = new FormData();
|
const formData = new FormData()
|
||||||
formData.append('doc_name', documentName);
|
formData.append('doc_name', documentName)
|
||||||
formData.append('doc_file', originFileObj);
|
formData.append('doc_file', originFileObj)
|
||||||
formData.append('doc_type', 'DOCUMENT');
|
formData.append('doc_type', 'DOCUMENT')
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/upload`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/upload`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
@ -378,18 +425,23 @@ const Documents = () => {
|
|||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddDocumentModalShow(false)
|
setIsAddDocumentModalShow(false)
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/list`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/list`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({
|
||||||
|
page: current,
|
||||||
|
page_size
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setDocuments(data.data)
|
setDocuments(data.data)
|
||||||
|
setTotal(data.data.total)
|
||||||
|
setCurrent(data.data.page)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed')
|
message.error(data.err_msg || 'failed')
|
||||||
@ -400,7 +452,7 @@ const Documents = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/add`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/add`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -419,18 +471,23 @@ const Documents = () => {
|
|||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddDocumentModalShow(false)
|
setIsAddDocumentModalShow(false)
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${spaceName}/document/list`,
|
`http://30.183.154.125:5000/knowledge/${spaceName}/document/list`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({
|
||||||
|
page: current,
|
||||||
|
page_size
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setDocuments(data.data)
|
setDocuments(data.data)
|
||||||
|
setTotal(data.data.total)
|
||||||
|
setCurrent(data.data.page)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed')
|
message.error(data.err_msg || 'failed')
|
||||||
|
@ -63,8 +63,8 @@ const Index = () => {
|
|||||||
const [knowledgeSpaceName, setKnowledgeSpaceName] = useState<string>('')
|
const [knowledgeSpaceName, setKnowledgeSpaceName] = useState<string>('')
|
||||||
const [webPageUrl, setWebPageUrl] = useState<string>('')
|
const [webPageUrl, setWebPageUrl] = useState<string>('')
|
||||||
const [documentName, setDocumentName] = useState<any>('')
|
const [documentName, setDocumentName] = useState<any>('')
|
||||||
const [textSource, setTextSource] = useState<string>('');
|
const [textSource, setTextSource] = useState<string>('')
|
||||||
const [text, setText] = useState<string>('');
|
const [text, setText] = useState<string>('')
|
||||||
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
||||||
const props: UploadProps = {
|
const props: UploadProps = {
|
||||||
name: 'file',
|
name: 'file',
|
||||||
@ -82,13 +82,16 @@ const Index = () => {
|
|||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
const res = await fetch('http://localhost:8000/knowledge/space/list', {
|
const res = await fetch(
|
||||||
|
'http://30.183.154.125:5000/knowledge/space/list',
|
||||||
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({})
|
||||||
})
|
}
|
||||||
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
setKnowledgeSpaceList(data.data)
|
setKnowledgeSpaceList(data.data)
|
||||||
@ -121,6 +124,7 @@ const Index = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
<div className="page-body p-4">
|
<div className="page-body p-4">
|
||||||
|
{knowledgeSpaceList.length ? (
|
||||||
<Table color="neutral" stripe="odd" variant="outlined">
|
<Table color="neutral" stripe="odd" variant="outlined">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -150,6 +154,9 @@ const Index = () => {
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Modal
|
<Modal
|
||||||
sx={{
|
sx={{
|
||||||
@ -199,7 +206,7 @@ const Index = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
'http://localhost:8000/knowledge/space/add',
|
'http://30.183.154.125:5000/knowledge/space/add',
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -218,7 +225,7 @@ const Index = () => {
|
|||||||
message.success('success')
|
message.success('success')
|
||||||
setActiveStep(1)
|
setActiveStep(1)
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
'http://localhost:8000/knowledge/space/list',
|
'http://30.183.154.125:5000/knowledge/space/list',
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -335,7 +342,7 @@ const Index = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${knowledgeSpaceName}/document/add`,
|
`http://30.183.154.125:5000/knowledge/${knowledgeSpaceName}/document/add`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -360,12 +367,12 @@ const Index = () => {
|
|||||||
message.error('Please select a file')
|
message.error('Please select a file')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const formData = new FormData();
|
const formData = new FormData()
|
||||||
formData.append('doc_name', documentName);
|
formData.append('doc_name', documentName)
|
||||||
formData.append('doc_file', originFileObj);
|
formData.append('doc_file', originFileObj)
|
||||||
formData.append('doc_type', 'DOCUMENT');
|
formData.append('doc_type', 'DOCUMENT')
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${knowledgeSpaceName}/document/upload`,
|
`http://30.183.154.125:5000/knowledge/${knowledgeSpaceName}/document/upload`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
@ -384,7 +391,7 @@ const Index = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/knowledge/${knowledgeSpaceName}/document/add`,
|
`http://30.183.154.125:5000/knowledge/${knowledgeSpaceName}/document/add`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
Reference in New Issue
Block a user