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

🔨 chore: Refresh token when change historyCount #3094

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

sxjeru
Copy link
Contributor

@sxjeru sxjeru commented Jun 30, 2024

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • ⚡️ perf
  • 📝 docs

🔀 变更说明 | Description of Change

#2933 重新实现。

存在一个问题,当历史消息数设置为大于现有消息数后,不论如何修改设置,token 均不会刷新。
准确来说是下面的 config 状态不再刷新。直到切换话题或刷新网页后恢复。
不清楚是什么问题。

const config = agentSelectors.currentAgentChatConfig(useAgentStore.getState());

📝 补充信息 | Additional Information

Copy link

vercel bot commented Jun 30, 2024

@sxjeru is attempting to deploy a commit to the LobeHub Pro Team on Vercel.

A member of the Team first needs to authorize it.

@lobehubbot
Copy link
Member

👍 @sxjeru

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.17%. Comparing base (03173b7) to head (4c6e7eb).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3094      +/-   ##
==========================================
- Coverage   94.17%   94.17%   -0.01%     
==========================================
  Files         394      394              
  Lines       24701    24700       -1     
  Branches     2806     2694     -112     
==========================================
- Hits        23262    23260       -2     
- Misses       1439     1440       +1     
Flag Coverage Δ
app 94.17% <100.00%> (-0.01%) ⬇️
server 68.05% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

const chatsMessageString = (s: ChatStore): string => {
const chats = currentChatsWithHistoryConfig(s);
const chatsMessageString = (s: ChatStore, config: LobeAgentChatConfig): string => {
const chats = currentChatsWithHistoryConfig(s, config);
return chats.map((m) => m.content).join('');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

核心问题还是message 的长度响应来自 chats 而不是 config ,确保响应式的正确做法应该是将 chats 作为入参,即

const chatsMessageString = (chats: ChatMessage[]) =>(s: ChatStore): string =>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以先试试我下面的回复写法是否OK,如果下面的写法能确保响应式,也可以

@@ -22,9 +22,10 @@ const Token = memo(() => {
const { t } = useTranslation(['chat', 'components']);
const theme = useTheme();

const config = agentSelectors.currentAgentChatConfig(useAgentStore.getState());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外这个写法也是有问题的。

useAgentStore.getState() 这个不是一个响应式的写法,取出来的值是fixed的,要响应式,得改成

const config = useAgentStore(agentSelectors.currentAgentChatConfig)

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants