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: improve model fetch behavior #6055

Merged
merged 10 commits into from
Feb 14, 2025
Merged

Conversation

hezhijie0327
Copy link
Contributor

@hezhijie0327 hezhijie0327 commented Feb 12, 2025

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

  1. 当 API 无法准确获取模型能力是时,回退至内建数据
  2. 补齐 Ollama 及 LMStudio 模型获取能力
  3. 修正 Gemini Thinking 模型,functionCall tag 问题
  4. 异步加载 LOBE_DEFAULT_MODEL_LIST [TODO]

📝 补充信息 | Additional Information

Before After
image image

close #5887

Copy link

vercel bot commented Feb 12, 2025

@hezhijie0327 is attempting to deploy a commit to the LobeChat Community Team on Vercel.

A member of the Team first needs to authorize it.

@lobehubbot
Copy link
Member

👍 @hezhijie0327

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 Feb 12, 2025

Codecov Report

Attention: Patch coverage is 25.94538% with 705 lines in your changes missing coverage. Please review.

Project coverage is 91.77%. Comparing base (5a012e4) to head (fc6458c).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/libs/agent-runtime/siliconcloud/index.ts 4.00% 48 Missing ⚠️
src/libs/agent-runtime/giteeai/index.ts 4.34% 44 Missing ⚠️
src/libs/agent-runtime/qwen/index.ts 4.44% 43 Missing ⚠️
src/libs/agent-runtime/groq/index.ts 4.65% 41 Missing ⚠️
src/libs/agent-runtime/stepfun/index.ts 4.76% 40 Missing ⚠️
src/libs/agent-runtime/tencentcloud/index.ts 15.90% 37 Missing ⚠️
src/libs/agent-runtime/ai360/index.ts 5.40% 35 Missing ⚠️
src/libs/agent-runtime/higress/index.ts 26.66% 33 Missing ⚠️
src/libs/agent-runtime/hunyuan/index.ts 5.88% 32 Missing ⚠️
src/libs/agent-runtime/fireworksai/index.ts 6.66% 28 Missing ⚠️
... and 15 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6055      +/-   ##
==========================================
- Coverage   92.47%   91.77%   -0.70%     
==========================================
  Files         661      660       -1     
  Lines       60005    60495     +490     
  Branches     4212     2840    -1372     
==========================================
+ Hits        55488    55520      +32     
- Misses       4517     4975     +458     
Flag Coverage Δ
app 91.77% <25.94%> (-0.70%) ⬇️
server 97.90% <ø> (ø)

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.

@hezhijie0327 hezhijie0327 marked this pull request as ready for review February 12, 2025 12:26
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 12, 2025
Copy link
Contributor

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

有一个唯一的问题。Model List 那个导入最好是在 model() 拉取方法中异步获取。

const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');

原因是后续随着 provider 数量增加,这部分的数据体积也会很大,这部分要做成按需导入的形式会比较好,未来能降低产物的体积

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Feb 13, 2025
@hezhijie0327
Copy link
Contributor Author

有一个唯一的问题。Model List 那个导入最好是在 model() 拉取方法中异步获取。

改好了

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


There is one only problem. Model List The import is best obtained asynchronously in the model() pull method.

Improved

Copy link
Contributor

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

LGTM.

留个思考,目前每个 provider 都几乎等于重写了 models 方法,后续有没有可能把 models 的拉取方法弄一版内置到 openaiFactory 里,然后在外部用配置式的方式完成细节调整?

Copy link

vercel bot commented Feb 14, 2025

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

Name Status Preview Comments Updated (UTC)
lobe-chat-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2025 2:41am

@arvinxx arvinxx changed the title ♻️ refactor: refactor model fetch behavior ♻️ refactor: improve model fetch behavior Feb 14, 2025
@arvinxx arvinxx merged commit 4c2aaf6 into lobehub:main Feb 14, 2025
10 of 12 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @hezhijie0327 ❤️

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 Feb 14, 2025
### [Version&nbsp;1.53.12](v1.53.11...v1.53.12)
<sup>Released on **2025-02-14**</sup>

#### ♻ Code Refactoring

- **misc**: Improve model fetch behavior.

<br/>

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

#### Code refactoring

* **misc**: Improve model fetch behavior, closes [#6055](#6055) ([4c2aaf6](4c2aaf6))

</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.53.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

AirboZH pushed a commit to yuanze-dev/lobe-chat that referenced this pull request Feb 14, 2025
* ♻️ refactor: refactor model fetch behavior

* 🐛 fix: fix gemini thinking model set functionCall tag

* 🐛 fix: fix Spark fc tag missing

* ✨ feat: add model fetch support for Tencent Cloud

* ♻️ refactor: refactor import `LOBE_DEFAULT_MODEL_LIST` with async method - Part 1

* ♻️ refactor: refactor import LOBE_DEFAULT_MODEL_LIST with async method - Part 2

* 🔨 chore: add vision, reasoning, fc default value

* ♻️ refactor: improve knownModel matching

* 🐛 fix: fix ci error
AirboZH pushed a commit to yuanze-dev/lobe-chat that referenced this pull request Feb 14, 2025
### [Version&nbsp;1.53.12](lobehub/lobe-chat@v1.53.11...v1.53.12)
<sup>Released on **2025-02-14**</sup>

#### ♻ Code Refactoring

- **misc**: Improve model fetch behavior.

<br/>

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

#### Code refactoring

* **misc**: Improve model fetch behavior, closes [lobehub#6055](lobehub#6055) ([4c2aaf6](lobehub@4c2aaf6))

</details>

<div align="right">

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

</div>
@hezhijie0327 hezhijie0327 deleted the models branch February 14, 2025 07:07
github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Feb 14, 2025
### [Version&nbsp;1.95.5](v1.95.4...v1.95.5)
<sup>Released on **2025-02-14**</sup>

#### ♻ Code Refactoring

- **misc**: Improve model fetch behavior.

<br/>

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

#### Code refactoring

* **misc**: Improve model fetch behavior, closes [lobehub#6055](https://github.com/bentwnghk/lobe-chat/issues/6055) ([4c2aaf6](4c2aaf6))

</details>

<div align="right">

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

</div>
@Thinker-Joe
Copy link

Perfect,点个大大的赞,成功修复问题了

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Perfect, please give me a big thumbs up and successfully fixed the problem

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.

[Bug] 社区版的所有Claude模型都不支持视觉识别
4 participants