diff --git a/.Rbuildignore b/.Rbuildignore index ddcc310..12b10be 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,5 @@ ^CRAN-SUBMISSION$ ^doc$ ^Meta$ +^[.]?air[.]toml$ +^\.vscode$ diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3ac34c8 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,126 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at codeofconduct@posit.co. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion]. + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at . + +[homepage]: https://www.contributor-covenant.org diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..344f76e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "Posit.air-vscode" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a9f69fe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "[r]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "Posit.air-vscode" + }, + "[quarto]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "quarto.quarto" + } +} diff --git a/DESCRIPTION b/DESCRIPTION index 347bd01..f212bc7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,46 +2,49 @@ Package: chattr Title: Interact with Large Language Models in 'RStudio' Version: 0.3.1 Authors@R: c( - person("Edgar", "Ruiz", , "edgar@posit.co", role = c("aut", "cre")), - person(given = "Posit Software, PBC", role = c("cph", "fnd")) + person("Edgar", "Ruiz", , "edgar@posit.co", role = c("aut", "cre")), + person("Posit Software, PBC", role = c("cph", "fnd"), + comment = c(ROR = "03wc8by49")) ) -Description: Enables user interactivity with large-language models ('LLM') inside - the 'RStudio' integrated development environment (IDE). The user can - interact with the model using the 'shiny' app included in this package, or - directly in the 'R' console. It comes with back-ends for 'OpenAI', 'GitHub' - 'Copilot', and 'LlamaGPT'. -URL: https://github.com/mlverse/chattr, - https://mlverse.github.io/chattr/ -BugReports: https://github.com/mlverse/chattr/issues +Description: Enables user interactivity with large-language models ('LLM') + inside the 'RStudio' integrated development environment (IDE). The + user can interact with the model using the 'shiny' app included in + this package, or directly in the 'R' console. It comes with back-ends + for 'OpenAI', 'GitHub' 'Copilot', and 'LlamaGPT'. License: MIT + file LICENSE -Encoding: UTF-8 -Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +URL: https://github.com/mlverse/chattr, https://mlverse.github.io/chattr/ +BugReports: https://github.com/mlverse/chattr/issues +Depends: + R (>= 4.1) Imports: - rstudioapi, - lifecycle, - processx, + bslib, + cli, + clipr, config, + coro, ellmer (>= 0.3.0), + fs, + glue, + httr2 (>= 1.1.0), + lifecycle, + processx, purrr, rlang, - bslib, + rstudioapi, shiny, - clipr, - httr2 (>= 1.1.0), - yaml, - glue, - coro, - cli, - fs -Depends: - R (>= 2.10) + yaml Suggests: covr, knitr, + withr, rmarkdown, - testthat (>= 3.0.0), - shinytest2, - withr + shinytest2, + testthat (>= 3.0.0) +VignetteBuilder: + knitr +Config/Needs/website: tidyverse/tidytemplate Config/testthat/edition: 3 -VignetteBuilder: knitr +Config/usethis/last-upkeep: 2025-11-11 +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.3 diff --git a/NAMESPACE b/NAMESPACE index 42f3e40..1dfc662 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,11 +24,13 @@ import(fs) import(glue) import(httr2) import(processx) +import(rlang) import(rstudioapi) import(shiny) import(yaml) importFrom(bslib,bs_theme) importFrom(clipr,write_clip) +importFrom(glue,glue) importFrom(grDevices,rgb) importFrom(lifecycle,deprecated) importFrom(purrr,discard) diff --git a/R/app-server.R b/R/app-server.R index e6ec7df..e5184d0 100644 --- a/R/app-server.R +++ b/R/app-server.R @@ -131,7 +131,7 @@ app_add_assistant <- function(content, input) { walk( order(seq_along(ch), decreasing = TRUE), - ~ { + \(.x) { len <- len_hist + .x content <- ch[[.x]]$content prep_content <- prep_entry(content, !ui_current_markdown()) @@ -140,8 +140,10 @@ app_add_assistant <- function(content, input) { insertUI( selector = "#tabs", where = "afterEnd", - ui = app_ui_entry(content, is_code, len) %>% - tagAppendAttributes(style = "width: 100%;") + ui = tagAppendAttributes( + app_ui_entry(content, is_code, len), + style = "width: 100%;" + ) ) if (is_code) { observeEvent(input[[paste0("copy", len)]], { @@ -162,7 +164,7 @@ app_add_assistant <- function(content, input) { ch_env$content_hist <- c( ch_env$content_hist, - map_chr(ch, ~ .x$content) + map_chr(ch, \(.x) .x$content) ) } @@ -181,7 +183,7 @@ prep_entry <- function(x, remove) { app_split_content <- function(content) { split_content <- unlist(strsplit(content, "```")) map( - seq_along(split_content), ~ { + seq_along(split_content), \(.x) { is_code <- (.x / 2) == floor(.x / 2) content <- split_content[.x] code <- NULL diff --git a/R/app-ui.R b/R/app-ui.R index 2ac2064..4af0702 100644 --- a/R/app-ui.R +++ b/R/app-ui.R @@ -60,7 +60,7 @@ app_ui <- function() { width = "100%", resize = "none" ) - ) %>% + ) |> tagAppendAttributes(style = "width: 85%;"), column( width = 1, @@ -80,7 +80,7 @@ app_ui <- function() { uiOutput("provider"), style = paste0("font-size:9px; color:", style$color_bk, ";") ) - ) %>% + ) |> tagAppendAttributes(style = "width: 15%;"), ), style = style$ui_panel @@ -102,8 +102,8 @@ app_ui_modal <- function() { tc <- chattr_defaults(type = "chat") - prompt2 <- tc$prompt %>% - process_prompt() %>% + prompt2 <- tc$prompt |> + process_prompt() |> paste(collapse = "\n") modalDialog( @@ -135,8 +135,7 @@ app_ui_entry <- function(content, is_code, no_id) { width = 12, fluidRow( align = "right", - column(width = 10, div()) %>% - tagAppendAttributes(style = "width: 80%;"), + tagAppendAttributes(column(width = 10, div()), style = "width: 80%;"), column( width = 2, if (is_code) { @@ -149,7 +148,7 @@ app_ui_entry <- function(content, is_code, no_id) { app_ui_button("New script", "new", "plus", no_id) }, style = "padding: 0px" - ) %>% + ) |> tagAppendAttributes(style = "width: 20%;") ), fluidRow( diff --git a/R/backend-ellmer.R b/R/backend-ellmer.R index fe55d11..bb12a75 100644 --- a/R/backend-ellmer.R +++ b/R/backend-ellmer.R @@ -1,12 +1,13 @@ #' @export ch_submit.ch_ellmer <- function( - defaults, - prompt = NULL, - stream = TRUE, - prompt_build = TRUE, - preview = FALSE, - shiny = FALSE, - ...) { + defaults, + prompt = NULL, + stream = TRUE, + prompt_build = TRUE, + preview = FALSE, + shiny = FALSE, + ... +) { if (preview) { return(prompt) } @@ -80,7 +81,7 @@ ch_ellmer_history <- function(x) { ) { new_history <- map( x, - ~ { + \(.x) { ellmer::Turn( role = .x$role, contents = list(ellmer::ContentText(.x$content)), diff --git a/R/backend-ollama.R b/R/backend-ollama.R index 4d9bdc5..a1860d4 100644 --- a/R/backend-ollama.R +++ b/R/backend-ollama.R @@ -3,11 +3,13 @@ ch_ollama_check <- function() { "http://localhost:11434", "http://127.0.0.1:11434" ) - check_urls <- urls %>% - map(~ request(.x) %>% - req_perform() %>% - try(silent = TRUE)) %>% - map_lgl(~ { + check_urls <- urls |> + map(\(.x){ + request(.x) |> + req_perform() |> + try(silent = TRUE) + }) |> + map_lgl(\(.x) { if (inherits(.x, "httr2_response")) { if (.x$status_code == 200) { TRUE diff --git a/R/ch-context.R b/R/ch-context.R index 0e3c6a4..e08687f 100644 --- a/R/ch-context.R +++ b/R/ch-context.R @@ -1,7 +1,8 @@ ch_context_data_files <- function( - max = NULL, - file_types = c("csv", "parquet", "xls", "xlsx", "txt"), - path = ".") { + max = NULL, + file_types = c("csv", "parquet", "xls", "xlsx", "txt"), + path = "." +) { if (is.null(max)) { files <- get_files( path = path, @@ -39,14 +40,15 @@ ch_context_data_files <- function( } get_files <- function(path, file_types, recurse) { - x <- file_types %>% - map(~ dir_ls( + x <- file_types |> + map(\(.x) + dir_ls( path = path, type = "file", glob = paste0("*.", .x), recurse = recurse - )) %>% - reduce(c) %>% + )) |> + reduce(c) |> try(silent = TRUE) if (inherits(x, "try-error")) { @@ -57,9 +59,9 @@ get_files <- function(path, file_types, recurse) { } ch_context_data_frames <- function(max = NULL) { - dfs <- ls(envir = .GlobalEnv) %>% - map(~ mget(.x, .GlobalEnv)) %>% - keep(~ inherits(.x[[1]], "data.frame")) + dfs <- ls(envir = .GlobalEnv) |> + map(\(.x) mget(.x, .GlobalEnv)) |> + keep(\(.x) inherits(.x[[1]], "data.frame")) if (length(dfs) > 0) { if (!is.null(max)) { @@ -67,17 +69,17 @@ ch_context_data_frames <- function(max = NULL) { dfs <- dfs[!is.na(dfs)] } - dfs <- dfs %>% - discard(is.null) %>% - discard(is.na) %>% - map(~ { - fields <- .x[[1]] %>% - imap(~ paste0(.y)) %>% + dfs <- dfs |> + discard(is.null) |> + discard(is.na) |> + map(\(.x) { + fields <- .x[[1]] |> + imap(\(.x, .y) paste0(.y)) |> paste0(collapse = ", ") paste0("|-- ", names(.x), " (", fields, ")") }) - data_frames <- dfs %>% + data_frames <- dfs |> paste0(collapse = " \n") if (length(dfs) > 0) { diff --git a/R/chattr-defaults-save.R b/R/chattr-defaults-save.R index 7e02d43..8f480bb 100644 --- a/R/chattr-defaults-save.R +++ b/R/chattr-defaults-save.R @@ -21,10 +21,10 @@ chattr_defaults_save <- function(path = "chattr.yml", other <- map( td[td_other], - ~ { + \(.x) { match <- imap_lgl( .x, - ~ { + \(.x, .y) { y <- td_default[[.y]] x <- .x if (!is.null(y) && !is.null(x)) { @@ -35,7 +35,7 @@ chattr_defaults_save <- function(path = "chattr.yml", } x != y } else { - ma <- imap_lgl(x, ~ .x == y[[.y]]) + ma <- imap_lgl(x, \(.x, .y) .x == y[[.y]]) !all(ma) } } else { @@ -45,8 +45,8 @@ chattr_defaults_save <- function(path = "chattr.yml", ) .x[match] } - ) %>% - keep(~ length(.x) > 0) + ) |> + keep(\(.x) length(.x) > 0) td_all <- list(default = td_default) if (length(other) > 0) td_all <- c(td_all, other) diff --git a/R/chattr-defaults.R b/R/chattr-defaults.R index 14ece77..4f7d787 100644 --- a/R/chattr-defaults.R +++ b/R/chattr-defaults.R @@ -181,7 +181,7 @@ print.ch_model <- function(x, ...) { prompt <- gsub("\\{", "\\{\\{", x$prompt) prompt <- gsub("\\}", "\\}\\}", prompt) - walk(prompt, ~ cli_li("{.val2 {.x}}")) + walk(prompt, \(.x) cli_li("{.val2 {.x}}")) cli_colors() cli_h3("Model") print_provider(x) @@ -190,7 +190,7 @@ print.ch_model <- function(x, ...) { cli_h3("Model Arguments:") iwalk( x$model_arguments, - ~ cli_li("{.y}: {.val1 {.x}}") + \(.x, .y) cli_li("{.y}: {.val1 {.x}}") ) } cli_h3("Context:") @@ -251,7 +251,7 @@ process_prompt <- function(x) { if (is.null(x)) { return(x) } - x %>% - map(~ glue(.x)) %>% + x |> + map(\(.x) glue(.x)) |> reduce(c) } diff --git a/R/chattr-package.R b/R/chattr-package.R index 696b372..0cce427 100644 --- a/R/chattr-package.R +++ b/R/chattr-package.R @@ -16,6 +16,8 @@ #' @import fs ## usethis namespace: start +#' @import rlang +#' @importFrom glue glue #' @importFrom lifecycle deprecated ## usethis namespace: end ch_env <- new.env() diff --git a/R/chattr-test.R b/R/chattr-test.R index 7b4668f..9e0a13b 100644 --- a/R/chattr-test.R +++ b/R/chattr-test.R @@ -43,13 +43,14 @@ ch_test.ch_model <- function(defaults = NULL) { #' @export ch_submit.ch_test_backend <- function( - defaults, - prompt = NULL, - stream = TRUE, - prompt_build = TRUE, - preview = FALSE, - shiny = FALSE, - ...) { + defaults, + prompt = NULL, + stream = TRUE, + prompt_build = TRUE, + preview = FALSE, + shiny = FALSE, + ... +) { if (stream) { ch_app_status("busy") for (i in seq_len(nchar(prompt))) { diff --git a/R/chattr-use.R b/R/chattr-use.R index 299861d..91b2b43 100644 --- a/R/chattr-use.R +++ b/R/chattr-use.R @@ -72,42 +72,42 @@ chattr_use <- function(x = NULL, ...) { } ch_get_ymls <- function(menu = TRUE, x = NULL) { - files <- package_file("configs") %>% - dir_ls() %>% - discard(~ grepl("ellmer.yml", .x)) + files <- package_file("configs") |> + dir_ls() |> + discard(\(.x) grepl("ellmer.yml", .x)) - prep_files <- files %>% - map(read_yaml) %>% - imap(~ { - name <- .y %>% - path_file() %>% + prep_files <- files |> + map(read_yaml) |> + imap(\(.x, .y) { + name <- .y |> + path_file() |> path_ext_remove() model <- .x$default[["model"]] %||% "" provider <- .x$default[["provider"]] %||% "" c(provider, model, name) - }) %>% + }) |> set_names( - files %>% - path_file() %>% + files |> + path_file() |> path_ext_remove() ) gpt_token <- ch_openai_token(fail = FALSE) if (is.null(gpt_token)) { - prep_files <- prep_files %>% - discard(~ grepl("OpenAI", .x[1])) + prep_files <- prep_files |> + discard(\(.x) grepl("OpenAI", .x[1])) } dbrx_token <- ch_databricks_token(fail = FALSE) dbrx_host <- ch_databricks_host(fail = FALSE) if (is.null(dbrx_token) | is.null(dbrx_host)) { - prep_files <- prep_files %>% - discard(~ grepl("Databricks", .x[1])) + prep_files <- prep_files |> + discard(\(.x) grepl("Databricks", .x[1])) } if (!ch_ollama_check()) { - prep_files <- prep_files %>% - discard(~ grepl("Ollama", .x[1])) + prep_files <- prep_files |> + discard(\(.x) grepl("Ollama", .x[1])) } if (length(prep_files) == 0) { @@ -119,16 +119,16 @@ ch_get_ymls <- function(menu = TRUE, x = NULL) { orig_names <- names(prep_files) - prep_files <- prep_files %>% - set_names(seq_along(prep_files)) %>% - imap(~ { + prep_files <- prep_files |> + set_names(seq_along(prep_files)) |> + imap(\(.x, .y) { if (.x[[1]] == .x[[2]] | is.logical(.x[[2]])) { x <- .x[[1]] } else { x <- paste(.x[[1]], "-", .x[[2]]) } paste0(x, " (", .x[[3]], ") \n") - }) %>% + }) |> set_names(orig_names) if (menu) { @@ -152,7 +152,7 @@ use_switch <- function(..., .file, .silent = FALSE) { ) walk( ch_env$valid_uis, - ~ { + \(.x) { chattr_defaults( type = .x, yaml_file = .file @@ -180,8 +180,8 @@ ch_package_file <- function(x) { } configs <- dir_ls(conf_folder) configs <- configs[path_file(configs) != "ellmer.yml"] - configs <- configs %>% - path_file() %>% + configs <- configs |> + path_file() |> path_ext_remove() msg <- glue("'{x}' is not acceptable, it may be deprecated. Valid values are:") abort(c(msg, configs), call = NULL) diff --git a/R/utils.R b/R/utils.R index 261679b..f81b895 100644 --- a/R/utils.R +++ b/R/utils.R @@ -35,7 +35,7 @@ print.ch_request <- function(x, ...) { if (!is.null(x$defaults$model_arguments)) { iwalk( x$defaults$model_arguments, - ~ { + \(.x, .y) { cli_div(theme = cli_colors()) cli_li("{.y}: {.val1 {.x}}") } @@ -47,13 +47,13 @@ print.ch_request <- function(x, ...) { print_history <- function(x) { cli_colors() cli_h3("Prompt:") - walk(x, ~ { + walk(x, \(.x) { x <- .x x_named <- is_named(x) - iwalk(x, ~ { + iwalk(x, \(.x, .y) { if (.y %in% c("role", "content")) { - split_x <- .x %>% - strsplit("\n") %>% + split_x <- .x |> + strsplit("\n") |> unlist() if (x_named) { title <- glue("{.y}:") @@ -64,7 +64,7 @@ print_history <- function(x) { cli_text("{title} {.val2 {.x}}") } else { cli_text("{title}") - walk(split_x, ~ cli_bullets("{.val2 {.x}}")) + walk(split_x, \(.x) cli_bullets("{.val2 {.x}}")) } } }) diff --git a/_pkgdown.yml b/_pkgdown.yml index 714ebf5..2e0f133 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -2,10 +2,8 @@ url: https://mlverse.github.io/chattr/ template: bootstrap: 5 reference: - - title: Start Up - contents: - - chattr_use + contents: chattr_use - title: Main functions contents: - chattr_app diff --git a/air.toml b/air.toml new file mode 100644 index 0000000..e69de29 diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg index 4baaee0..b61c57c 100644 --- a/man/figures/lifecycle-deprecated.svg +++ b/man/figures/lifecycle-deprecated.svg @@ -1 +1,21 @@ -lifecyclelifecycledeprecateddeprecated \ No newline at end of file + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg index d1d060e..5d88fc2 100644 --- a/man/figures/lifecycle-experimental.svg +++ b/man/figures/lifecycle-experimental.svg @@ -1 +1,21 @@ -lifecyclelifecycleexperimentalexperimental \ No newline at end of file + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg index e015dc8..9bf21e7 100644 --- a/man/figures/lifecycle-stable.svg +++ b/man/figures/lifecycle-stable.svg @@ -1 +1,29 @@ -lifecyclelifecyclestablestable \ No newline at end of file + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg index 75f24f5..db8d757 100644 --- a/man/figures/lifecycle-superseded.svg +++ b/man/figures/lifecycle-superseded.svg @@ -1 +1,21 @@ - lifecyclelifecyclesupersededsuperseded \ No newline at end of file + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/figures/logo.png b/man/figures/logo.png index df8970a..eba815f 100644 Binary files a/man/figures/logo.png and b/man/figures/logo.png differ diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png index 8bcc34b..7745d10 100644 Binary files a/pkgdown/favicon/apple-touch-icon.png and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-96x96.png b/pkgdown/favicon/favicon-96x96.png new file mode 100644 index 0000000..e5bef04 Binary files /dev/null and b/pkgdown/favicon/favicon-96x96.png differ diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico index 2c1406e..1d6ca19 100644 Binary files a/pkgdown/favicon/favicon.ico and b/pkgdown/favicon/favicon.ico differ diff --git a/pkgdown/favicon/favicon.svg b/pkgdown/favicon/favicon.svg new file mode 100644 index 0000000..feeba40 --- /dev/null +++ b/pkgdown/favicon/favicon.svg @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/pkgdown/favicon/site.webmanifest b/pkgdown/favicon/site.webmanifest new file mode 100644 index 0000000..4ebda26 --- /dev/null +++ b/pkgdown/favicon/site.webmanifest @@ -0,0 +1,21 @@ +{ + "name": "", + "short_name": "", + "icons": [ + { + "src": "/web-app-manifest-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "/web-app-manifest-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} \ No newline at end of file diff --git a/pkgdown/favicon/web-app-manifest-192x192.png b/pkgdown/favicon/web-app-manifest-192x192.png new file mode 100644 index 0000000..b6ef0e2 Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-192x192.png differ diff --git a/pkgdown/favicon/web-app-manifest-512x512.png b/pkgdown/favicon/web-app-manifest-512x512.png new file mode 100644 index 0000000..8605836 Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-512x512.png differ diff --git a/tests/testthat.R b/tests/testthat.R index 71e0b28..2ed8a45 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -3,11 +3,10 @@ # # Where should you do additional test configuration? # Learn more about the roles of various files in: -# * https://r-pkgs.org/tests.html -# * https://testthat.r-lib.org/reference/test_package.html#special-files +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html library(testthat) library(chattr) -library(shiny) test_check("chattr") diff --git a/tests/testthat/_snaps/backend-openai.md b/tests/testthat/_snaps/backend-openai.md index 0779c44..22f6580 100644 --- a/tests/testthat/_snaps/backend-openai.md +++ b/tests/testthat/_snaps/backend-openai.md @@ -1,8 +1,12 @@ # Missing token returns error - No token found - - Add your key to the "OPENAI_API_KEY" environment variable - - or - Add "openai-api-key" to a `config` YAML file + Code + ch_openai_token(d) + Condition + Error in `ch_openai_token()`: + ! No token found + - Add your key to the "OPENAI_API_KEY" environment variable + - or - Add "openai-api-key" to a `config` YAML file # Init messages work diff --git a/tests/testthat/_snaps/ch_context.md b/tests/testthat/_snaps/ch_context.md index 67731e1..f77213c 100644 --- a/tests/testthat/_snaps/ch_context.md +++ b/tests/testthat/_snaps/ch_context.md @@ -1,7 +1,7 @@ # Data frames context Code - . + cat(ch_context_data_frames()) Output Data frames currently in R memory (and columns): |-- iris (Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species) @@ -10,7 +10,7 @@ --- Code - . + cat(ch_context_data_frames(max = 1)) Output Data frames currently in R memory (and columns): |-- iris (Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species) diff --git a/tests/testthat/_snaps/chattr-use.md b/tests/testthat/_snaps/chattr-use.md index 28258d9..a06bc39 100644 --- a/tests/testthat/_snaps/chattr-use.md +++ b/tests/testthat/_snaps/chattr-use.md @@ -14,19 +14,27 @@ # If all missing show error - No model setup found. Please use `?chattr_use` to get started + Code + ch_get_ymls(menu = FALSE) + Condition + Error: + ! No model setup found. Please use `?chattr_use` to get started # Invalid label returns expected error - 'notexists' is not acceptable, it may be deprecated. Valid values are: - * databricks-dbrx - * databricks-meta-llama31-70b - * databricks-mixtral8x7b - * gpt41-mini - * gpt41-nano - * gpt41 - * gpt4o - * ollama + Code + ch_package_file("notexists") + Condition + Error: + ! 'notexists' is not acceptable, it may be deprecated. Valid values are: + * databricks-dbrx + * databricks-meta-llama31-70b + * databricks-mixtral8x7b + * gpt41-mini + * gpt41-nano + * gpt41 + * gpt4o + * ollama # Uses ellmer object diff --git a/tests/testthat/helper-utils.R b/tests/testthat/helper-utils.R index c2ede9f..2341437 100644 --- a/tests/testthat/helper-utils.R +++ b/tests/testthat/helper-utils.R @@ -1,5 +1,5 @@ test_simulate_model <- function(file, type = "console") { - defaults <- package_file("configs", file) %>% + defaults <- package_file("configs", file) |> yaml::read_yaml() as_ch_model(defaults$default, type) } diff --git a/tests/testthat/test-app-server.R b/tests/testthat/test-app-server.R index 40eb8f3..ee901e8 100644 --- a/tests/testthat/test-app-server.R +++ b/tests/testthat/test-app-server.R @@ -12,16 +12,6 @@ test_that("Testing the function directly", { session$setInputs(saved = TRUE) }) ) - expect_null( - shiny::testServer(app_server, { - #session$setInputs(open = TRUE) - }) - ) - expect_null( - shiny::testServer(app_server, { - session$setInputs(save = TRUE) - }) - ) }) }) diff --git a/tests/testthat/test-backend-openai.R b/tests/testthat/test-backend-openai.R index 942806e..070d49e 100644 --- a/tests/testthat/test-backend-openai.R +++ b/tests/testthat/test-backend-openai.R @@ -1,7 +1,7 @@ test_that("Missing token returns error", { withr::with_envvar( new = c("OPENAI_API_KEY" = NA), - expect_snapshot_error(ch_openai_token(d)) + expect_snapshot(ch_openai_token(d), error = TRUE) ) }) diff --git a/tests/testthat/test-ch_context.R b/tests/testthat/test-ch_context.R index 35613a1..868ca34 100644 --- a/tests/testthat/test-ch_context.R +++ b/tests/testthat/test-ch_context.R @@ -1,10 +1,10 @@ test_that("Data frames context", { - ch_context_data_frames() %>% - cat() %>% + ch_context_data_frames() |> + cat() |> expect_snapshot() - ch_context_data_frames(max = 1) %>% - cat() %>% + ch_context_data_frames(max = 1) |> + cat() |> expect_snapshot() }) diff --git a/tests/testthat/test-chattr-use.R b/tests/testthat/test-chattr-use.R index c743dce..a62dc58 100644 --- a/tests/testthat/test-chattr-use.R +++ b/tests/testthat/test-chattr-use.R @@ -44,7 +44,7 @@ test_that("If all missing show error", { "DATABRICKS_HOST" = NA ), { - expect_snapshot_error(ch_get_ymls(menu = FALSE)) + expect_snapshot(ch_get_ymls(menu = FALSE), error = TRUE) } ) }) @@ -72,7 +72,7 @@ test_that("Menu works", { test_that("Invalid label returns expected error", { - expect_snapshot_error(ch_package_file("notexists")) + expect_snapshot(ch_package_file("notexists"), error = TRUE) }) test_that("Uses ellmer object", { diff --git a/vignettes/other-interfaces.Rmd b/vignettes/other-interfaces.Rmd index bb547d1..7ef7be7 100644 --- a/vignettes/other-interfaces.Rmd +++ b/vignettes/other-interfaces.Rmd @@ -7,7 +7,8 @@ vignette: > %\VignetteEncoding{UTF-8} --- -```{r, include = FALSE} +```{r} +#| include: false knitr::opts_chunk$set( collapse = TRUE, comment = "#>" diff --git a/vignettes/prompt_defaults.Rmd b/vignettes/prompt_defaults.Rmd index 8039f4f..41ba1ec 100644 --- a/vignettes/prompt_defaults.Rmd +++ b/vignettes/prompt_defaults.Rmd @@ -7,7 +7,8 @@ vignette: > %\VignetteEncoding{UTF-8} --- -```{r, include = FALSE} +```{r} +#| include: false knitr::opts_chunk$set( collapse = TRUE, comment = "#>"