mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 17:16:52 +08:00
Fix: Memory-related bug fixes (#12238)
### What problem does this PR solve? Fix: Memory-related bug fixes - Forget memory button text - Adjust memory storage interface ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -91,13 +91,13 @@ export function ConfirmDeleteDialog({
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter className="px-5 flex items-center gap-2">
|
||||
<AlertDialogCancel onClick={onCancel}>
|
||||
{okButtonText || t('common.cancel')}
|
||||
{cancelButtonText || t('common.cancel')}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-state-error text-text-primary hover:text-text-primary hover:bg-state-error"
|
||||
onClick={onOk}
|
||||
>
|
||||
{cancelButtonText || t('common.delete')}
|
||||
{okButtonText || t('common.delete')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
|
||||
@ -112,6 +112,10 @@ export default {
|
||||
Semantic Memory: General knowledge and facts about the user and world.
|
||||
Episodic Memory: Time-stamped records of specific events and experiences.
|
||||
Procedural Memory: Learned skills, habits, and automated procedures.`,
|
||||
raw: 'raw',
|
||||
semantic: 'semantic',
|
||||
episodic: 'episodic',
|
||||
procedural: 'procedural',
|
||||
editName: 'Edit name',
|
||||
memory: 'Memory',
|
||||
createMemory: 'Create memory',
|
||||
|
||||
@ -99,11 +99,15 @@ export default {
|
||||
llmTooltip: '分析对话内容,提取关键信息,并生成结构化的记忆摘要。',
|
||||
embeddingModelTooltip:
|
||||
'将文本转换为数值向量,用于语义相似度搜索和记忆检索。',
|
||||
embeddingModelError: '记忆类型为必填项,且"原始"类型不可删除。',
|
||||
embeddingModelError: '记忆类型为必填项,且"row"类型不可删除。',
|
||||
memoryTypeTooltip: `原始: 用户与代理之间的原始对话内容(默认必需)。
|
||||
语义记忆: 关于用户和世界的通用知识和事实。
|
||||
情景记忆: 带时间戳的特定事件和经历记录。
|
||||
程序记忆: 学习的技能、习惯和自动化程序。`,
|
||||
raw: '原始',
|
||||
semantic: '语义',
|
||||
episodic: '情景',
|
||||
procedural: '程序',
|
||||
editName: '编辑名称',
|
||||
memory: '记忆',
|
||||
createMemory: '创建记忆',
|
||||
|
||||
@ -10,6 +10,12 @@ export enum MemoryType {
|
||||
Episodic = 'episodic',
|
||||
Procedural = 'procedural',
|
||||
}
|
||||
export const MemoryOptions = (t: TFunction) => [
|
||||
{ label: t('memories.raw'), value: MemoryType.Raw },
|
||||
{ label: t('memories.semantic'), value: MemoryType.Semantic },
|
||||
{ label: t('memories.episodic'), value: MemoryType.Episodic },
|
||||
{ label: t('memories.procedural'), value: MemoryType.Procedural },
|
||||
];
|
||||
export const createMemoryFields = (t: TFunction) =>
|
||||
[
|
||||
{
|
||||
@ -24,12 +30,7 @@ export const createMemoryFields = (t: TFunction) =>
|
||||
type: FormFieldType.MultiSelect,
|
||||
placeholder: t('memories.descriptionPlaceholder'),
|
||||
tooltip: t('memories.memoryTypeTooltip'),
|
||||
options: [
|
||||
{ label: 'Raw', value: MemoryType.Raw },
|
||||
{ label: 'Semantic', value: MemoryType.Semantic },
|
||||
{ label: 'Episodic', value: MemoryType.Episodic },
|
||||
{ label: 'Procedural', value: MemoryType.Procedural },
|
||||
],
|
||||
options: MemoryOptions(t),
|
||||
required: true,
|
||||
customValidate: (value) => {
|
||||
if (!value.includes(MemoryType.Raw) || !value.length) {
|
||||
|
||||
@ -251,6 +251,7 @@ export function MemoryTable({
|
||||
title={t('memory.messages.forgetMessage')}
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
okButtonText={t('common.confirm')}
|
||||
content={{
|
||||
title: t('memory.messages.forgetMessageTip'),
|
||||
node: (
|
||||
|
||||
@ -95,7 +95,7 @@ export const AdvancedSettingsForm = () => {
|
||||
// placeholder: t('memory.config.storageTypePlaceholder'),
|
||||
options: [
|
||||
// { label: 'LRU', value: 'LRU' },
|
||||
{ label: 'FIFO', value: 'FIFO' },
|
||||
{ label: 'FIFO', value: 'fifo' },
|
||||
],
|
||||
required: false,
|
||||
}}
|
||||
|
||||
@ -15,9 +15,9 @@ export const useUpdateMemoryConfig = () => {
|
||||
try {
|
||||
const params = omit(data, [
|
||||
'id',
|
||||
'memory_type',
|
||||
'embd_id',
|
||||
'storage_type',
|
||||
// 'memory_type',
|
||||
// 'embd_id',
|
||||
// 'storage_type',
|
||||
]);
|
||||
res = await updateMemory({
|
||||
// ...memoryDataTemp,
|
||||
|
||||
@ -6,9 +6,9 @@ import { MainContainer } from '@/pages/dataset/dataset-setting/configuration-for
|
||||
import { TopTitle } from '@/pages/dataset/dataset-title';
|
||||
import { IMemory } from '@/pages/memories/interface';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { t } from 'i18next';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { z } from 'zod';
|
||||
import { useFetchMemoryBaseConfiguration } from '../hooks/use-memory-setting';
|
||||
import {
|
||||
@ -24,14 +24,15 @@ import {
|
||||
memoryModelFormSchema,
|
||||
} from './memory-model-form';
|
||||
|
||||
const MemoryMessageSchema = z.object({
|
||||
id: z.string(),
|
||||
...basicInfoSchema,
|
||||
...memoryModelFormSchema,
|
||||
...advancedSettingsFormSchema,
|
||||
});
|
||||
// type MemoryMessageForm = z.infer<typeof MemoryMessageSchema>;
|
||||
export default function MemoryMessage() {
|
||||
const { t } = useTranslation();
|
||||
const MemoryMessageSchema = z.object({
|
||||
id: z.string(),
|
||||
...basicInfoSchema,
|
||||
...memoryModelFormSchema(t),
|
||||
...advancedSettingsFormSchema,
|
||||
});
|
||||
const form = useForm<IMemory>({
|
||||
resolver: zodResolver(MemoryMessageSchema),
|
||||
defaultValues: {
|
||||
@ -58,11 +59,12 @@ export default function MemoryMessage() {
|
||||
system_prompt: data?.system_prompt || '',
|
||||
user_prompt: data?.user_prompt || '',
|
||||
forgetting_policy: data?.forgetting_policy || 'FIFO',
|
||||
storage_type: data?.storage_type || 'table',
|
||||
storage_type: data?.storage_type || 'Table',
|
||||
permissions: data?.permissions || 'me',
|
||||
});
|
||||
}, [data, form]);
|
||||
const onSubmit = (data: IMemory) => {
|
||||
console.log('data', data);
|
||||
onMemoryRenameOk(data);
|
||||
};
|
||||
return (
|
||||
|
||||
@ -1,21 +1,30 @@
|
||||
import { FormFieldType, RenderField } from '@/components/dynamic-form';
|
||||
import { useModelOptions } from '@/components/llm-setting-items/llm-form-field';
|
||||
import { EmbeddingSelect } from '@/pages/dataset/dataset-setting/configuration/common-item';
|
||||
import { MemoryType } from '@/pages/memories/constants';
|
||||
import { MemoryOptions, MemoryType } from '@/pages/memories/constants';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { z } from 'zod';
|
||||
import { useFetchMemoryMessageList } from '../memory-message/hook';
|
||||
|
||||
export const memoryModelFormSchema = {
|
||||
export const memoryModelFormSchema = (t: TFunction) => ({
|
||||
embd_id: z.string(),
|
||||
llm_id: z.string(),
|
||||
memory_type: z.array(z.string()).optional(),
|
||||
memory_type: z.array(z.string()).superRefine((data, ctx) => {
|
||||
if (!data.includes(MemoryType.Raw) || !data.length) {
|
||||
ctx.addIssue({
|
||||
// path: ['memory_type'],
|
||||
message: t('memories.embeddingModelError'),
|
||||
code: 'custom',
|
||||
});
|
||||
}
|
||||
}),
|
||||
memory_size: z.number().optional(),
|
||||
};
|
||||
});
|
||||
export const defaultMemoryModelForm = {
|
||||
embd_id: '',
|
||||
llm_id: '',
|
||||
memory_type: [MemoryType.Raw],
|
||||
memory_type: [],
|
||||
memory_size: 0,
|
||||
};
|
||||
export const MemoryModelForm = () => {
|
||||
@ -66,13 +75,14 @@ export const MemoryModelForm = () => {
|
||||
horizontal: true,
|
||||
placeholder: t('memories.memoryTypePlaceholder'),
|
||||
tooltip: t('memories.memoryTypeTooltip'),
|
||||
disabled: true,
|
||||
options: [
|
||||
{ label: 'Raw', value: 'raw' },
|
||||
{ label: 'Semantic', value: 'semantic' },
|
||||
{ label: 'Episodic', value: 'episodic' },
|
||||
{ label: 'Procedural', value: 'procedural' },
|
||||
],
|
||||
disabled: data?.messages?.total_count > 0,
|
||||
options: MemoryOptions(t),
|
||||
customValidate: (value) => {
|
||||
if (!value.includes(MemoryType.Raw) || !value.length) {
|
||||
return t('memories.embeddingModelError');
|
||||
}
|
||||
return true;
|
||||
},
|
||||
required: true,
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -34,7 +34,7 @@ const methods = {
|
||||
} as const;
|
||||
const memoryService = registerNextServer<keyof typeof methods>(methods);
|
||||
export const updateMemoryById = (id: string, data: any) => {
|
||||
return request.put(updateMemorySetting(id), { data });
|
||||
return request.put(updateMemorySetting(id), { ...data });
|
||||
};
|
||||
export const getMemoryDetailById = (id: string, data: any) => {
|
||||
return request.get(getMemoryDetail(id), { params: data });
|
||||
|
||||
Reference in New Issue
Block a user