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

This commit is contained in:
aries_ckt 2023-06-30 15:45:14 +08:00
commit 877a7f8bb1
5 changed files with 85 additions and 67 deletions

View File

@ -1 +1 @@
export const fetchBaseURL = 'http://30.183.153.109:5000'; export const fetchBaseURL = 'http://30.183.154.76:5000';

View File

@ -44,8 +44,8 @@ const ChunkList = () => {
{chunkList.length ? ( {chunkList.length ? (
<> <>
<Table <Table
color="info" color="primary"
variant="soft" variant="plain"
size="lg" size="lg"
sx={{ sx={{
'& tbody tr: hover': { '& tbody tr: hover': {

View File

@ -18,7 +18,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, Pagination, message } from 'antd' import { Upload, Pagination, Popover, message } from 'antd'
import { fetchBaseURL } from '@/app/datastores/constants' import { fetchBaseURL } from '@/app/datastores/constants'
const { Dragger } = Upload const { Dragger } = Upload
@ -33,8 +33,8 @@ const Item = styled(Sheet)(({ theme }) => ({
color: theme.vars.palette.text.secondary color: theme.vars.palette.text.secondary
})) }))
const stepsOfAddingDocument = [ const stepsOfAddingDocument = [
'Choose a Datasource type', '1.Choose a Datasource type',
'Setup the Datasource' '2.Setup the Datasource'
] ]
const documentTypeList = [ const documentTypeList = [
{ {
@ -121,6 +121,7 @@ const Documents = () => {
<Button <Button
variant="outlined" variant="outlined"
onClick={() => setIsAddDocumentModalShow(true)} onClick={() => setIsAddDocumentModalShow(true)}
sx={{ marginBottom: '20px' }}
> >
+ Add Datasource + Add Datasource
</Button> </Button>
@ -128,8 +129,8 @@ const Documents = () => {
{documents.length ? ( {documents.length ? (
<> <>
<Table <Table
color="info" color="primary"
variant="soft" variant="plain"
size="lg" size="lg"
sx={{ sx={{
'& tbody tr: hover': { '& tbody tr: hover': {
@ -148,6 +149,7 @@ const Documents = () => {
<th>Size</th> <th>Size</th>
<th>Last Synch</th> <th>Last Synch</th>
<th>Status</th> <th>Status</th>
<th>Result</th>
<th>Operation</th> <th>Operation</th>
</tr> </tr>
</thead> </thead>
@ -156,11 +158,7 @@ const Documents = () => {
<tr key={row.id}> <tr key={row.id}>
<td>{row.doc_name}</td> <td>{row.doc_name}</td>
<td> <td>
<Chip <Chip variant="solid" color="neutral" sx={{ opacity: 0.5 }}>
variant="soft"
color="neutral"
sx={{ fontWeight: 300 }}
>
{row.doc_type} {row.doc_type}
</Chip> </Chip>
</td> </td>
@ -168,8 +166,8 @@ const Documents = () => {
<td>{moment(row.last_sync).format('YYYY-MM-DD HH:MM:SS')}</td> <td>{moment(row.last_sync).format('YYYY-MM-DD HH:MM:SS')}</td>
<td> <td>
<Chip <Chip
sx={{ fontWeight: 300 }} sx={{ opacity: 0.5 }}
variant="soft" variant="solid"
color={(function () { color={(function () {
switch (row.status) { switch (row.status) {
case 'TODO': case 'TODO':
@ -186,12 +184,46 @@ const Documents = () => {
{row.status} {row.status}
</Chip> </Chip>
</td> </td>
<td>
{(function () {
if (row.status === 'TODO' || row.status === 'RUNNING') {
return ''
} else if (row.status === 'FINISHED') {
return (
<Popover content={row.result} trigger="hover">
<Chip
variant="solid"
color="success"
sx={{ opacity: 0.5 }}
>
SUCCESS
</Chip>
</Popover>
)
} else {
return (
<Popover content={row.result} trigger="hover">
<Chip
variant="solid"
color="danger"
sx={{ opacity: 0.5 }}
>
FAILED
</Chip>
</Popover>
)
}
})()}
</td>
<td> <td>
{ {
<> <>
<Button <Button
variant="outlined" variant="outlined"
size="sm" size="sm"
sx={{
marginRight: '20px'
}}
onClick={async () => { onClick={async () => {
const res = await fetch( const res = await fetch(
`${fetchBaseURL}/knowledge/${spaceName}/document/sync`, `${fetchBaseURL}/knowledge/${spaceName}/document/sync`,
@ -297,7 +329,10 @@ const Documents = () => {
{stepsOfAddingDocument.map((item: any, index: number) => ( {stepsOfAddingDocument.map((item: any, index: number) => (
<Item <Item
key={item} key={item}
sx={{ fontWeight: activeStep === index ? 'bold' : '' }} sx={{
fontWeight: activeStep === index ? 'bold' : '',
color: activeStep === index ? '#814DDE' : ''
}}
> >
{item} {item}
</Item> </Item>
@ -389,6 +424,7 @@ const Documents = () => {
)} )}
</Box> </Box>
<Button <Button
variant="outlined"
onClick={async () => { onClick={async () => {
if (documentName === '') { if (documentName === '') {
message.error('Please input the name') message.error('Please input the name')

View File

@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation'
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { InboxOutlined } from '@ant-design/icons' import { InboxOutlined } from '@ant-design/icons'
import type { UploadProps } from 'antd' import type { UploadProps } from 'antd'
import { message, Upload } from 'antd' import { message, Upload, Popover } from 'antd'
import { import {
useColorScheme, useColorScheme,
Modal, Modal,
@ -34,9 +34,9 @@ const Item = styled(Sheet)(({ theme }) => ({
})) }))
const stepsOfAddingSpace = [ const stepsOfAddingSpace = [
'Knowledge Space Configuration', '1.Knowledge Space Config',
'Choose a Datasource type', '2.Choose a Datasource type',
'Setup the Datasource' '3.Setup the Datasource'
] ]
const documentTypeList = [ const documentTypeList = [
{ {
@ -128,8 +128,8 @@ const Index = () => {
<div className="page-body p-4"> <div className="page-body p-4">
{knowledgeSpaceList.length ? ( {knowledgeSpaceList.length ? (
<Table <Table
color="info" color="primary"
variant="soft" variant="plain"
size="lg" size="lg"
sx={{ sx={{
'& tbody tr: hover': { '& tbody tr: hover': {
@ -146,6 +146,7 @@ const Index = () => {
<th>Name</th> <th>Name</th>
<th>Vector</th> <th>Vector</th>
<th>Owner</th> <th>Owner</th>
<th>Description</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -165,23 +166,22 @@ const Index = () => {
} }
</td> </td>
<td> <td>
<Chip <Chip variant="solid" color="neutral" sx={{ opacity: 0.5 }}>
variant="soft"
color="neutral"
sx={{ fontWeight: 300 }}
>
{row.vector_type} {row.vector_type}
</Chip> </Chip>
</td> </td>
<td> <td>
<Chip <Chip variant="solid" color="neutral" sx={{ opacity: 0.5 }}>
variant="soft"
color="neutral"
sx={{ fontWeight: 300 }}
>
{row.owner} {row.owner}
</Chip> </Chip>
</td> </td>
<td>
<Popover content={row.desc} trigger="hover">
{row.desc.length > 10
? `${row.desc.slice(0, 10)}...`
: row.desc}
</Popover>
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
@ -214,7 +214,7 @@ const Index = () => {
{stepsOfAddingSpace.map((item: any, index: number) => ( {stepsOfAddingSpace.map((item: any, index: number) => (
<Item <Item
key={item} key={item}
sx={{ fontWeight: activeStep === index ? 'bold' : '' }} sx={{ fontWeight: activeStep === index ? 'bold' : '', color: activeStep === index ? '#814DDE' : '' }}
> >
{item} {item}
</Item> </Item>
@ -237,18 +237,21 @@ const Index = () => {
message.error('please input the name') message.error('please input the name')
return return
} }
const res = await fetch(`${fetchBaseURL}/knowledge/space/add`, { const res = await fetch(
method: 'POST', `${fetchBaseURL}/knowledge/space/add`,
headers: { {
'Content-Type': 'application/json' method: 'POST',
}, headers: {
body: JSON.stringify({ 'Content-Type': 'application/json'
name: knowledgeSpaceName, },
vector_type: 'Chroma', body: JSON.stringify({
owner: 'keting', name: knowledgeSpaceName,
desc: 'test1' vector_type: 'Chroma',
}) owner: 'keting',
}) desc: 'test1'
})
}
)
const data = await res.json() const data = await res.json()
if (data.success) { if (data.success) {
message.success('success') message.success('success')
@ -360,6 +363,7 @@ const Index = () => {
)} )}
</Box> </Box>
<Button <Button
variant='outlined'
onClick={async () => { onClick={async () => {
if (documentName === '') { if (documentName === '') {
message.error('Please input the name') message.error('Please input the name')

View File

@ -12,28 +12,6 @@ body {
background-color: var(--joy-palette-background-body); background-color: var(--joy-palette-background-body);
} }
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
text-align: left;
padding: 8px;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
body .ant-btn-primary { body .ant-btn-primary {
background-color: #1677ff; background-color: #1677ff;
} }