Skip to content

Check input model and return if the model does not exist in modelPath #2314

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 10 commits into from
11 changes: 11 additions & 0 deletions core/http/ctx/fiber.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ func ModelFromContext(ctx *fiber.Ctx, loader *model.ModelLoader, modelInput stri
if bearerExists {
log.Debug().Msgf("Using model from bearer token: %s", bearer)
modelInput = bearer
//Takes precedence, then return inmediatly
return modelInput,nil
}

//if a model is specified in modelInput, and there is no bearertoken,but it doesn´t exists in the model path, return QUICKLY. https://github.com/mudler/LocalAI/issues/1076
modelExists := modelInput != "" && loader.ExistsInModelPath(modelInput)
if !modelExists{
log.Debug().Msgf("The specified model does not exist in the model PATH, returning error")
return "", fmt.Errorf("invalid model filename")
}

//A model is specified, or the first available model is picked
return modelInput, nil
}
Loading