feat(web): memory management add scene
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||||
import { Form, Input, App } from 'antd';
|
import { Form, Input, App } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import type { MemoryFormData, Memory, MemoryFormRef } from '../types';
|
import type { MemoryFormData, Memory, MemoryFormRef } from '../types';
|
||||||
import RbModal from '@/components/RbModal'
|
import RbModal from '@/components/RbModal'
|
||||||
import { createMemoryConfig, updateMemoryConfig } from '@/api/memory'
|
import { createMemoryConfig, updateMemoryConfig } from '@/api/memory'
|
||||||
|
import { getOntologyScenesUrl } from '@/api/ontology'
|
||||||
|
import CustomSelect from '@/components/CustomSelect';
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
@@ -38,6 +41,7 @@ const MemoryForm = forwardRef<MemoryFormRef, MemoryFormProps>(({
|
|||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
config_name: memory.config_name,
|
config_name: memory.config_name,
|
||||||
config_desc: memory.config_desc,
|
config_desc: memory.config_desc,
|
||||||
|
scene_id: memory.scene_id
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
@@ -102,6 +106,21 @@ const MemoryForm = forwardRef<MemoryFormRef, MemoryFormProps>(({
|
|||||||
>
|
>
|
||||||
<Input.TextArea placeholder={t('common.pleaseEnter')} />
|
<Input.TextArea placeholder={t('common.pleaseEnter')} />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
name="scene_id"
|
||||||
|
label={t('memory.scene_id')}
|
||||||
|
rules={[{ required: true, message: t('common.pleaseSelect') }]}
|
||||||
|
>
|
||||||
|
<CustomSelect
|
||||||
|
placeholder={t('common.pleaseSelect')}
|
||||||
|
url={getOntologyScenesUrl}
|
||||||
|
params={{ pagesize: 100, page: 1 }}
|
||||||
|
hasAll={false}
|
||||||
|
valueKey='scene_id'
|
||||||
|
labelKey="scene_name"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</RbModal>
|
</RbModal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { getMemoryConfigList, deleteMemoryConfig } from '@/api/memory'
|
|||||||
import BodyWrapper from '@/components/Empty/BodyWrapper'
|
import BodyWrapper from '@/components/Empty/BodyWrapper'
|
||||||
import { formatDateTime } from '@/utils/format';
|
import { formatDateTime } from '@/utils/format';
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
|
import RbAlert from '@/components/RbAlert'
|
||||||
|
|
||||||
const MemoryManagement: React.FC = () => {
|
const MemoryManagement: React.FC = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -98,10 +99,18 @@ const MemoryManagement: React.FC = () => {
|
|||||||
<Tooltip title={item.config_desc}>
|
<Tooltip title={item.config_desc}>
|
||||||
<div className="rb:text-[#5B6167] rb:text-[12px] rb:leading-4.25 rb:font-regular rb:-mt-1 rb:wrap-break-word rb:line-clamp-1">{item.config_desc}</div>
|
<div className="rb:text-[#5B6167] rb:text-[12px] rb:leading-4.25 rb:font-regular rb:-mt-1 rb:wrap-break-word rb:line-clamp-1">{item.config_desc}</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
<RbAlert className="rb:mt-3 ">
|
||||||
|
<div className={clsx("rb:flex rb:gap-5 rb:font-regular rb:text-[14px]")}>
|
||||||
|
<span className="rb:text-[#5B6167]">{t('memory.scene_id')}: </span>
|
||||||
|
<span className="rb:font-medium">
|
||||||
|
{item.scene_name || '-'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</RbAlert>
|
||||||
|
|
||||||
<div className="rb:grid rb:grid-cols-2 rb:gap-4 rb:mt-3">
|
<div className="rb:grid rb:grid-cols-2 rb:gap-x-4 rb:gap-y-3 rb:mt-3">
|
||||||
{['memoryExtractionEngine', 'forgottenEngine', 'emotionEngine', 'reflectionEngine'].map((key) => (
|
{['memoryExtractionEngine', 'forgottenEngine', 'emotionEngine', 'reflectionEngine'].map((key) => (
|
||||||
<div key={key} className="rb:group rb:cursor-pointer rb:bg-[#F0F3F8] rb:h-10 rb:rounded-md rb:flex rb:items-center rb:justify-between rb:p-[0_8px_0_12px] rb:mt-3 rb:text-[#5B6167] rb:font-medium"
|
<div key={key} className="rb:group rb:cursor-pointer rb:bg-[#F0F3F8] rb:h-10 rb:rounded-md rb:flex rb:items-center rb:justify-between rb:p-[0_8px_0_12px] rb:text-[#5B6167] rb:font-medium"
|
||||||
onClick={() => handleClick(item.config_id, key)}
|
onClick={() => handleClick(item.config_id, key)}
|
||||||
>
|
>
|
||||||
{t(`memory.${key}`)}
|
{t(`memory.${key}`)}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export interface MemoryFormData {
|
|||||||
config_id?: number;
|
config_id?: number;
|
||||||
config_name: string;
|
config_name: string;
|
||||||
config_desc?: string;
|
config_desc?: string;
|
||||||
|
scene_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内存数据类型
|
// 内存数据类型
|
||||||
@@ -30,6 +31,8 @@ export interface Memory {
|
|||||||
updated_at: string;
|
updated_at: string;
|
||||||
config_desc: string;
|
config_desc: string;
|
||||||
workspace_id: string;
|
workspace_id: string;
|
||||||
|
scene_id: string;
|
||||||
|
scene_name: string;
|
||||||
[key: string]: string | number | boolean;
|
[key: string]: string | number | boolean;
|
||||||
}
|
}
|
||||||
// 定义组件暴露的方法接口
|
// 定义组件暴露的方法接口
|
||||||
|
|||||||
Reference in New Issue
Block a user