squash past, centralize request middleware PR

Signed-off-by: Dave Lee <dave@gray101.com>
This commit is contained in:
Dave Lee 2025-02-05 14:14:10 -05:00
parent 28a1310890
commit c1f30ba3a9
No known key found for this signature in database
55 changed files with 481027 additions and 821 deletions

22
core/schema/request.go Normal file
View file

@ -0,0 +1,22 @@
package schema
// This file and type represent a generic request to LocalAI - as opposed to requests to LocalAI-specific endpoints, which live in localai.go
type LocalAIRequest interface {
ModelName(*string) string
}
type BasicModelRequest struct {
Model string `json:"model" yaml:"model"`
// TODO: Should this also include the following fields from the OpenAI side of the world?
// If so, changes should be made to core/http/middleware/request.go to match
// Context context.Context `json:"-"`
// Cancel context.CancelFunc `json:"-"`
}
func (bmr *BasicModelRequest) ModelName(s *string) string {
if s != nil {
bmr.Model = *s
}
return bmr.Model
}