LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

OUTDATED: `http/middleware` directory, request middleware centralization, model list filtering

Open dave-gray101 opened this issue 7 months ago • 1 comments

Middleware Refactor

This PR has a few goals, but is scoped strictly to avoid major functional changes:

  • Introduces core/http/middleware to hold http related code that's not endpoint specific -- metrics.go is pure file movement to live with the others. -- auth.go handles the creation of keyauth configuration data and contains the validation function. --- actual implementation of auth has been temporarily moved to my keyauth v2 backport - I submitted and merged the required feature changes to fiber upstream, but v3 is not quite yet stable enough for us to target... hence this backport. -- request.go contains a series of composable middlewares that are able to either extract user-provided information from the fiber context, or provide programmer suggested defaults. Later on, endpoints can retrieve these from fiber context Locals.
  • Plumbs through Application container to endpoints as needed. This is subject to future change as more services are created
  • Overhaul of ListModels and BackendConfig to add filtering capabilities, currently mostly used for setting defaults, but also drives some UI elements now. -- Currently reserved for the next PR but may end up here - plan to add a checkbox to UI to determine if "loose files" should appear in the dropdowns or not.

dave-gray101 avatar Jul 02 '24 15:07 dave-gray101