mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-02 00:25:06 +08:00
Fix: Editing the agent greeting causes the greeting to be continuously added to the message list. #12635 (#12636)
### What problem does this PR solve? Fix: Editing the agent greeting causes the greeting to be continuously added to the message list. #12635 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -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 = ({
|
export const LlmIcon = ({
|
||||||
name,
|
name,
|
||||||
height = 48,
|
height = 48,
|
||||||
@ -79,14 +100,7 @@ export const LlmIcon = ({
|
|||||||
imgClass?: string;
|
imgClass?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const isDark = useIsDarkTheme();
|
const isDark = useIsDarkTheme();
|
||||||
const themeIcons = [
|
const icon = useMemo(() => {
|
||||||
LLMFactory.FishAudio,
|
|
||||||
LLMFactory.TogetherAI,
|
|
||||||
LLMFactory.Meituan,
|
|
||||||
LLMFactory.Longcat,
|
|
||||||
LLMFactory.MinerU,
|
|
||||||
];
|
|
||||||
let icon = useMemo(() => {
|
|
||||||
const icontemp = IconMap[name as keyof typeof IconMap];
|
const icontemp = IconMap[name as keyof typeof IconMap];
|
||||||
if (themeIcons.includes(name as LLMFactory)) {
|
if (themeIcons.includes(name as LLMFactory)) {
|
||||||
if (isDark) {
|
if (isDark) {
|
||||||
@ -98,16 +112,6 @@ export const LlmIcon = ({
|
|||||||
return icontemp;
|
return icontemp;
|
||||||
}, [name, isDark]);
|
}, [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)) {
|
if (svgIcons.includes(name as LLMFactory)) {
|
||||||
return (
|
return (
|
||||||
<SvgIcon
|
<SvgIcon
|
||||||
|
|||||||
@ -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(() => {
|
const removeLatestMessage = useCallback(() => {
|
||||||
setDerivedMessages((pre) => {
|
setDerivedMessages((pre) => {
|
||||||
const nextMessages = pre?.slice(0, -2) ?? [];
|
const nextMessages = pre?.slice(0, -2) ?? [];
|
||||||
@ -607,6 +631,7 @@ export const useSelectDerivedMessages = () => {
|
|||||||
removeAllMessages,
|
removeAllMessages,
|
||||||
scrollToBottom,
|
scrollToBottom,
|
||||||
removeAllMessagesExceptFirst,
|
removeAllMessagesExceptFirst,
|
||||||
|
addPrologue,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -243,6 +243,7 @@ export const useSendAgentMessage = ({
|
|||||||
removeAllMessages,
|
removeAllMessages,
|
||||||
removeAllMessagesExceptFirst,
|
removeAllMessagesExceptFirst,
|
||||||
scrollToBottom,
|
scrollToBottom,
|
||||||
|
addPrologue,
|
||||||
} = useSelectDerivedMessages();
|
} = useSelectDerivedMessages();
|
||||||
const { addEventList: addEventListFun } = useContext(AgentChatLogContext);
|
const { addEventList: addEventListFun } = useContext(AgentChatLogContext);
|
||||||
const {
|
const {
|
||||||
@ -417,12 +418,11 @@ export const useSendAgentMessage = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prologue) {
|
if (prologue) {
|
||||||
addNewestOneAnswer({
|
addPrologue(prologue);
|
||||||
answer: prologue,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
addNewestOneAnswer,
|
addNewestOneAnswer,
|
||||||
|
addPrologue,
|
||||||
agentId,
|
agentId,
|
||||||
isTaskMode,
|
isTaskMode,
|
||||||
prologue,
|
prologue,
|
||||||
|
|||||||
Reference in New Issue
Block a user