Skip to content

Commit

Permalink
🔧 check modelfile is exists
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufcanb committed Mar 2, 2024
1 parent 2524b93 commit 16ce0f7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions explain/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ func (e *Explain) before(_ *cli.Context) error {
os.Exit(-1)
}

list, err := e.api.List(context.Background())
if err != nil {
fmt.Println(shell.Err() + " " + err.Error())
fmt.Println(shell.Err() + " Ollama connection failed. Please check your Ollama if it's running or configured correctly.")
os.Exit(-1)
}

for _, model := range list.Models {
if model.Name == e.modelfile {
return nil
}
fmt.Println(shell.Err() + " " + "tlm explain:7b model not found.\n\nPlease run `tlm deploy` to deploy tlm models first.")
os.Exit(-1)
return nil
}

return nil
}

Expand Down
16 changes: 16 additions & 0 deletions suggest/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ func (s *Suggest) before(_ *cli.Context) error {
os.Exit(-1)
}

list, err := s.api.List(context.Background())
if err != nil {
fmt.Println(shell.Err() + " " + err.Error())
fmt.Println(shell.Err() + " Ollama connection failed. Please check your Ollama if it's running or configured correctly.")
os.Exit(-1)
}

for _, model := range list.Models {
if model.Name == s.modelfile {
return nil
}
fmt.Println(shell.Err() + " " + "tlm suggest:7b model not found.\n\nPlease run `tlm deploy` to deploy tlm models first.")
os.Exit(-1)
return nil
}

return nil
}

Expand Down

0 comments on commit 16ce0f7

Please sign in to comment.