Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 限制历史消息数功能逻辑缺陷 #5154

Open
1oca1h0st opened this issue Dec 23, 2024 · 3 comments · May be fixed by #5174
Open

[Bug] 限制历史消息数功能逻辑缺陷 #5154

1oca1h0st opened this issue Dec 23, 2024 · 3 comments · May be fixed by #5174
Labels
🐛 Bug Something isn't working | 缺陷

Comments

@1oca1h0st
Copy link

📦 部署环境

Docker

📌 软件版本

v1.38.0

💻 系统环境

macOS

🌐 浏览器

Chrome

🐛 问题描述

限制历史消息数功能打开时,设置为0应当是没有上下文,而不是不限制上下文数量。

现在实际上当启用限制功能时,最低为0,代码逻辑在:
lobehub/lobe-chat/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/index.tsx [68:75]
const enableHistoryDivider = useAgentStore((s) => {
const config = agentSelectors.currentAgentChatConfig(s);
return (
config.enableHistoryCount &&
historyLength > (config.historyCount ?? 0) &&
config.historyCount === historyLength - index
);
});
可以看到限制为0时,会始终返回false

📷 复现步骤

启用一个话题时,启用限制历史消息数功能,设置限制为0即可复现

🚦 期望结果

当启用限制历史消息数功能,且限制为0时,限制应当如下:

user: A
AI:B
---结束对话
user:new A
AI: new B

📝 补充信息

No response

@1oca1h0st 1oca1h0st added the 🐛 Bug Something isn't working | 缺陷 label Dec 23, 2024
@github-project-automation github-project-automation bot moved this to Roadmap - Chat 1.x in Lobe Chat Routine Dec 23, 2024
@lobehubbot
Copy link
Member

👀 @1oca1h0st

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

Copy link

dosubot bot commented Dec 23, 2024

Hello, @1oca1h0st! I'm here to help you with any bugs, questions, or contributions. Let me know how I can assist you!

The issue you're encountering is related to the logic for handling the historyCount setting when it is set to 0. The expected behavior is that when the enableHistoryCount feature is turned on and historyCount is set to 0, no context should be retained. However, the current implementation does not achieve this, as the logic always returns false when historyCount is 0.

To address this, you may need to adjust the logic in the ChatItem/index.tsx file. Specifically, ensure that when historyCount is set to 0, the application does not retain any previous messages. This might involve modifying the condition that checks the historyCount and historyLength to correctly handle the case where historyCount is 0.

The relevant code snippet is:

const enableHistoryDivider = useAgentStore((s) => {
    const config = agentSelectors.currentAgentChatConfig(s);
    return (
      config.enableHistoryCount &&
      historyLength > (config.historyCount ?? 0) &&
      config.historyCount === historyLength - index
    );
});

You might need to add a specific check for historyCount === 0 to ensure that no messages are retained in this scenario.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@1oca1h0st
Copy link
Author

翻找了下代码,发现是设计就是这样的,请问是否能更改呢?
image

这个与issue #4816 同一个问题

@sxjeru sxjeru linked a pull request Dec 25, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working | 缺陷
Projects
Status: Roadmap - Chat 1.x
Development

Successfully merging a pull request may close this issue.

2 participants