diff --git a/datacenter/app/datastores/documents/chunklist/page.tsx b/datacenter/app/datastores/documents/chunklist/page.tsx index ca17030e9..eb68e9296 100644 --- a/datacenter/app/datastores/documents/chunklist/page.tsx +++ b/datacenter/app/datastores/documents/chunklist/page.tsx @@ -2,73 +2,119 @@ import { useSearchParams } from 'next/navigation' import React, { useState, useEffect } from 'react' -import { Table } from '@/lib/mui' -import { Popover } from 'antd' +import { Table, Stack } from '@/lib/mui' +import { Popover, Pagination } from 'antd' +const page_size = 20 const ChunkList = () => { const spaceName = useSearchParams().get('spacename') const documentId = useSearchParams().get('documentid') + const [total, setTotal] = useState(0) + const [current, setCurrent] = useState(0) const [chunkList, setChunkList] = useState([]) useEffect(() => { async function fetchChunks() { const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/chunk/list`, + `http://30.183.154.125:5000/knowledge/${spaceName}/chunk/list`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - document_id: documentId + document_id: documentId, + page: 1, + page_size }) } ) const data = await res.json() if (data.success) { - setChunkList(data.data) + setChunkList(data.data.data) + setTotal(data.data.total) + setCurrent(data.data.page) } } fetchChunks() }, []) return (
- - - - - - - - - - {chunkList.map((row: any) => ( - - - - - - ))} - -
NameContentMeta Data
{row.doc_name} - { - - {row.content.length > 10 - ? `${row.content.slice(0, 10)}...` - : row.content} - + {chunkList.length ? ( + <> + + + + + + + + + + {chunkList.map((row: any) => ( + + + + + + ))} + +
NameContentMeta Data
{row.doc_name} + { + + {row.content.length > 10 + ? `${row.content.slice(0, 10)}...` + : row.content} + + } + + { + + {row.meta_info.length > 10 + ? `${row.meta_info.slice(0, 10)}...` + : row.meta_info} + + } +
+ + { + const res = await fetch( + `http://30.183.154.125:5000/knowledge/${spaceName}/chunk/list`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + document_id: documentId, + page, + page_size + }) + } + ) + const data = await res.json() + if (data.success) { + setChunkList(data.data.data) + setTotal(data.data.total) + setCurrent(data.data.page) } -
- { - - {row.meta_info.length > 10 - ? `${row.meta_info.slice(0, 10)}...` - : row.meta_info} - - } -
+ }} + hideOnSinglePage + /> + + + ) : ( + <> + )}
) } diff --git a/datacenter/app/datastores/documents/page.tsx b/datacenter/app/datastores/documents/page.tsx index e5c8575dd..8cb482b34 100644 --- a/datacenter/app/datastores/documents/page.tsx +++ b/datacenter/app/datastores/documents/page.tsx @@ -17,7 +17,7 @@ import { import moment from 'moment' import { InboxOutlined } from '@ant-design/icons' import type { UploadProps } from 'antd' -import { Upload, message } from 'antd' +import { Upload, Pagination, message } from 'antd' const { Dragger } = Upload const Item = styled(Sheet)(({ theme }) => ({ @@ -38,19 +38,20 @@ const documentTypeList = [ { type: 'text', title: 'Text', - subTitle: 'Paste some text' + subTitle: 'Fill your raw text' }, { type: 'webPage', - title: 'Web Page', - subTitle: 'Crawl text from a web page' + title: 'URL', + subTitle: 'Fetch the content of a URL' }, { type: 'file', - title: 'File', - subTitle: 'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel' + title: 'Document', + subTitle: 'Upload a document, document type can be PDF, CSV, Text, PowerPoint, Word, Markdown' } ] +const page_size = 20; const Documents = () => { const router = useRouter() @@ -62,9 +63,11 @@ const Documents = () => { const [documents, setDocuments] = useState([]) const [webPageUrl, setWebPageUrl] = useState('') const [documentName, setDocumentName] = useState('') - const [textSource, setTextSource] = useState(''); - const [text, setText] = useState(''); + const [textSource, setTextSource] = useState('') + const [text, setText] = useState('') const [originFileObj, setOriginFileObj] = useState(null) + const [total, setTotal] = useState(0) + const [current, setCurrent] = useState(0) const props: UploadProps = { name: 'file', multiple: false, @@ -82,18 +85,23 @@ const Documents = () => { useEffect(() => { async function fetchDocuments() { const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/list`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/list`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({}) + body: JSON.stringify({ + page: 1, + page_size + }) } ) const data = await res.json() if (data.success) { - setDocuments(data.data) + setDocuments(data.data.data) + setTotal(data.data.total) + setCurrent(data.data.page) } } fetchDocuments() @@ -113,89 +121,127 @@ const Documents = () => { + Add Datasource - - - - - - - - - - - - - {documents.map((row: any) => ( - - - - - - - - - ))} - -
NameTypeSizeLast SynchStatusOperation
{row.doc_name}{row.doc_type}{row.chunk_size}{moment(row.last_sync).format('YYYY-MM-DD HH:MM:SS')} - - {row.status} - - - { - <> -
+ }} + hideOnSinglePage + /> + + + ) : ( + <> + )} { return } const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/add`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/add`, { method: 'POST', headers: { @@ -341,18 +387,23 @@ const Documents = () => { message.success('success') setIsAddDocumentModalShow(false) const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/list`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/list`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({}) + body: JSON.stringify({ + page: current, + page_size + }) } ) const data = await res.json() if (data.success) { setDocuments(data.data) + setTotal(data.data.total) + setCurrent(data.data.page) } } else { message.error(data.err_msg || 'failed') @@ -362,12 +413,12 @@ const Documents = () => { message.error('Please select a file') return } - const formData = new FormData(); - formData.append('doc_name', documentName); - formData.append('doc_file', originFileObj); - formData.append('doc_type', 'DOCUMENT'); + const formData = new FormData() + formData.append('doc_name', documentName) + formData.append('doc_file', originFileObj) + formData.append('doc_type', 'DOCUMENT') const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/upload`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/upload`, { method: 'POST', body: formData @@ -378,18 +429,23 @@ const Documents = () => { message.success('success') setIsAddDocumentModalShow(false) const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/list`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/list`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({}) + body: JSON.stringify({ + page: current, + page_size + }) } ) const data = await res.json() if (data.success) { setDocuments(data.data) + setTotal(data.data.total) + setCurrent(data.data.page) } } else { message.error(data.err_msg || 'failed') @@ -400,7 +456,7 @@ const Documents = () => { return } const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/add`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/add`, { method: 'POST', headers: { @@ -419,18 +475,23 @@ const Documents = () => { message.success('success') setIsAddDocumentModalShow(false) const res = await fetch( - `http://localhost:8000/knowledge/${spaceName}/document/list`, + `http://30.183.154.125:5000/knowledge/${spaceName}/document/list`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({}) + body: JSON.stringify({ + page: current, + page_size + }) } ) const data = await res.json() if (data.success) { setDocuments(data.data) + setTotal(data.data.total) + setCurrent(data.data.page) } } else { message.error(data.err_msg || 'failed') diff --git a/datacenter/app/datastores/page.tsx b/datacenter/app/datastores/page.tsx index f99e138f8..17d655a97 100644 --- a/datacenter/app/datastores/page.tsx +++ b/datacenter/app/datastores/page.tsx @@ -39,17 +39,17 @@ const documentTypeList = [ { type: 'text', title: 'Text', - subTitle: 'Paste some text' + subTitle: 'Fill your raw text' }, { type: 'webPage', - title: 'Web Page', - subTitle: 'Crawl text from a web page' + title: 'URL', + subTitle: 'Fetch the content of a URL' }, { type: 'file', - title: 'File', - subTitle: 'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel' + title: 'Document', + subTitle: 'Upload a document, document type can be PDF, CSV, Text, PowerPoint, Word, Markdown' } ] @@ -63,8 +63,8 @@ const Index = () => { const [knowledgeSpaceName, setKnowledgeSpaceName] = useState('') const [webPageUrl, setWebPageUrl] = useState('') const [documentName, setDocumentName] = useState('') - const [textSource, setTextSource] = useState(''); - const [text, setText] = useState(''); + const [textSource, setTextSource] = useState('') + const [text, setText] = useState('') const [originFileObj, setOriginFileObj] = useState(null) const props: UploadProps = { name: 'file', @@ -82,13 +82,16 @@ const Index = () => { } useEffect(() => { async function fetchData() { - const res = await fetch('http://localhost:8000/knowledge/space/list', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({}) - }) + const res = await fetch( + 'http://30.183.154.125:5000/knowledge/space/list', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({}) + } + ) const data = await res.json() if (data.success) { setKnowledgeSpaceList(data.data) @@ -121,35 +124,39 @@ const Index = () => {
- - - - - - - - - - {knowledgeSpaceList.map((row: any) => ( - - - - + {knowledgeSpaceList.length ? ( +
NameProviderOwner
- { - - router.push(`/datastores/documents?name=${row.name}`) - } - > - {row.name} - - } - {row.vector_type}{row.owner}
+ + + + + - ))} - -
NameProviderOwner
+ + + {knowledgeSpaceList.map((row: any) => ( + + + { + + router.push(`/datastores/documents?name=${row.name}`) + } + > + {row.name} + + } + + {row.vector_type} + {row.owner} + + ))} + + + ) : ( + <> + )}
{ return } const res = await fetch( - 'http://localhost:8000/knowledge/space/add', + 'http://30.183.154.125:5000/knowledge/space/add', { method: 'POST', headers: { @@ -218,7 +225,7 @@ const Index = () => { message.success('success') setActiveStep(1) const res = await fetch( - 'http://localhost:8000/knowledge/space/list', + 'http://30.183.154.125:5000/knowledge/space/list', { method: 'POST', headers: { @@ -335,7 +342,7 @@ const Index = () => { return } const res = await fetch( - `http://localhost:8000/knowledge/${knowledgeSpaceName}/document/add`, + `http://30.183.154.125:5000/knowledge/${knowledgeSpaceName}/document/add`, { method: 'POST', headers: { @@ -360,12 +367,12 @@ const Index = () => { message.error('Please select a file') return } - const formData = new FormData(); - formData.append('doc_name', documentName); - formData.append('doc_file', originFileObj); - formData.append('doc_type', 'DOCUMENT'); + const formData = new FormData() + formData.append('doc_name', documentName) + formData.append('doc_file', originFileObj) + formData.append('doc_type', 'DOCUMENT') const res = await fetch( - `http://localhost:8000/knowledge/${knowledgeSpaceName}/document/upload`, + `http://30.183.154.125:5000/knowledge/${knowledgeSpaceName}/document/upload`, { method: 'POST', body: formData @@ -384,7 +391,7 @@ const Index = () => { return } const res = await fetch( - `http://localhost:8000/knowledge/${knowledgeSpaceName}/document/add`, + `http://30.183.154.125:5000/knowledge/${knowledgeSpaceName}/document/add`, { method: 'POST', headers: { diff --git a/datacenter/app/globals.css b/datacenter/app/globals.css index 04a5d0afa..ae7bc662f 100644 --- a/datacenter/app/globals.css +++ b/datacenter/app/globals.css @@ -10,4 +10,21 @@ body { font-size: var(--joy-fontSize-md, 1rem); line-height: var(--joy-lineHeight-md, 1.5); background-color: var(--joy-palette-background-body); +} + +.ant-pagination .ant-pagination-prev * { + color: rgb(145, 35, 167) !important; +} + +.ant-pagination .ant-pagination-next * { + color: rgb(145, 35, 167) !important; +} + +.ant-pagination .ant-pagination-item { + border-color: rgb(145, 35, 167) !important; + background-color: rgb(145, 35, 167) !important; +} + +.ant-pagination .ant-pagination-item.ant-pagination-item-active a { + color: white !important; } \ No newline at end of file diff --git a/datacenter/components/leftSider.tsx b/datacenter/components/leftSider.tsx index c534dbb17..c04463466 100644 --- a/datacenter/components/leftSider.tsx +++ b/datacenter/components/leftSider.tsx @@ -4,8 +4,7 @@ import { usePathname, useSearchParams } from 'next/navigation'; import Link from 'next/link'; import Image from 'next/image'; import { Box, List, ListItem, ListItemButton, ListItemDecorator, ListItemContent, Typography, Button, useColorScheme } from '@/lib/mui'; -import SmartToyRoundedIcon from '@mui/icons-material/SmartToyRounded'; // Icons import -import StorageRoundedIcon from '@mui/icons-material/StorageRounded'; +import Article from '@mui/icons-material/Article'; import DarkModeIcon from '@mui/icons-material/DarkMode'; import WbSunnyIcon from '@mui/icons-material/WbSunny'; import MenuIcon from '@mui/icons-material/Menu'; @@ -19,14 +18,9 @@ const LeftSider = () => { const menus = useMemo(() => { return [{ - label: 'Agents', - icon: , - route: '/agents', - active: pathname === '/agents', - }, { - label: 'Datastores', + label: 'Knowledge Space', route: '/datastores', - icon: , + icon:
, active: pathname === '/datastores' }]; }, [pathname]); @@ -75,13 +69,6 @@ const LeftSider = () => { }} >
- Databerry DB-GPT diff --git a/datacenter/public/databerry-logo-icon.png b/datacenter/public/databerry-logo-icon.png deleted file mode 100644 index 9ee985d5b..000000000 Binary files a/datacenter/public/databerry-logo-icon.png and /dev/null differ