[PR #12127] [CLOSED] perf: optimize get_models #61707

Closed
opened 2026-05-06 05:18:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/12127
Author: @yvedeng
Created: 3/27/2025
Status: Closed

Base: devHead: yvedeng/optimize-models-endpoint


📝 Commits (1)

  • b157814 perf: 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

  • 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>
GiteaMirror added the pull-request label 2026-05-06 05:18:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#61707