It refactors most frontend API calls into a couple of idiomatic helpers wherever possible. As discussed in #2227's comments, while the helpers are generic over the expected API return type, they're purposefully loose for the time being; users may opt-in to doing do...Request<T>.
Notes/Code Review
The main refactoring commit was done manually; I tried to be careful that the calls are equivalent to what the preimage was, but of course something could have slipped past these non-AI eyeballs.
Testing
Since there are no automated tests for the backend, I did some manual testing.
I tested that the app seems to work (signup, signin, ollama chat, llava "what's in this image", tagging, etc.).
Changelog Entry
Changed
Refactored frontend API calls and error handling to reduce repetition.
🔄 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/2233
**Author:** [@akx](https://github.com/akx)
**Created:** 5/13/2024
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `api-helpers`
---
### 📝 Commits (2)
- [`1746712`](https://github.com/open-webui/open-webui/commit/1746712a6b341597ef8ac09ad882584829605025) feat: add API request helpers for frontend
- [`b36b940`](https://github.com/open-webui/open-webui/commit/b36b940476d6e241bf3afe7edb2c238ff8b6759c) chore: refactor APIs to use new helpers
### 📊 Changes
**16 files changed** (+416 additions, -3807 deletions)
<details>
<summary>View changed files</summary>
📝 `src/lib/apis/audio/index.ts` (+4 -76)
📝 `src/lib/apis/auths/index.ts` (+32 -381)
📝 `src/lib/apis/chats/index.ts` (+62 -631)
📝 `src/lib/apis/configs/index.ts` (+11 -107)
📝 `src/lib/apis/documents/index.ts` (+21 -185)
➕ `src/lib/apis/helpers.ts` (+96 -0)
📝 `src/lib/apis/images/index.ts` (+21 -421)
📝 `src/lib/apis/index.ts` (+23 -300)
📝 `src/lib/apis/memories/index.ts` (+7 -167)
📝 `src/lib/apis/models/index.ts` (+10 -143)
📝 `src/lib/apis/ollama/index.ts` (+58 -440)
📝 `src/lib/apis/openai/index.ts` (+5 -119)
📝 `src/lib/apis/prompts/index.ts` (+14 -151)
📝 `src/lib/apis/rag/index.ts` (+29 -415)
📝 `src/lib/apis/users/index.ts` (+18 -231)
📝 `src/lib/apis/utils/index.ts` (+5 -40)
</details>
### 📄 Description
## Pull Request Checklist
- [x] **Target branch:** Pull requests should target the `dev` branch.
- [x] **Description:** Briefly describe the changes in this pull request.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [x] **Testing:** Have you written and run sufficient tests for the changes?
- [x] **Code Review:** Have you self-reviewed your code and addressed any coding standard issues?
---
## Description
This PR is a continuation/rework of #2227.
It refactors most frontend API calls into a couple of idiomatic helpers wherever possible. As discussed in #2227's comments, while the helpers are generic over the expected API return type, they're purposefully loose for the time being; users may opt-in to doing `do...Request<T>`.
## Notes/Code Review
The main refactoring commit was done manually; I tried to be careful that the calls are equivalent to what the preimage was, but of course something could have slipped past these non-AI eyeballs.
## Testing
Since there are no automated tests for the backend, I did some manual testing.
I tested that the app seems to work (signup, signin, ollama chat, llava "what's in this image", tagging, etc.).
---
### Changelog Entry
### Changed
- Refactored frontend API calls and error handling to reduce repetition.
---
<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/2233
Author: @akx
Created: 5/13/2024
Status: ❌ Closed
Base:
dev← Head:api-helpers📝 Commits (2)
1746712feat: add API request helpers for frontendb36b940chore: refactor APIs to use new helpers📊 Changes
16 files changed (+416 additions, -3807 deletions)
View changed files
📝
src/lib/apis/audio/index.ts(+4 -76)📝
src/lib/apis/auths/index.ts(+32 -381)📝
src/lib/apis/chats/index.ts(+62 -631)📝
src/lib/apis/configs/index.ts(+11 -107)📝
src/lib/apis/documents/index.ts(+21 -185)➕
src/lib/apis/helpers.ts(+96 -0)📝
src/lib/apis/images/index.ts(+21 -421)📝
src/lib/apis/index.ts(+23 -300)📝
src/lib/apis/memories/index.ts(+7 -167)📝
src/lib/apis/models/index.ts(+10 -143)📝
src/lib/apis/ollama/index.ts(+58 -440)📝
src/lib/apis/openai/index.ts(+5 -119)📝
src/lib/apis/prompts/index.ts(+14 -151)📝
src/lib/apis/rag/index.ts(+29 -415)📝
src/lib/apis/users/index.ts(+18 -231)📝
src/lib/apis/utils/index.ts(+5 -40)📄 Description
Pull Request Checklist
devbranch.Description
This PR is a continuation/rework of #2227.
It refactors most frontend API calls into a couple of idiomatic helpers wherever possible. As discussed in #2227's comments, while the helpers are generic over the expected API return type, they're purposefully loose for the time being; users may opt-in to doing
do...Request<T>.Notes/Code Review
The main refactoring commit was done manually; I tried to be careful that the calls are equivalent to what the preimage was, but of course something could have slipped past these non-AI eyeballs.
Testing
Since there are no automated tests for the backend, I did some manual testing.
I tested that the app seems to work (signup, signin, ollama chat, llava "what's in this image", tagging, etc.).
Changelog Entry
Changed
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.