Revert "pull model on make if not present locally"
This reverts commit 360a10ace391a674de60aa7b9b8cb65e8074027c.
This commit is contained in:
parent
8ebbd12f21
commit
12ab8f8f5f
1 changed files with 3 additions and 29 deletions
32
cmd/cmd.go
32
cmd/cmd.go
|
@ -21,7 +21,6 @@ import (
|
||||||
|
|
||||||
"github.com/jmorganca/ollama/api"
|
"github.com/jmorganca/ollama/api"
|
||||||
"github.com/jmorganca/ollama/format"
|
"github.com/jmorganca/ollama/format"
|
||||||
"github.com/jmorganca/ollama/parser"
|
|
||||||
"github.com/jmorganca/ollama/progressbar"
|
"github.com/jmorganca/ollama/progressbar"
|
||||||
"github.com/jmorganca/ollama/server"
|
"github.com/jmorganca/ollama/server"
|
||||||
)
|
)
|
||||||
|
@ -37,24 +36,6 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
var spinner *Spinner
|
var spinner *Spinner
|
||||||
|
|
||||||
// pull the model file if needed
|
|
||||||
mf, err := os.Open(filename)
|
|
||||||
defer mf.Close()
|
|
||||||
cmds, err := parser.Parse(mf)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
mf.Close()
|
|
||||||
for _, c := range cmds {
|
|
||||||
if c.Name == "model" {
|
|
||||||
// check if the model file needs to be pulled
|
|
||||||
checkPull(c.Args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
request := api.CreateRequest{Name: args[0], Path: filename}
|
request := api.CreateRequest{Name: args[0], Path: filename}
|
||||||
fn := func(resp api.CreateProgress) error {
|
fn := func(resp api.CreateProgress) error {
|
||||||
if spinner != nil {
|
if spinner != nil {
|
||||||
|
@ -78,8 +59,8 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPull(model string) error {
|
func RunHandler(cmd *cobra.Command, args []string) error {
|
||||||
mp := server.ParseModelPath(model)
|
mp := server.ParseModelPath(args[0])
|
||||||
fp, err := mp.GetManifestPath(false)
|
fp, err := mp.GetManifestPath(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -88,7 +69,7 @@ func checkPull(model string) error {
|
||||||
_, err = os.Stat(fp)
|
_, err = os.Stat(fp)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
if err := pull(model, false); err != nil {
|
if err := pull(args[0], false); err != nil {
|
||||||
var apiStatusError api.StatusError
|
var apiStatusError api.StatusError
|
||||||
if !errors.As(err, &apiStatusError) {
|
if !errors.As(err, &apiStatusError) {
|
||||||
return err
|
return err
|
||||||
|
@ -102,13 +83,6 @@ func checkPull(model string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func RunHandler(cmd *cobra.Command, args []string) error {
|
|
||||||
if err := checkPull(args[0]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return RunGenerate(cmd, args)
|
return RunGenerate(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue