Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Editing the agent greeting causes the greeting to be continuously added to the message list. #12635 (#12636)

balibabud531bd4f1acc
diff --git a/web/src/components/svg-icon.tsx b/web/src/components/svg-icon.tsx
index 8931a292fb..3f97bf0d07 100644
--- a/web/src/components/svg-icon.tsx
+++ b/web/src/components/svg-icon.tsx
@@ -65,6 +65,27 @@ const SvgIcon = memo(
},
);
+SvgIcon.displayName = 'SvgIcon';
+
+const themeIcons = [
+ LLMFactory.FishAudio,
+ LLMFactory.TogetherAI,
+ LLMFactory.Meituan,
+ LLMFactory.Longcat,
+ LLMFactory.MinerU,
+];
+
+const svgIcons = [
+ LLMFactory.LocalAI,
+ // LLMFactory.VolcEngine,
+ // LLMFactory.MiniMax,
+ LLMFactory.Gemini,
+ LLMFactory.StepFun,
+ LLMFactory.MinerU,
+ LLMFactory.PaddleOCR,
+ // LLMFactory.DeerAPI,
+];
+
export const LlmIcon = ({
name,
height = 48,
@@ -79,14 +100,7 @@ export const LlmIcon = ({
imgClass?: string;
}) => {
const isDark = useIsDarkTheme();
- const themeIcons = [
- LLMFactory.FishAudio,
- LLMFactory.TogetherAI,
- LLMFactory.Meituan,
- LLMFactory.Longcat,
- LLMFactory.MinerU,
- ];
- let icon = useMemo(() => {
+ const icon = useMemo(() => {
const icontemp = IconMap[name as keyof typeof IconMap];
if (themeIcons.includes(name as LLMFactory)) {
if (isDark) {
@@ -98,16 +112,6 @@ export const LlmIcon = ({
return icontemp;
}, [name, isDark]);
- const svgIcons = [
- LLMFactory.LocalAI,
- // LLMFactory.VolcEngine,
- // LLMFactory.MiniMax,
- LLMFactory.Gemini,
- LLMFactory.StepFun,
- LLMFactory.MinerU,
- LLMFactory.PaddleOCR,
- // LLMFactory.DeerAPI,
- ];
if (svgIcons.includes(name as LLMFactory)) {
return (
<SvgIcon
diff --git a/web/src/hooks/logic-hooks.ts b/web/src/hooks/logic-hooks.ts
index e6323af554..1f7909016b 100644
--- a/web/src/hooks/logic-hooks.ts
+++ b/web/src/hooks/logic-hooks.ts
@@ -536,6 +536,30 @@ export const useSelectDerivedMessages = () => {
});
}, []);
+ const addPrologue = useCallback((prologue: string) => {
+ setDerivedMessages((pre) => {
+ if (pre.length > 0) {
+ return [
+ {
+ ...pre[0],
+ content: prologue,
+ },
+ ...pre.slice(1),
+ ];
+ }
+
+ return [
+ {
+ role: MessageType.Assistant,
+ content: prologue,
+ id: buildMessageUuid({
+ role: MessageType.Assistant,
+ }),
+ },
+ ];
+ });
+ }, []);
+
const removeLatestMessage = useCallback(() => {
setDerivedMessages((pre) => {
const nextMessages = pre?.slice(0, -2) ?? [];
@@ -607,6 +631,7 @@ export const useSelectDerivedMessages = () => {
removeAllMessages,
scrollToBottom,
removeAllMessagesExceptFirst,
+ addPrologue,
};
};
diff --git a/web/src/pages/agent/chat/use-send-agent-message.ts b/web/src/pages/agent/chat/use-send-agent-message.ts
index 186f3ac299..a40c08740d 100644
--- a/web/src/pages/agent/chat/use-send-agent-message.ts
+++ b/web/src/pages/agent/chat/use-send-agent-message.ts
@@ -243,6 +243,7 @@ export const useSendAgentMessage = ({
removeAllMessages,
removeAllMessagesExceptFirst,
scrollToBottom,
+ addPrologue,
} = useSelectDerivedMessages();
const { addEventList: addEventListFun } = useContext(AgentChatLogContext);
const {
@@ -417,12 +418,11 @@ export const useSendAgentMessage = ({
return;
}
if (prologue) {
- addNewestOneAnswer({
- answer: prologue,
- });
+ addPrologue(prologue);
}
}, [
addNewestOneAnswer,
+ addPrologue,
agentId,
isTaskMode,
prologue,