feat: add GraphRAG framework and integrate TuGraph (#1506)

Co-authored-by: KingSkyLi <15566300566@163.com>
Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
This commit is contained in:
Florian
2024-05-16 15:39:50 +08:00
committed by GitHub
parent 593e974405
commit a9087c3853
133 changed files with 10139 additions and 6631 deletions

View File

@@ -48,8 +48,8 @@ function GPTCard({
className={classNames('w-11 h-11 rounded-full mr-4 object-contain bg-white', {
'border border-gray-200': iconBorder,
})}
width={44}
height={44}
width={48}
height={48}
src={icon}
alt={title}
/>

View File

@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Button, Card, Space, Divider, Empty, Spin, Tag, Tooltip, Modal } from 'antd';
import { DeleteFilled, InteractionFilled, PlusOutlined, ToolFilled, EyeFilled, WarningOutlined } from '@ant-design/icons';
import { DeleteFilled, InteractionFilled, PlusOutlined, ToolFilled, EyeFilled, WarningOutlined, DeploymentUnitOutlined} from '@ant-design/icons';
import { apiInterceptors, delDocument, getDocumentList, syncDocument } from '@/client/api';
import { IDocument, ISpace } from '@/types/knowledge';
import moment from 'moment';
@@ -94,6 +94,9 @@ export default function DocPanel(props: IProps) {
setArgumentsShow(true);
};
const openGraphVisualPage = () => {
router.push(`/knowledge/graph/?spaceName=${space.name}`);
}
const renderResultTag = (status: string, result: string) => {
let color;
switch (status) {
@@ -210,6 +213,9 @@ export default function DocPanel(props: IProps) {
<Button size="middle" className="flex items-center mx-2" icon={<ToolFilled />} onClick={handleArguments}>
Arguments
</Button>
{
space.vector_type === 'KnowledgeGraph' && (<Button size="middle" className="flex items-center mx-2" icon={<DeploymentUnitOutlined />} onClick={openGraphVisualPage}>{t('View_Graph')}</Button>)
}
</Space>
<Divider />
<Spin spinning={isLoading}>{renderDocumentCard()}</Spin>

View File

@@ -21,7 +21,6 @@ export default function SpaceCard(props: IProps) {
const router = useRouter();
const { t } = useTranslation();
const { space, getSpaces } = props;
const showDeleteConfirm = () => {
confirm({
title: t('Tips'),
@@ -72,7 +71,7 @@ export default function SpaceCard(props: IProps) {
<GptCard
title={space.name}
desc={space.desc}
icon="/models/knowledge-default.jpg"
icon={space.vector_type === 'KnowledgeGraph'?"/models/knowledge-graph.png":"/models/knowledge-default.jpg"}
iconBorder={false}
tags={[
{

View File

@@ -1,6 +1,6 @@
import { addSpace, apiInterceptors } from '@/client/api';
import { StepChangeParams } from '@/types/knowledge';
import { Button, Form, Input, Spin } from 'antd';
import { Button, Form, Input, Spin,Select } from 'antd';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -8,6 +8,7 @@ type FieldType = {
spaceName: string;
owner: string;
description: string;
storage:string;
};
type IProps = {
@@ -20,12 +21,13 @@ export default function SpaceForm(props: IProps) {
const [spinning, setSpinning] = useState<boolean>(false);
const handleFinish = async (fieldsValue: FieldType) => {
const { spaceName, owner, description } = fieldsValue;
const { spaceName, owner, description,storage } = fieldsValue;
setSpinning(true);
let vector_type = storage
const [_, data, res] = await apiInterceptors(
addSpace({
name: spaceName,
vector_type: 'Chroma',
vector_type: vector_type,
owner,
desc: description,
}),
@@ -64,6 +66,12 @@ export default function SpaceForm(props: IProps) {
<Form.Item<FieldType> label={t('Owner')} name="owner" rules={[{ required: true, message: t('Please_input_the_owner') }]}>
<Input className="mb-5 h-12" placeholder={t('Please_input_the_owner')} />
</Form.Item>
<Form.Item<FieldType> label={t('Storage')} name="storage" rules={[{ required: true, message: t('Please_select_the_storage') }]}>
<Select className="mb-5 h-12" placeholder={t('Please_select_the_storage')}>
<Select.Option value="Chroma">Vector Store</Select.Option>
<Select.Option value="KnowledgeGraph">Knowledge Graph</Select.Option>
</Select>
</Form.Item>
<Form.Item<FieldType> label={t('Description')} name="description" rules={[{ required: true, message: t('Please_input_the_description') }]}>
<Input className="mb-5 h-12" placeholder={t('Please_input_the_description')} />
</Form.Item>