Stop model before deletion if loaded (fixed #6957) (#7050)

This commit is contained in:
Alex Mavrogiannis
2024-10-01 15:45:43 -07:00
committed by GitHub
parent 79d3b1e2bd
commit f40bb398f6
4 changed files with 310 additions and 58 deletions

View File

@@ -680,6 +680,17 @@ func DeleteHandler(cmd *cobra.Command, args []string) error {
return err
}
// Unload the model if it's running before deletion
opts := &runOptions{
Model: args[0],
KeepAlive: &api.Duration{Duration: 0},
}
if err := loadOrUnloadModel(cmd, opts); err != nil {
if !strings.Contains(err.Error(), "not found") {
return fmt.Errorf("unable to stop existing running model \"%s\": %s", args[0], err)
}
}
for _, name := range args {
req := api.DeleteRequest{Name: name}
if err := client.Delete(cmd.Context(), &req); err != nil {