mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-24 15:36:50 +08:00
Fix:Bugs fix (Reduce metadata saving steps ...) (#12095)
### What problem does this PR solve? Fix:Bugs fix - Configure memory and metadata (in Chinese) - Add indexing modal - Reduce metadata saving steps ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
10
web/src/assets/svg/home-icon/memory-bri.svg
Normal file
10
web/src/assets/svg/home-icon/memory-bri.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M22 12H2M22 12V18C22 18.5304 21.7893 19.0391 21.4142 19.4142C21.0391 19.7893 20.5304 20 20 20H4C3.46957 20 2.96086 19.7893 2.58579 19.4142C2.21071 19.0391 2 18.5304 2 18V12M22 12L18.55 5.11C18.3844 4.77679 18.1292 4.49637 17.813 4.30028C17.4967 4.10419 17.1321 4.0002 16.76 4H7.24C6.86792 4.0002 6.50326 4.10419 6.18704 4.30028C5.87083 4.49637 5.61558 4.77679 5.45 5.11L2 12" stroke="url(#paint0_linear_1415_84974)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M6 16H6.01M10 16H10.01" stroke="#00BEB4" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_1415_84974" x1="12.5556" y1="4" x2="12.5556" y2="20" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#161618"/>
|
||||
<stop offset="1" stop-color="#666666"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 935 B |
@ -1,6 +1,7 @@
|
||||
import { DocumentParserType } from '@/constants/knowledge';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { LLMModelItem } from '@/pages/dataset/dataset-setting/configuration/common-item';
|
||||
import {
|
||||
GenerateLogButton,
|
||||
GenerateType,
|
||||
@ -136,6 +137,10 @@ const GraphRagItems = ({
|
||||
|
||||
return (
|
||||
<FormContainer className={cn({ 'mb-4': marginBottom }, className)}>
|
||||
<LLMModelItem
|
||||
label={t('globalIndexModel')}
|
||||
name={'parser_config.llm_id'}
|
||||
/>
|
||||
<UseGraphRagFormField
|
||||
data={data}
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -176,6 +176,7 @@ Procedural Memory: Learned skills, habits, and automated procedures.`,
|
||||
},
|
||||
knowledgeDetails: {
|
||||
metadata: {
|
||||
fieldSetting: 'Field settings',
|
||||
changesAffectNewParses: 'Changes affect new parses only.',
|
||||
editMetadataForDataset: 'View and edit metadata for ',
|
||||
restrictDefinedValues: 'Restrict to defined values',
|
||||
@ -363,7 +364,11 @@ Procedural Memory: Learned skills, habits, and automated procedures.`,
|
||||
reRankModelWaring: 'Re-rank model is very time consuming.',
|
||||
},
|
||||
knowledgeConfiguration: {
|
||||
globalIndexModelTip:
|
||||
'Used to generate Knowledge graphs, RAPTOR, auto-metadata, auto-keyword and auto-question. Model performance will affects generation quality.',
|
||||
globalIndexModel: 'Indexing model',
|
||||
settings: 'Settings',
|
||||
autoMetadataTip: `Automatically generate metadata. Applies to new files during parsing. Existing files require re-parsing to update (chunks remain preserved). Be aware that extra tokens will be consumed by the indexing model specified in 'Configuration'.`,
|
||||
imageContextWindow: 'Image context window',
|
||||
imageContextWindowTip:
|
||||
'Captures N tokens of text above and below the image to provide richer background context for the image chunk.',
|
||||
|
||||
@ -93,6 +93,67 @@ export default {
|
||||
search: '搜索',
|
||||
welcome: '欢迎来到',
|
||||
dataset: '知识库',
|
||||
Memories: '记忆',
|
||||
},
|
||||
memories: {
|
||||
llmTooltip: '分析对话内容,提取关键信息,并生成结构化的记忆摘要。',
|
||||
embeddingModelTooltip:
|
||||
'将文本转换为数值向量,用于语义相似度搜索和记忆检索。',
|
||||
embeddingModelError: '记忆类型为必填项,且"原始"类型不可删除。',
|
||||
memoryTypeTooltip: `原始: 用户与代理之间的原始对话内容(默认必需)。
|
||||
语义记忆: 关于用户和世界的通用知识和事实。
|
||||
情景记忆: 带时间戳的特定事件和经历记录。
|
||||
程序记忆: 学习的技能、习惯和自动化程序。`,
|
||||
editName: '编辑名称',
|
||||
memory: '记忆',
|
||||
createMemory: '创建记忆',
|
||||
name: '名称',
|
||||
memoryNamePlaceholder: '记忆名称',
|
||||
memoryType: '记忆类型',
|
||||
embeddingModel: '嵌入模型',
|
||||
selectModel: '选择模型',
|
||||
llm: '大语言模型',
|
||||
delMemoryWarn: `删除后,此记忆中的所有消息都将被删除,代理将无法检索。`,
|
||||
},
|
||||
memory: {
|
||||
messages: {
|
||||
messageDescription:
|
||||
'记忆检索已在高级设置中配置相似度阈值、关键词相似度权重和前N个结果。',
|
||||
copied: '已复制!',
|
||||
contentEmbed: '内容嵌入',
|
||||
content: '内容',
|
||||
delMessageWarn: `遗忘后,代理将无法检索此消息。`,
|
||||
forgetMessage: '遗忘消息',
|
||||
sessionId: '会话ID',
|
||||
agent: '代理',
|
||||
type: '类型',
|
||||
validDate: '有效日期',
|
||||
forgetAt: '遗忘于',
|
||||
source: '来源',
|
||||
enable: '启用',
|
||||
action: '操作',
|
||||
},
|
||||
config: {
|
||||
avatar: '头像',
|
||||
description: '描述',
|
||||
memorySize: '记忆大小',
|
||||
advancedSettings: '高级设置',
|
||||
permission: '权限',
|
||||
onlyMe: '仅自己',
|
||||
team: '团队',
|
||||
storageType: '存储类型',
|
||||
storageTypePlaceholder: '请选择存储类型',
|
||||
forgetPolicy: '遗忘策略',
|
||||
temperature: '温度',
|
||||
systemPrompt: '系统提示词',
|
||||
systemPromptPlaceholder: '请输入系统提示词',
|
||||
userPrompt: '用户提示词',
|
||||
userPromptPlaceholder: '请输入用户提示词',
|
||||
},
|
||||
sideBar: {
|
||||
messages: '消息',
|
||||
configuration: '配置',
|
||||
},
|
||||
},
|
||||
knowledgeList: {
|
||||
welcome: '欢迎回来',
|
||||
@ -106,6 +167,22 @@ export default {
|
||||
parserRequired: '分块方法必填',
|
||||
},
|
||||
knowledgeDetails: {
|
||||
metadata: {
|
||||
fieldSetting: '字段设置',
|
||||
changesAffectNewParses: '更改仅影响新解析。',
|
||||
editMetadataForDataset: '查看和编辑元数据于 ',
|
||||
restrictDefinedValues: '限制为已定义值',
|
||||
metadataGenerationSettings: '元数据生成设置',
|
||||
manageMetadataForDataset: '管理此数据集的元数据',
|
||||
manageMetadata: '管理元数据',
|
||||
metadata: '元数据',
|
||||
values: '值',
|
||||
action: '操作',
|
||||
field: '字段',
|
||||
description: '描述',
|
||||
fieldName: '字段名',
|
||||
editMetadata: '编辑元数据',
|
||||
},
|
||||
localUpload: '本地上传',
|
||||
fileSize: '文件大小',
|
||||
fileType: '文件类型',
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import message from '@/components/ui/message';
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { useSetDocumentMeta } from '@/hooks/use-document-request';
|
||||
import {
|
||||
import kbService, {
|
||||
getMetaDataService,
|
||||
updateMetaData,
|
||||
} from '@/services/knowledge-service';
|
||||
@ -255,7 +255,7 @@ export const useManageMetaDataModal = (
|
||||
data: operations,
|
||||
});
|
||||
if (res.code === 0) {
|
||||
message.success(t('message.success'));
|
||||
message.success(t('message.operated'));
|
||||
callback();
|
||||
}
|
||||
},
|
||||
@ -282,11 +282,18 @@ export const useManageMetaDataModal = (
|
||||
const handleSaveSettings = useCallback(
|
||||
async (callback: () => void) => {
|
||||
const data = util.tableDataToMetaDataSettingJSON(tableData);
|
||||
callback();
|
||||
const { data: res } = await kbService.kbUpdateMetaData({
|
||||
kb_id: id,
|
||||
metadata: data,
|
||||
});
|
||||
if (res.code === 0) {
|
||||
message.success(t('message.operated'));
|
||||
callback?.();
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
[tableData],
|
||||
[tableData, id],
|
||||
);
|
||||
|
||||
const handleSave = useCallback(
|
||||
|
||||
@ -27,7 +27,7 @@ import {
|
||||
import { Plus, Settings, Trash2 } from 'lucide-react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useManageMetaDataModal } from './hook';
|
||||
import { MetadataType, useManageMetaDataModal } from './hook';
|
||||
import { IManageModalProps, IMetaDataTableData } from './interface';
|
||||
import { ManageValuesModal } from './manage-values-modal';
|
||||
export const ManageMetadataModal = (props: IManageModalProps) => {
|
||||
@ -335,7 +335,13 @@ export const ManageMetadataModal = (props: IManageModalProps) => {
|
||||
</Modal>
|
||||
{manageValuesVisible && (
|
||||
<ManageValuesModal
|
||||
title={<div>{t('knowledgeDetails.metadata.editMetadata')}</div>}
|
||||
title={
|
||||
<div>
|
||||
{metadataType === MetadataType.Setting
|
||||
? t('knowledgeDetails.metadata.fieldSetting')
|
||||
: t('knowledgeDetails.metadata.editMetadata')}
|
||||
</div>
|
||||
}
|
||||
visible={manageValuesVisible}
|
||||
hideModal={hideManageValuesModal}
|
||||
data={valueData}
|
||||
|
||||
@ -154,7 +154,7 @@ export const ManageValuesModal = (props: IManageValuesProps) => {
|
||||
open={visible}
|
||||
onCancel={handleHideModal}
|
||||
className="!w-[460px]"
|
||||
okText={t('common.save')}
|
||||
okText={t('common.confirm')}
|
||||
onOk={handleSave}
|
||||
maskClosable={false}
|
||||
footer={null}
|
||||
|
||||
@ -3,7 +3,10 @@ import {
|
||||
FormFieldType,
|
||||
RenderField,
|
||||
} from '@/components/dynamic-form';
|
||||
import { SelectWithSearch } from '@/components/originui/select-with-search';
|
||||
import {
|
||||
SelectWithSearch,
|
||||
SelectWithSearchFlagOptionType,
|
||||
} from '@/components/originui/select-with-search';
|
||||
import { SliderInputFormField } from '@/components/slider-input-form-field';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
@ -16,7 +19,9 @@ import {
|
||||
import { Radio } from '@/components/ui/radio';
|
||||
import { Spin } from '@/components/ui/spin';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { LlmModelType } from '@/constants/knowledge';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useComposeLlmOptionsByModelTypes } from '@/hooks/use-llm-request';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { t } from 'i18next';
|
||||
import { Settings } from 'lucide-react';
|
||||
@ -41,6 +46,8 @@ import {
|
||||
interface IProps {
|
||||
line?: 1 | 2;
|
||||
isEdit?: boolean;
|
||||
label?: string;
|
||||
name?: string;
|
||||
}
|
||||
export function ChunkMethodItem(props: IProps) {
|
||||
const { line } = props;
|
||||
@ -368,7 +375,7 @@ export function AutoMetadata() {
|
||||
type: FormFieldType.Custom,
|
||||
horizontal: true,
|
||||
defaultValue: true,
|
||||
|
||||
tooltip: t('knowledgeConfiguration.autoMetadataTip'),
|
||||
render: (fieldProps: ControllerRenderProps) => (
|
||||
<div className="flex items-center justify-between">
|
||||
<Button
|
||||
@ -432,3 +439,80 @@ export function AutoMetadata() {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const LLMSelect = ({
|
||||
isEdit,
|
||||
field,
|
||||
disabled = false,
|
||||
}: {
|
||||
isEdit: boolean;
|
||||
field: FieldValues;
|
||||
name?: string;
|
||||
disabled?: boolean;
|
||||
}) => {
|
||||
const { t } = useTranslate('knowledgeConfiguration');
|
||||
const modelOptions = useComposeLlmOptionsByModelTypes([
|
||||
LlmModelType.Chat,
|
||||
LlmModelType.Image2text,
|
||||
]);
|
||||
return (
|
||||
<SelectWithSearch
|
||||
onChange={async (value) => {
|
||||
field.onChange(value);
|
||||
}}
|
||||
disabled={disabled && !isEdit}
|
||||
value={field.value}
|
||||
options={modelOptions as SelectWithSearchFlagOptionType[]}
|
||||
placeholder={t('embeddingModelPlaceholder')}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function LLMModelItem({ line = 1, isEdit, label, name }: IProps) {
|
||||
const { t } = useTranslate('knowledgeConfiguration');
|
||||
const form = useFormContext();
|
||||
const disabled = useHasParsedDocument(isEdit);
|
||||
return (
|
||||
<>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={name ?? 'llm_id'}
|
||||
render={({ field }) => (
|
||||
<FormItem className={cn(' items-center space-y-0 ')}>
|
||||
<div
|
||||
className={cn('flex', {
|
||||
' items-center': line === 1,
|
||||
'flex-col gap-1': line === 2,
|
||||
})}
|
||||
>
|
||||
<FormLabel
|
||||
required
|
||||
tooltip={t('globalIndexModelTip')}
|
||||
className={cn('text-sm whitespace-wrap ', {
|
||||
'w-1/4': line === 1,
|
||||
})}
|
||||
>
|
||||
{label ?? t('llmModel')}
|
||||
</FormLabel>
|
||||
<div
|
||||
className={cn('text-text-secondary', { 'w-3/4': line === 1 })}
|
||||
>
|
||||
<FormControl>
|
||||
<LLMSelect
|
||||
isEdit={!!isEdit}
|
||||
field={field}
|
||||
disabled={disabled}
|
||||
></LLMSelect>
|
||||
</FormControl>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex pt-1">
|
||||
<div className={line === 1 ? 'w-1/4' : ''}></div>
|
||||
<FormMessage />
|
||||
</div>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -96,6 +96,7 @@ export const formSchema = z
|
||||
)
|
||||
.optional(),
|
||||
enable_metadata: z.boolean().optional(),
|
||||
llm_id: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
pagerank: z.number(),
|
||||
|
||||
@ -93,6 +93,7 @@ export default function DatasetSettings() {
|
||||
},
|
||||
metadata: [],
|
||||
enable_metadata: false,
|
||||
llm_id: '',
|
||||
},
|
||||
pipeline_id: '',
|
||||
parseType: 1,
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { DynamicForm } from '@/components/dynamic-form';
|
||||
import { useModelOptions } from '@/components/llm-setting-items/llm-form-field';
|
||||
import { HomeIcon } from '@/components/svg-icon';
|
||||
import { Modal } from '@/components/ui/modal/modal';
|
||||
import { memo, useMemo } from 'react';
|
||||
@ -18,7 +17,7 @@ type IProps = {
|
||||
export const AddOrEditModal = memo((props: IProps) => {
|
||||
const { open, onClose, onSubmit, initialMemory, isCreate } = props;
|
||||
const { t } = useTranslation();
|
||||
const { modelOptions } = useModelOptions();
|
||||
// const { modelOptions } = useModelOptions();
|
||||
|
||||
const fields = useMemo(() => {
|
||||
if (!isCreate) {
|
||||
@ -26,21 +25,22 @@ export const AddOrEditModal = memo((props: IProps) => {
|
||||
(field: any) => field.name === 'name',
|
||||
);
|
||||
} else {
|
||||
const tempFields = createMemoryFields(t).map((field: any) => {
|
||||
if (field.name === 'llm_id') {
|
||||
return {
|
||||
...field,
|
||||
options: modelOptions,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
...field,
|
||||
};
|
||||
}
|
||||
});
|
||||
return tempFields;
|
||||
// const tempFields = createMemoryFields(t).map((field: any) => {
|
||||
// if (field.name === 'llm_id') {
|
||||
// return {
|
||||
// ...field,
|
||||
// options: modelOptions,
|
||||
// };
|
||||
// } else {
|
||||
// return {
|
||||
// ...field,
|
||||
// };
|
||||
// }
|
||||
// });
|
||||
// return tempFields;
|
||||
return createMemoryFields(t);
|
||||
}
|
||||
}, [modelOptions, isCreate]);
|
||||
}, [isCreate, t]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { FormFieldConfig, FormFieldType } from '@/components/dynamic-form';
|
||||
import { EmbeddingSelect } from '@/pages/dataset/dataset-setting/configuration/common-item';
|
||||
import {
|
||||
EmbeddingSelect,
|
||||
LLMSelect,
|
||||
} from '@/pages/dataset/dataset-setting/configuration/common-item';
|
||||
import { TFunction } from 'i18next';
|
||||
export enum MemoryType {
|
||||
Raw = 'raw',
|
||||
@ -52,6 +55,7 @@ export const createMemoryFields = (t: TFunction) =>
|
||||
required: true,
|
||||
type: FormFieldType.Select,
|
||||
tooltip: t('memories.llmTooltip'),
|
||||
render: (field) => <LLMSelect field={field} isEdit={false} />,
|
||||
},
|
||||
] as FormFieldConfig[];
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ const {
|
||||
runRaptor,
|
||||
traceRaptor,
|
||||
check_embedding,
|
||||
kbUpdateMetaData,
|
||||
} = api;
|
||||
|
||||
const methods = {
|
||||
@ -215,6 +216,10 @@ const methods = {
|
||||
url: check_embedding,
|
||||
method: 'post',
|
||||
},
|
||||
kbUpdateMetaData: {
|
||||
url: kbUpdateMetaData,
|
||||
method: 'post',
|
||||
},
|
||||
// getMetaData: {
|
||||
// url: getMetaData,
|
||||
// method: 'get',
|
||||
|
||||
@ -79,6 +79,7 @@ export default {
|
||||
pipelineRerun: `${api_host}/canvas/rerun`,
|
||||
getMetaData: `${api_host}/document/metadata/summary`,
|
||||
updateMetaData: `${api_host}/document/metadata/update`,
|
||||
kbUpdateMetaData: `${api_host}/kb/update_metadata_setting`,
|
||||
|
||||
// tags
|
||||
listTag: (knowledgeId: string) => `${api_host}/kb/${knowledgeId}/tags`,
|
||||
|
||||
Reference in New Issue
Block a user