mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-30 07:06:39 +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:
@ -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,
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user