Skip to content

Commit

Permalink
only pull gguf model if already exists (ollama#1817)
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceMacD authored Jan 5, 2024
1 parent 9c2941e commit 3a9f447
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,19 @@ func RunHandler(cmd *cobra.Command, args []string) error {
}
case err != nil:
return err
}

if model.Details.Format != "gguf" {
// pull and retry to see if the model has been updated
parts := strings.Split(name, string(os.PathSeparator))
if len(parts) == 1 {
// this is a library model, log some info
fmt.Fprintln(os.Stderr, "This model is no longer compatible with Ollama. Pulling a new version...")
}
if err := PullHandler(cmd, []string{name}); err != nil {
fmt.Printf("Error: %s\n", err)
return fmt.Errorf("unsupported model, please update this model to gguf format") // relay the original error
default:
// the model was found, check if it is in the correct format
if model.Details.Format != "" && model.Details.Format != "gguf" {
// pull and retry to see if the model has been updated
parts := strings.Split(name, string(os.PathSeparator))
if len(parts) == 1 {
// this is a library model, log some info
fmt.Fprintln(os.Stderr, "This model is no longer compatible with Ollama. Pulling a new version...")
}
if err := PullHandler(cmd, []string{name}); err != nil {
fmt.Printf("Error: %s\n", err)
return fmt.Errorf("unsupported model, please update this model to gguf format") // relay the original error
}
}
}

Expand Down

0 comments on commit 3a9f447

Please sign in to comment.