mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-15 23:13:15 +00:00
Merge remote-tracking branch 'origin/new-page-framework' into llm_framework
This commit is contained in:
commit
e9d70b8f90
@ -13,23 +13,48 @@ import {
|
|||||||
ProFormTextArea,
|
ProFormTextArea,
|
||||||
StepsForm
|
StepsForm
|
||||||
} from '@ant-design/pro-components'
|
} from '@ant-design/pro-components'
|
||||||
import { Button, Modal, message } from 'antd'
|
import { Button, Modal, Table, message } from 'antd'
|
||||||
|
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
const formRef = useRef<ProFormInstance>();
|
const formRef = useRef<ProFormInstance>();
|
||||||
|
const [knowledgeSpaceList, setKnowledgeSpaceList] = useState<any>([]);
|
||||||
const [isAddKnowledgeSpaceModalShow, setIsAddKnowledgeSpaceModalShow] =
|
const [isAddKnowledgeSpaceModalShow, setIsAddKnowledgeSpaceModalShow] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
const [knowledgeSpaceName, setKnowledgeSpaceName] = useState<string>('');
|
const [knowledgeSpaceName, setKnowledgeSpaceName] = useState<string>('');
|
||||||
const [webUrlName, setWebUrlName] = useState<string>('');
|
|
||||||
const [webPageUrl, setWebPageUrl] = useState<string>('');
|
const [webPageUrl, setWebPageUrl] = useState<string>('');
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="header">
|
<div className="page-header p-4">
|
||||||
<div>Knowledge Spaces</div>
|
<div className="page-header-title">Knowledge Spaces</div>
|
||||||
<Button onClick={() => setIsAddKnowledgeSpaceModalShow(true)} type='default'>
|
<Button onClick={() => setIsAddKnowledgeSpaceModalShow(true)} type='default'>
|
||||||
+ New Knowledge Space
|
+ New Knowledge Space
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="page-body p-4">
|
||||||
|
<Table
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: 'Name',
|
||||||
|
dataIndex: 'name',
|
||||||
|
key: 'name',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Provider',
|
||||||
|
dataIndex: 'vector_type',
|
||||||
|
key: 'vector_type',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Owner',
|
||||||
|
dataIndex: 'owner',
|
||||||
|
key: 'owner',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
dataSource={knowledgeSpaceList}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<Modal
|
<Modal
|
||||||
title="Add Knowledge Space"
|
title="Add Knowledge Space"
|
||||||
footer={null}
|
footer={null}
|
||||||
@ -76,6 +101,17 @@ const Index = () => {
|
|||||||
if (data.success) {
|
if (data.success) {
|
||||||
props.onSubmit?.();
|
props.onSubmit?.();
|
||||||
message.success('success');
|
message.success('success');
|
||||||
|
const res = await fetch('http://localhost:8000/knowledge/space/list', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({}),
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.success) {
|
||||||
|
setKnowledgeSpaceList(data.data);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed');
|
message.error(data.err_msg || 'failed');
|
||||||
}
|
}
|
||||||
@ -107,8 +143,8 @@ const Index = () => {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
doc_name: webUrlName,
|
doc_name: webPageUrl,
|
||||||
doc_type: webPageUrl
|
doc_type: 'URL'
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@ -160,14 +196,6 @@ const Index = () => {
|
|||||||
name="time"
|
name="time"
|
||||||
title="Setup the Datasource"
|
title="Setup the Datasource"
|
||||||
>
|
>
|
||||||
<ProFormText
|
|
||||||
name="webUrlName"
|
|
||||||
label="Name"
|
|
||||||
width="lg"
|
|
||||||
placeholder="Please input the name"
|
|
||||||
rules={[{ required: true }]}
|
|
||||||
onChange={(e: any) => setWebUrlName(e.target.value)}
|
|
||||||
/>
|
|
||||||
<ProFormText
|
<ProFormText
|
||||||
name="webPageUrl"
|
name="webPageUrl"
|
||||||
label="Web Page URL"
|
label="Web Page URL"
|
||||||
@ -181,9 +209,13 @@ const Index = () => {
|
|||||||
</ProCard>
|
</ProCard>
|
||||||
</Modal>
|
</Modal>
|
||||||
<style jsx>{`
|
<style jsx>{`
|
||||||
.header {
|
.page-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
.page-header-title {
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.datasource-type-wrap {
|
.datasource-type-wrap {
|
||||||
height: 100px;
|
height: 100px;
|
||||||
|
Loading…
Reference in New Issue
Block a user