mirror of
https://github.com/ollama/ollama.git
synced 2025-07-28 18:15:29 +02:00
pr feedback
- move error check to api client pull - simplify error check in generate - return nil on any pull error
This commit is contained in:
@@ -45,22 +45,16 @@ func generate(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
remoteModel, err := getRemote(req.Model)
|
||||
if err != nil {
|
||||
// couldn't check the directory, proceed in offline mode
|
||||
_, err := os.Stat(req.Model)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()})
|
||||
return
|
||||
}
|
||||
// couldn't find the model file, try setting the model to the cache directory
|
||||
req.Model = path.Join(cacheDir(), "models", req.Model+".bin")
|
||||
}
|
||||
}
|
||||
if remoteModel != nil {
|
||||
if remoteModel, _ := getRemote(req.Model); remoteModel != nil {
|
||||
req.Model = remoteModel.FullName()
|
||||
}
|
||||
if _, err := os.Stat(req.Model); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Model = path.Join(cacheDir(), "models", req.Model+".bin")
|
||||
}
|
||||
|
||||
modelOpts := getModelOpts(req)
|
||||
modelOpts.NGPULayers = 1 // hard-code this for now
|
||||
|
Reference in New Issue
Block a user