simonpcouch / pal

LLM assistants for R
https://simonpcouch.github.io/pal/
Other
5 stars 3 forks source link

stream responses in addin #10

Closed simonpcouch closed 1 week ago

simonpcouch commented 1 week ago

hopefully no more off-by-one ๐Ÿ”ฅ๐Ÿ‘นโ˜„๏ธ๐Ÿงจ๐Ÿ‘บ

Closes #8.

simonpcouch commented 1 week ago

Here are some examples I tested with:


# a longer one -----------------------------------------------------------------
extra_grid_params <- glue::single_quote(extra_grid_params)
extra_grid_params <- glue::glue_collapse(extra_grid_params, sep = ", ")

msg <- glue::glue(
  "The provided `grid` has the following parameter columns that have ",
  "not been marked for tuning by `tune()`: {extra_grid_params}."
)

rlang::abort(msg)

# a shorter one ----------------------------------------------------------------
some_thing <- paste0(some_other_thing, collapse = ", ")
stop(glue::glue("Here is {some_thing}."))

# indented inside of a function ------------------------------------------------
augment.data.frame <- function(x, data, ...) {
  # only an issue when there's no trailing newline
  stop(paste("augment's first argument should be a model, not a data.frame"))
}

# one that will be made to stretch across several lines ------------------------
stop("This is a message that is a super duper uber gloober wooper shoober duper foober pooper long.")

# some stuff after to make sure it doesn't get deleted

When testing, try highlighting both the whole final line and just the portion of the final line with the message to ensure there aren't off-by-ones due to trailing newlines.