LocalAI
LocalAI copied to clipboard
feat: Centralized Request Processing middleware
This PR reworks how our endpoints parse and process user input, in order to centralize and commonize that code as much as possible. This will drastically cut down the endpoint-specific code to a minimum.
Additionally, the VAD subsystem was untested - making it hard to validate if this changeset was safe or not. Therefore, this PR also adds both manual testing tools (via bruno) and automated testing in the AIO image.
Note to @mudler - this PR looks worse than it is - here's some reviewing notes to help
core/http/middleware/request.goshould be where you start - its the heart of the change and replacescore/http/ctx/fiber.go- configuration of defaults is now a responsibility of the route function - seems a bit weird at first, but allows endpoints to be easily reused with different defaults on different paths.
- while all the endpoint files were updated, the changes all follow the same pattern:
- A new standard header to the function was added which pulls the relevant input and config from the earlier middleware stage
- A bunch of code is deleted as its now performed earlier by those middlewares
- The functional code specific to the endpoint is unchanged except for variable references
- Specific to the AIO CI test: I was seeing very unpredictable behavior on CI versus locally reproducing this test. It turns out that setting
LOCALAI_SINGLE_ACTIVE_BACKEND=truehelps with a memory usage issue!
Deploy Preview for localai ready!
| Name | Link |
|---|---|
| Latest commit | f7dab99d80f4b2bc45d249406fa7684b651261cf |
| Latest deploy log | https://app.netlify.com/sites/localai/deploys/67a9c57513819e00084f4390 |
| Deploy Preview | https://deploy-preview-3847--localai.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
~~@mudler merged in VAD, but I don't know how to test it manually yet since it's new. Please double check that :)~~
@mudler Ready for review, now with working VAD test.
merged and squashed this again.
@mudler - Can you decide if this PR is worth maintaining? It's been stable through my testing for a while now. I'd like to either find a merge window for this, or just scrap it if you dislike the central concept. Thanks!
merged and squashed this again.
@mudler - Can you decide if this PR is worth maintaining? It's been stable through my testing for a while now. I'd like to either find a merge window for this, or just scrap it if you dislike the central concept. Thanks!
Just had a quick look now and direction looks good, however since changes are big I need to take a closer look, I'll try to do this asap in these days as now would be a good merge window !