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

♻️ refactor: separate message slice and ai-chat slice #4359

Merged
merged 5 commits into from
Oct 13, 2024

Conversation

arvinxx
Copy link
Contributor

@arvinxx arvinxx commented Oct 13, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

重构 chat store 中 message slice (当前太大了,总共 30 个 actions),考虑未来 message 还会支持多选、批量删除等操作。AI 对话部分会进一步增强能力,因此提前拆成两个 slice:

  • message slice: 承载所有 message 的增删改查和基础交互,actions 总共 21 个;
    • 增:(1 外部 + 2 内部)
    • 删:(4 外部 + 1 内部)
    • 改:(3 外部 + 3 内部)
    • 查:(2 外部 + 3 内部)
    • 副作用: 2 外部
    • 由于 message 作为基础实体,增删改查相关的实现已经基本完备,因此基础实现不会膨胀;
    • 未来的进一步优化思路是将 message slice 作为 aiChat slice 的基础方法来使用,因此可以考虑优化接口和收敛实现;
  • aiChat slice: 承载所有 ai chat competition 的实现 (9 个),后续 rag 也提取到该 slice 中

📝 补充信息 | Additional Information

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Oct 13, 2024
Copy link

vercel bot commented Oct 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-database ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 13, 2024 3:54pm
lobe-chat-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 13, 2024 3:54pm

@lobehubbot
Copy link
Member

👍 @arvinxx

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 Oct 13, 2024

Codecov Report

Attention: Patch coverage is 87.75862% with 71 lines in your changes missing coverage. Please review.

Project coverage is 92.21%. Comparing base (0284606) to head (3ba3606).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/store/chat/slices/aiChat/action.ts 86.75% 71 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4359      +/-   ##
==========================================
+ Coverage   92.19%   92.21%   +0.01%     
==========================================
  Files         491      493       +2     
  Lines       35346    35396      +50     
  Branches     3246     2303     -943     
==========================================
+ Hits        32588    32640      +52     
+ Misses       2758     2756       -2     
Flag Coverage Δ
app 92.21% <87.75%> (+0.01%) ⬆️
server 97.37% <ø> (ø)

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.

@arvinxx arvinxx merged commit 7d037f6 into main Oct 13, 2024
11 checks passed
@arvinxx arvinxx deleted the refactor/refactor-chat-store branch October 13, 2024 15:55
@lobehubbot
Copy link
Member

❤️ Great PR @arvinxx ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

github-actions bot pushed a commit that referenced this pull request Oct 13, 2024
### [Version&nbsp;1.22.4](v1.22.3...v1.22.4)
<sup>Released on **2024-10-13**</sup>

#### ♻ Code Refactoring

- **misc**: Separate message slice and aiChat slice.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Separate message slice and aiChat slice, closes [#4359](#4359) ([7d037f6](7d037f6))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.22.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Oct 14, 2024
### [Version&nbsp;1.65.2](v1.65.1...v1.65.2)
<sup>Released on **2024-10-14**</sup>

#### ♻ Code Refactoring

- **misc**: Separate message slice and aiChat slice.

#### 🐛 Bug Fixes

- **misc**: Fix images not go in to chat context.

#### 💄 Styles

- **misc**: Reorder github model list & updata info & add new model, support multi-windows for PWA.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Separate message slice and aiChat slice, closes [lobehub#4359](https://github.com/bentwnghk/lobe-chat/issues/4359) ([7d037f6](7d037f6))

#### What's fixed

* **misc**: Fix images not go in to chat context, closes [lobehub#4361](https://github.com/bentwnghk/lobe-chat/issues/4361) ([f17ab49](f17ab49))

#### Styles

* **misc**: Reorder github model list & updata info & add new model, closes [lobehub#4360](https://github.com/bentwnghk/lobe-chat/issues/4360) ([e7767a5](e7767a5))
* **misc**: Support multi-windows for PWA, closes [lobehub#4334](https://github.com/bentwnghk/lobe-chat/issues/4334) ([0284606](0284606))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants