feat(ChatKnowledge): Support Financial Report Analysis (#1702)

Co-authored-by: hzh97 <2976151305@qq.com>
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: licunxing <864255598@qq.com>
This commit is contained in:
Aries-ckt
2024-07-26 13:40:54 +08:00
committed by GitHub
parent 22e0680a6a
commit 167d972093
160 changed files with 89339 additions and 795 deletions

View File

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

View File

@@ -1,43 +1,62 @@
import { addSpace, apiInterceptors } from '@/client/api';
import { StepChangeParams } from '@/types/knowledge';
import { Button, Form, Input, Spin,Select } from 'antd';
import { useState } from 'react';
import { IStorage, StepChangeParams } from '@/types/knowledge';
import { Button, Form, Input, Spin, Select } from 'antd';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
type FieldType = {
spaceName: string;
owner: string;
description: string;
storage:string;
storage: string;
field: string;
};
type IProps = {
handleStepChange: (params: StepChangeParams) => void;
spaceConfig: IStorage | null;
};
export default function SpaceForm(props: IProps) {
const { t } = useTranslation();
const { handleStepChange } = props;
const { handleStepChange, spaceConfig } = props;
const [spinning, setSpinning] = useState<boolean>(false);
const [storage, setStorage] = useState<string>();
const [form] = Form.useForm();
useEffect(() => {
form.setFieldValue('storage', spaceConfig?.[0].name);
setStorage(spaceConfig?.[0].name);
}, [spaceConfig]);
const handleStorageChange = (data: string) => {
setStorage(data);
};
const handleFinish = async (fieldsValue: FieldType) => {
const { spaceName, owner, description,storage } = fieldsValue;
const { spaceName, owner, description, storage, field } = fieldsValue;
setSpinning(true);
let vector_type = storage
let vector_type = storage;
let domain_type = field;
const [_, data, res] = await apiInterceptors(
addSpace({
name: spaceName,
vector_type: vector_type,
owner,
desc: description,
domain_type: domain_type,
}),
);
setSpinning(false);
res?.success && handleStepChange({ label: 'forward', spaceName });
const is_financial = domain_type === 'FinancialReport';
res?.success && handleStepChange({ label: 'forward', spaceName, pace: is_financial ? 2 : 1, docType: is_financial ? 'DOCUMENT' : '' });
};
return (
<Spin spinning={spinning}>
<Form
form={form}
size="large"
className="mt-4"
layout="vertical"
@@ -67,10 +86,19 @@ export default function SpaceForm(props: IProps) {
<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="VectorStore">Vector Store</Select.Option>
<Select.Option value="KnowledgeGraph">Knowledge Graph</Select.Option>
<Select.Option value="FullText">Full Text</Select.Option>
<Select className="mb-5 h-12" placeholder={t('Please_select_the_storage')} onChange={handleStorageChange}>
{spaceConfig?.map((item) => {
return <Select.Option value={item.name}>{item.desc}</Select.Option>;
})}
</Select>
</Form.Item>
<Form.Item<FieldType> label={t('Domain')} name="field" rules={[{ required: true, message: t('Please_select_the_domain_type') }]}>
<Select className="mb-5 h-12" placeholder={t('Please_select_the_domain_type')}>
{spaceConfig
?.find((item) => item.name === storage)
?.domain_types.map((item) => {
return <Select.Option value={item.name}>{item.desc}</Select.Option>;
})}
</Select>
</Form.Item>
<Form.Item<FieldType> label={t('Description')} name="description" rules={[{ required: true, message: t('Please_input_the_description') }]}>