From 03e39ca9be72f9850464bfbc3ccb6a0c27b4f89c Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Thu, 24 Jul 2025 09:30:05 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9AOptimize=20Agent=20template=20page,?= =?UTF-8?q?=20=20fix=20bugs=20in=20knowledge=20base=20(#9009)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? Replace Avatar with RAGFlowAvatar component for knowledge base and agent, optimize Agent template page, and modify bugs in knowledge base #3221 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- .../components/entity-types-form-field.tsx | 8 --- web/src/components/knowledge-base-item.tsx | 10 +-- .../raptor-form-fields.tsx | 24 ++++--- web/src/hooks/llm-hooks.tsx | 16 +++-- web/src/locales/en.ts | 1 + web/src/locales/zh.ts | 1 + .../agent/canvas/node/retrieval-node.tsx | 13 ++-- web/src/pages/agents/agent-templates.tsx | 15 ++++- web/src/pages/agents/template-card.tsx | 64 +++++++++++-------- web/src/pages/agents/template-sidebar.tsx | 57 +++++++++++++++++ .../dataset/dataset/parsing-status-cell.tsx | 23 +++++-- web/src/pages/dataset/setting/hooks.ts | 13 +++- web/src/pages/dataset/setting/index.tsx | 4 -- web/src/pages/datasets/dataset-card.tsx | 11 ++-- .../pages/user-setting/setting-model/hooks.ts | 15 +++-- .../user-setting/setting-model/index.tsx | 33 +++++++--- .../setting-model/ollama-modal/index.tsx | 17 ++--- 17 files changed, 222 insertions(+), 103 deletions(-) create mode 100644 web/src/pages/agents/template-sidebar.tsx diff --git a/web/src/components/entity-types-form-field.tsx b/web/src/components/entity-types-form-field.tsx index ddf08cb0b..6008b20b0 100644 --- a/web/src/components/entity-types-form-field.tsx +++ b/web/src/components/entity-types-form-field.tsx @@ -12,13 +12,6 @@ import { type EntityTypesFormFieldProps = { name?: string; }; -const initialEntityTypes = [ - 'organization', - 'person', - 'geo', - 'event', - 'category', -]; export function EntityTypesFormField({ name = 'parser_config.entity_types', }: EntityTypesFormFieldProps) { @@ -29,7 +22,6 @@ export function EntityTypesFormField({ { return ( diff --git a/web/src/components/knowledge-base-item.tsx b/web/src/components/knowledge-base-item.tsx index 7ae98e4d5..e01ff6e80 100644 --- a/web/src/components/knowledge-base-item.tsx +++ b/web/src/components/knowledge-base-item.tsx @@ -3,9 +3,8 @@ import { useTranslate } from '@/hooks/common-hooks'; import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; import { UserOutlined } from '@ant-design/icons'; import { Avatar as AntAvatar, Form, Select, Space } from 'antd'; -import { Book } from 'lucide-react'; import { useFormContext } from 'react-hook-form'; -import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'; +import { RAGFlowAvatar } from './ragflow-avatar'; import { FormControl, FormField, FormItem, FormLabel } from './ui/form'; import { MultiSelect } from './ui/multi-select'; @@ -81,12 +80,7 @@ export function KnowledgeBaseFormField() { label: x.name, value: x.id, icon: () => ( - - - - - - + ), })); diff --git a/web/src/components/parse-configuration/raptor-form-fields.tsx b/web/src/components/parse-configuration/raptor-form-fields.tsx index 8ee184e46..17d631ad3 100644 --- a/web/src/components/parse-configuration/raptor-form-fields.tsx +++ b/web/src/components/parse-configuration/raptor-form-fields.tsx @@ -3,7 +3,7 @@ import { DocumentParserType } from '@/constants/knowledge'; import { useTranslate } from '@/hooks/common-hooks'; import random from 'lodash/random'; import { Plus } from 'lucide-react'; -import { useCallback } from 'react'; +import { useCallback, useEffect } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import { SliderInputFormField } from '../slider-input-form-field'; import { Button } from '../ui/button'; @@ -46,6 +46,10 @@ export const showTagItems = (parserId: DocumentParserType) => { const UseRaptorField = 'parser_config.raptor.use_raptor'; const RandomSeedField = 'parser_config.raptor.random_seed'; +const MaxTokenField = 'parser_config.raptor.max_token'; +const ThresholdField = 'parser_config.raptor.threshold'; +const MaxCluster = 'parser_config.raptor.max_cluster'; +const Prompt = 'parser_config.raptor.prompt'; // The three types "table", "resume" and "one" do not display this configuration. @@ -53,6 +57,15 @@ const RaptorFormFields = () => { const form = useFormContext(); const { t } = useTranslate('knowledgeConfiguration'); const useRaptor = useWatch({ name: UseRaptorField }); + useEffect(() => { + if (useRaptor) { + form.setValue(MaxTokenField, 256); + form.setValue(ThresholdField, 0.1); + form.setValue(MaxCluster, 64); + form.setValue(RandomSeedField, 0); + form.setValue(Prompt, t('promptText')); + } + }, [form, useRaptor, t]); const handleGenerate = useCallback(() => { form.setValue(RandomSeedField, random(10000)); @@ -114,11 +127,7 @@ const RaptorFormFields = () => {
-