- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.9k
feat: Centralized Request Processing middleware #3847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ✅ Deploy Preview for localai ready!
 To edit notification comments on pull requests, go to your Netlify site configuration. | 
ed7f03e    to
    7dfddc7      
    Compare
  
    13a7411    to
    85ed9ae      
    Compare
  
    | 
 | 
df37c12    to
    d08311f      
    Compare
  
    | @mudler Ready for review, now with working VAD test. | 
Signed-off-by: Dave Lee <[email protected]>
6050d80    to
    c1f30ba      
    Compare
  
    | 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 ! | 
| @@ -0,0 +1,8 @@ | |||
| backend: silero-vad | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| config.LoadOptionF16(options.F16), | ||
| config.ModelPath(options.ModelPath), | ||
| ) | ||
| cfg, err := application.BackendLoader().LoadBackendConfigFileByNameDefaultOptions(m, options) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
        
          
                core/backend/tokenize.go
              
                Outdated
          
        
      | opts := ModelOptions(backendConfig, appConfig) | ||
|  | ||
| inferenceModel, err = loader.Load(opts...) | ||
| // TODO: looks weird, seems to be a correct merge? | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks going behind in history. this switch isn't needed anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have corrected this :)
| return cfg, nil | ||
| } | ||
|  | ||
| func (bcl *BackendConfigLoader) LoadBackendConfigFileByNameDefaultOptions(modelName string, appConfig *ApplicationConfig) (*BackendConfig, error) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup really appreciated!
| } | ||
|  | ||
| if (u & FLAG_VAD) == FLAG_VAD { | ||
| if c.Backend != "silero-vad" { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for later: at some point we should think about having these constants defined to be re-usable. There are some repetitions as well in the model initializer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - probably worth doing that as followup if you're OK with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely, was just a reminder/note
Signed-off-by: Dave Lee <[email protected]>
Signed-off-by: Dave Lee <[email protected]>
Signed-off-by: Ettore Di Giacinto <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems quite huge as a text golang file - can we maybe add the converted file to the repo in the fixture folder?
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.goLOCALAI_SINGLE_ACTIVE_BACKEND=truehelps with a memory usage issue!