R/backend-ollama.R

Defines functions ch_ollama_check

ch_ollama_check <- function() {
  urls <- c(
    "http://localhost:11434",
    "http://127.0.0.1:11434"
  )
  check_urls <- urls %>%
    map(~ request(.x) %>%
      req_perform() %>%
      try(silent = TRUE)) %>%
    map_lgl(~ {
      if (inherits(.x, "httr2_response")) {
        if (.x$status_code == 200) {
          TRUE
        }
      } else {
        FALSE
      }
    })
  any(check_urls)
}

Try the chattr package in your browser

Any scripts or data that you put into this service are public.

chattr documentation built on June 8, 2025, 11:07 a.m.