This PR is to improve the performance of the DB query for the get_models() function.
Given that we have N models, we can reduce the number of DB queries from 1 + N (for retrieving the users) to 1.
Changed
Refactored get_models() function
Fixed models test
Additional Information
Sorry about the previous PR. I forgot to push my latest change. Let me know if I need to change anything. Thanks!
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/12127
**Author:** [@yvedeng](https://github.com/yvedeng)
**Created:** 3/27/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `yvedeng/optimize-models-endpoint`
---
### 📝 Commits (1)
- [`b157814`](https://github.com/open-webui/open-webui/commit/b1578146ca7a4f578c0c4c2cd29243198e112e7e) perf: optimize get_models
### 📊 Changes
**4 files changed** (+10 additions, -7 deletions)
<details>
<summary>View changed files</summary>
➕ `backend/open_webui/conftest.py` (+4 -0)
📝 `backend/open_webui/models/models.py` (+3 -4)
📝 `backend/open_webui/test/apps/webui/routers/test_models.py` (+2 -2)
📝 `backend/open_webui/test/util/mock_user.py` (+1 -1)
</details>
### 📄 Description
# Changelog Entry
### Description
This PR is to improve the performance of the DB query for the get_models() function.
Given that we have N models, we can reduce the number of DB queries from 1 + N (for retrieving the users) to 1.
### Changed
- Refactored get_models() function
- Fixed models test
### Additional Information
- Sorry about the previous PR. I forgot to push my latest change. Let me know if I need to change anything. Thanks!
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/12127
Author: @yvedeng
Created: 3/27/2025
Status: ❌ Closed
Base:
dev← Head:yvedeng/optimize-models-endpoint📝 Commits (1)
b157814perf: optimize get_models📊 Changes
4 files changed (+10 additions, -7 deletions)
View changed files
➕
backend/open_webui/conftest.py(+4 -0)📝
backend/open_webui/models/models.py(+3 -4)📝
backend/open_webui/test/apps/webui/routers/test_models.py(+2 -2)📝
backend/open_webui/test/util/mock_user.py(+1 -1)📄 Description
Changelog Entry
Description
This PR is to improve the performance of the DB query for the get_models() function.
Given that we have N models, we can reduce the number of DB queries from 1 + N (for retrieving the users) to 1.
Changed
Additional Information
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.