Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion commands/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func newRemoveCmd(desktopClient *desktop.Client) *cobra.Command {
var force bool

c := &cobra.Command{
Use: "rm [MODEL...]",
Short: "Remove models downloaded from Docker Hub",
Expand All @@ -23,7 +25,7 @@ func newRemoveCmd(desktopClient *desktop.Client) *cobra.Command {
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
response, err := desktopClient.Remove(args)
response, err := desktopClient.Remove(args, force)
if response != "" {
cmd.Println(response)
}
Expand All @@ -35,5 +37,7 @@ func newRemoveCmd(desktopClient *desktop.Client) *cobra.Command {
},
ValidArgsFunction: completion.ModelNames(desktopClient, -1),
}

c.Flags().BoolVarP(&force, "force", "f", false, "Forcefully remove the model")
return c
}
11 changes: 9 additions & 2 deletions desktop/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"net/http"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -390,7 +391,7 @@ func (c *Client) Chat(model, prompt string) error {
return nil
}

func (c *Client) Remove(models []string) (string, error) {
func (c *Client) Remove(models []string, force bool) (string, error) {
modelRemoved := ""
for _, model := range models {
// Check if not a model ID passed as parameter.
Expand All @@ -400,7 +401,13 @@ func (c *Client) Remove(models []string) (string, error) {
}
}

removePath := inference.ModelsPrefix + "/" + model
// Construct the URL with query parameters
removePath := fmt.Sprintf("%s/%s?force=%s",
inference.ModelsPrefix,
model,
strconv.FormatBool(force),
)

resp, err := c.doRequest(http.MethodDelete, removePath, nil)
if err != nil {
return modelRemoved, c.handleQueryError(err, removePath)
Expand Down