mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-12 05:32:32 +00:00
feat: fetch chunk list
This commit is contained in:
parent
85272f5d34
commit
b75d901895
64
datacenter/app/datastores/documents/chunklist/page.tsx
Normal file
64
datacenter/app/datastores/documents/chunklist/page.tsx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Router from 'next/router'
|
||||||
|
import { withRouter } from 'next/router'
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Table, Popover } from 'antd';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
const ChunkList = ({ router }) => {
|
||||||
|
const [chunkList, setChunkList] = useState<any>([]);
|
||||||
|
useEffect(() => {
|
||||||
|
async function fetchChunks() {
|
||||||
|
const res = await fetch(`http://localhost:8000/knowledge/${router.query.spacename}/chunk/list`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
document_id: router.query.documentid
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.success) {
|
||||||
|
setChunkList(data.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchChunks();
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<div className='p-4'>
|
||||||
|
<Table
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: 'Name',
|
||||||
|
dataIndex: 'doc_name',
|
||||||
|
key: 'doc_name',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Content',
|
||||||
|
dataIndex: 'content',
|
||||||
|
key: 'content',
|
||||||
|
align: 'center',
|
||||||
|
render: (text: string, label: any) => {
|
||||||
|
return <Popover content={text} trigger="hover">{text.length < 10 ? `${text.slice(0, 10)}...` : text}</Popover>;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Meta Data',
|
||||||
|
dataIndex: 'meta_info',
|
||||||
|
key: 'meta_info',
|
||||||
|
align: 'center',
|
||||||
|
render: (text: string, label: any) => {
|
||||||
|
return <Popover content={JSON.stringify(text || '{}', null, 2)} trigger="hover">{text.length < 10 ? `${text.slice(0, 10)}...` : text}</Popover>;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
dataSource={chunkList}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(ChunkList);
|
@ -1,8 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import Router from 'next/router'
|
||||||
import { withRouter } from 'next/router'
|
import { withRouter } from 'next/router'
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Table } from 'antd';
|
import { Table, Button } from 'antd';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
const Documents = ({ router }) => {
|
const Documents = ({ router }) => {
|
||||||
@ -58,6 +59,19 @@ const Documents = ({ router }) => {
|
|||||||
key: 'status',
|
key: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Operation',
|
||||||
|
dataIndex: 'operation',
|
||||||
|
key: 'operation',
|
||||||
|
align: 'center',
|
||||||
|
render: (_: any, label: any) => {
|
||||||
|
return (
|
||||||
|
<Button onClick={() => {
|
||||||
|
Router.push(`/datastores/documents/chunklist?spacename=${router.query.name}&documentid=${label.id}`)
|
||||||
|
}}>Detail of Chunks</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
dataSource={documents}
|
dataSource={documents}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user