Merge remote-tracking branch 'origin/new-page-framework' into llm_framework

This commit is contained in:
aries_ckt 2023-06-26 17:39:43 +08:00
commit 8fcf994f52
5 changed files with 163 additions and 2 deletions

View 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);

View File

@ -0,0 +1,82 @@
"use client";
import Router from 'next/router'
import { withRouter } from 'next/router'
import React, { useState, useEffect } from 'react';
import { Table, Button } from 'antd';
import moment from 'moment';
const Documents = ({ router }) => {
const [documents, setDocuments] = useState<any>([]);
useEffect(() => {
async function fetchDocuments() {
const res = await fetch(`http://localhost:8000/knowledge/${router.query.name}/document/list`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
const data = await res.json();
if (data.success) {
setDocuments(data.data);
}
}
fetchDocuments();
}, []);
return (
<div className='p-4'>
<Table
columns={[
{
title: 'Name',
dataIndex: 'doc_name',
key: 'doc_name',
align: 'center',
},
{
title: 'Type',
dataIndex: 'doc_type',
key: 'doc_type',
align: 'center',
},
{
title: 'Size',
dataIndex: 'chunk_size',
key: 'chunk_size',
align: 'center',
},
{
title: 'Last Synch',
dataIndex: 'last_sync',
key: 'last_sync',
align: 'center',
render: (text: string) => moment(text).format('YYYY-MM-DD HH:MM:SS')
},
{
title: 'Status',
dataIndex: 'status',
key: 'status',
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}
/>
</div>
)
}
export default withRouter(Documents);

View File

@ -1,5 +1,6 @@
'use client'
import Router from 'next/router'
import type { ProFormInstance } from '@ant-design/pro-components';
import React, { useState, useRef, useEffect } from 'react'
import {
@ -55,7 +56,7 @@ const Index = () => {
key: 'name',
align: 'center',
render: (text: string) => {
return <a href='javascript:;'>{text}</a>
return <a href='javascript:;' onClick={() => Router.push(`/datastores/documents?name=${text}`)}>{text}</a>
}
},
{
@ -103,7 +104,6 @@ const Index = () => {
if (knowledgeSpaceName === '') {
props.onSubmit?.()
} else {
props.onSubmit?.();
const res = await fetch('http://localhost:8000/knowledge/space/add', {
method: 'POST',
headers: {

View File

@ -30,6 +30,7 @@
"cuid": "^3.0.0",
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"moment": "^2.29.4",
"next": "13.4.7",
"next-auth": "^4.20.1",
"postcss": "8.4.24",
@ -5487,6 +5488,14 @@
"resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
},
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
"engines": {
"node": "*"
}
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",
@ -12413,6 +12422,11 @@
"resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
},
"moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
},
"mri": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",

View File

@ -31,6 +31,7 @@
"cuid": "^3.0.0",
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"moment": "^2.29.4",
"next": "13.4.7",
"next-auth": "^4.20.1",
"postcss": "8.4.24",