Skip to content

Commit

Permalink
adds delete_model
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Jan 4, 2024
1 parent 29d71ea commit dae5667
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(chat)
export(delete_model)
export(list_models)
export(new_chat)
export(pull_model)
Expand Down
31 changes: 27 additions & 4 deletions R/models.r
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#' Pull a new model or show more information about it
#' Pull, show and delete models
#'
#' @param model name of the model. "llama2" by default.
#' @details
#' - `pull_model()`: downloads model
#' - `show_model()`: displays information about a local model
#' - `delete_model()`: deletes local model
#'
#' @param model name of the model. Defaults to "llama2" when `NULL` (except in
#' `delete_model`).
#' @inheritParams query
#'
#' @return (invisible) a tibble with information about the model
#' @return (invisible) a tibble with information about the model (except in
#' `delete_model`)
#' @export
#'
#' @examples
Expand All @@ -20,7 +27,7 @@ pull_model <- function(model = NULL, server = NULL) {
httr2::request(server) |>
httr2::req_url_path_append("/api/pull") |>
httr2::req_body_json(list(name = model)) |>
httr2::req_perform_stream(callback = pgrs, buffer_kb = 0.1L)
httr2::req_perform_stream(callback = pgrs, buffer_kb = 0.1)

the$str_prgs <- NULL

Expand All @@ -44,6 +51,22 @@ show_model <- function(model = NULL, server = NULL) {
}


#' @rdname pull_model
#' @export
delete_model <- function(model, server = NULL) {

if (is.null(server)) server <- getOption("rollama_server", default = "http://localhost:11434")

httr2::request(server) |>
httr2::req_url_path_append("/api/delete") |>
httr2::req_method("DELETE") |>
httr2::req_body_json(list(name = model)) |>
httr2::req_perform()

cli::cli_progress_message("{cli::col_green(cli::symbol$tick)} {model} removed")
}


#' List models that are available locally.
#'
#' @return a tibble of installed models
Expand Down
17 changes: 14 additions & 3 deletions man/pull_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/query.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dae5667

Please sign in to comment.