Skip to content

Commit d7efbba

Browse files
authored
Merge pull request #149 from mlverse/upkeep-2025-11
Upkeep 2025 11
2 parents 1e947ec + da6f33c commit d7efbba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+433
-163
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
^CRAN-SUBMISSION$
1414
^doc$
1515
^Meta$
16+
^[.]?air[.]toml$
17+
^\.vscode$

.github/CODE_OF_CONDUCT.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at codeofconduct@posit.co.
63+
All complaints will be reviewed and investigated promptly and fairly.
64+
65+
All community leaders are obligated to respect the privacy and security of the
66+
reporter of any incident.
67+
68+
## Enforcement Guidelines
69+
70+
Community leaders will follow these Community Impact Guidelines in determining
71+
the consequences for any action they deem in violation of this Code of Conduct:
72+
73+
### 1. Correction
74+
75+
**Community Impact**: Use of inappropriate language or other behavior deemed
76+
unprofessional or unwelcome in the community.
77+
78+
**Consequence**: A private, written warning from community leaders, providing
79+
clarity around the nature of the violation and an explanation of why the
80+
behavior was inappropriate. A public apology may be requested.
81+
82+
### 2. Warning
83+
84+
**Community Impact**: A violation through a single incident or series of
85+
actions.
86+
87+
**Consequence**: A warning with consequences for continued behavior. No
88+
interaction with the people involved, including unsolicited interaction with
89+
those enforcing the Code of Conduct, for a specified period of time. This
90+
includes avoiding interactions in community spaces as well as external channels
91+
like social media. Violating these terms may lead to a temporary or permanent
92+
ban.
93+
94+
### 3. Temporary Ban
95+
96+
**Community Impact**: A serious violation of community standards, including
97+
sustained inappropriate behavior.
98+
99+
**Consequence**: A temporary ban from any sort of interaction or public
100+
communication with the community for a specified period of time. No public or
101+
private interaction with the people involved, including unsolicited interaction
102+
with those enforcing the Code of Conduct, is allowed during this period.
103+
Violating these terms may lead to a permanent ban.
104+
105+
### 4. Permanent Ban
106+
107+
**Community Impact**: Demonstrating a pattern of violation of community
108+
standards, including sustained inappropriate behavior, harassment of an
109+
individual, or aggression toward or disparagement of classes of individuals.
110+
111+
**Consequence**: A permanent ban from any sort of public interaction within the
112+
community.
113+
114+
## Attribution
115+
116+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117+
version 2.1, available at
118+
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.
119+
120+
Community Impact Guidelines were inspired by
121+
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].
122+
123+
For answers to common questions about this code of conduct, see the FAQ at
124+
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.
125+
126+
[homepage]: https://www.contributor-covenant.org

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"Posit.air-vscode"
4+
]
5+
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"[r]": {
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "Posit.air-vscode"
5+
},
6+
"[quarto]": {
7+
"editor.formatOnSave": true,
8+
"editor.defaultFormatter": "quarto.quarto"
9+
}
10+
}

DESCRIPTION

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,49 @@ Package: chattr
22
Title: Interact with Large Language Models in 'RStudio'
33
Version: 0.3.1
44
Authors@R: c(
5-
person("Edgar", "Ruiz", , "edgar@posit.co", role = c("aut", "cre")),
6-
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
5+
person("Edgar", "Ruiz", , "edgar@posit.co", role = c("aut", "cre")),
6+
person("Posit Software, PBC", role = c("cph", "fnd"),
7+
comment = c(ROR = "03wc8by49"))
78
)
8-
Description: Enables user interactivity with large-language models ('LLM') inside
9-
the 'RStudio' integrated development environment (IDE). The user can
10-
interact with the model using the 'shiny' app included in this package, or
11-
directly in the 'R' console. It comes with back-ends for 'OpenAI', 'GitHub'
12-
'Copilot', and 'LlamaGPT'.
13-
URL: https://github.com/mlverse/chattr,
14-
https://mlverse.github.io/chattr/
15-
BugReports: https://github.com/mlverse/chattr/issues
9+
Description: Enables user interactivity with large-language models ('LLM')
10+
inside the 'RStudio' integrated development environment (IDE). The
11+
user can interact with the model using the 'shiny' app included in
12+
this package, or directly in the 'R' console. It comes with back-ends
13+
for 'OpenAI', 'GitHub' 'Copilot', and 'LlamaGPT'.
1614
License: MIT + file LICENSE
17-
Encoding: UTF-8
18-
Roxygen: list(markdown = TRUE)
19-
RoxygenNote: 7.3.2
15+
URL: https://github.com/mlverse/chattr, https://mlverse.github.io/chattr/
16+
BugReports: https://github.com/mlverse/chattr/issues
17+
Depends:
18+
R (>= 4.1)
2019
Imports:
21-
rstudioapi,
22-
lifecycle,
23-
processx,
20+
bslib,
21+
cli,
22+
clipr,
2423
config,
24+
coro,
2525
ellmer (>= 0.3.0),
26+
fs,
27+
glue,
28+
httr2 (>= 1.1.0),
29+
lifecycle,
30+
processx,
2631
purrr,
2732
rlang,
28-
bslib,
33+
rstudioapi,
2934
shiny,
30-
clipr,
31-
httr2 (>= 1.1.0),
32-
yaml,
33-
glue,
34-
coro,
35-
cli,
36-
fs
37-
Depends:
38-
R (>= 2.10)
35+
yaml
3936
Suggests:
4037
covr,
4138
knitr,
39+
withr,
4240
rmarkdown,
43-
testthat (>= 3.0.0),
44-
shinytest2,
45-
withr
41+
shinytest2,
42+
testthat (>= 3.0.0)
43+
VignetteBuilder:
44+
knitr
45+
Config/Needs/website: tidyverse/tidytemplate
4646
Config/testthat/edition: 3
47-
VignetteBuilder: knitr
47+
Config/usethis/last-upkeep: 2025-11-11
48+
Encoding: UTF-8
49+
Roxygen: list(markdown = TRUE)
50+
RoxygenNote: 7.3.3

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ import(fs)
2424
import(glue)
2525
import(httr2)
2626
import(processx)
27+
import(rlang)
2728
import(rstudioapi)
2829
import(shiny)
2930
import(yaml)
3031
importFrom(bslib,bs_theme)
3132
importFrom(clipr,write_clip)
33+
importFrom(glue,glue)
3234
importFrom(grDevices,rgb)
3335
importFrom(lifecycle,deprecated)
3436
importFrom(purrr,discard)

R/app-server.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ app_add_assistant <- function(content, input) {
131131

132132
walk(
133133
order(seq_along(ch), decreasing = TRUE),
134-
~ {
134+
\(.x) {
135135
len <- len_hist + .x
136136
content <- ch[[.x]]$content
137137
prep_content <- prep_entry(content, !ui_current_markdown())
@@ -140,8 +140,10 @@ app_add_assistant <- function(content, input) {
140140
insertUI(
141141
selector = "#tabs",
142142
where = "afterEnd",
143-
ui = app_ui_entry(content, is_code, len) %>%
144-
tagAppendAttributes(style = "width: 100%;")
143+
ui = tagAppendAttributes(
144+
app_ui_entry(content, is_code, len),
145+
style = "width: 100%;"
146+
)
145147
)
146148
if (is_code) {
147149
observeEvent(input[[paste0("copy", len)]], {
@@ -162,7 +164,7 @@ app_add_assistant <- function(content, input) {
162164

163165
ch_env$content_hist <- c(
164166
ch_env$content_hist,
165-
map_chr(ch, ~ .x$content)
167+
map_chr(ch, \(.x) .x$content)
166168
)
167169
}
168170

@@ -181,7 +183,7 @@ prep_entry <- function(x, remove) {
181183
app_split_content <- function(content) {
182184
split_content <- unlist(strsplit(content, "```"))
183185
map(
184-
seq_along(split_content), ~ {
186+
seq_along(split_content), \(.x) {
185187
is_code <- (.x / 2) == floor(.x / 2)
186188
content <- split_content[.x]
187189
code <- NULL

R/app-ui.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ app_ui <- function() {
6060
width = "100%",
6161
resize = "none"
6262
)
63-
) %>%
63+
) |>
6464
tagAppendAttributes(style = "width: 85%;"),
6565
column(
6666
width = 1,
@@ -80,7 +80,7 @@ app_ui <- function() {
8080
uiOutput("provider"),
8181
style = paste0("font-size:9px; color:", style$color_bk, ";")
8282
)
83-
) %>%
83+
) |>
8484
tagAppendAttributes(style = "width: 15%;"),
8585
),
8686
style = style$ui_panel
@@ -102,8 +102,8 @@ app_ui_modal <- function() {
102102

103103
tc <- chattr_defaults(type = "chat")
104104

105-
prompt2 <- tc$prompt %>%
106-
process_prompt() %>%
105+
prompt2 <- tc$prompt |>
106+
process_prompt() |>
107107
paste(collapse = "\n")
108108

109109
modalDialog(
@@ -135,8 +135,7 @@ app_ui_entry <- function(content, is_code, no_id) {
135135
width = 12,
136136
fluidRow(
137137
align = "right",
138-
column(width = 10, div()) %>%
139-
tagAppendAttributes(style = "width: 80%;"),
138+
tagAppendAttributes(column(width = 10, div()), style = "width: 80%;"),
140139
column(
141140
width = 2,
142141
if (is_code) {
@@ -149,7 +148,7 @@ app_ui_entry <- function(content, is_code, no_id) {
149148
app_ui_button("New script", "new", "plus", no_id)
150149
},
151150
style = "padding: 0px"
152-
) %>%
151+
) |>
153152
tagAppendAttributes(style = "width: 20%;")
154153
),
155154
fluidRow(

R/backend-ellmer.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#' @export
22
ch_submit.ch_ellmer <- function(
3-
defaults,
4-
prompt = NULL,
5-
stream = TRUE,
6-
prompt_build = TRUE,
7-
preview = FALSE,
8-
shiny = FALSE,
9-
...) {
3+
defaults,
4+
prompt = NULL,
5+
stream = TRUE,
6+
prompt_build = TRUE,
7+
preview = FALSE,
8+
shiny = FALSE,
9+
...
10+
) {
1011
if (preview) {
1112
return(prompt)
1213
}
@@ -80,7 +81,7 @@ ch_ellmer_history <- function(x) {
8081
) {
8182
new_history <- map(
8283
x,
83-
~ {
84+
\(.x) {
8485
ellmer::Turn(
8586
role = .x$role,
8687
contents = list(ellmer::ContentText(.x$content)),

R/backend-ollama.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ ch_ollama_check <- function() {
33
"http://localhost:11434",
44
"http://127.0.0.1:11434"
55
)
6-
check_urls <- urls %>%
7-
map(~ request(.x) %>%
8-
req_perform() %>%
9-
try(silent = TRUE)) %>%
10-
map_lgl(~ {
6+
check_urls <- urls |>
7+
map(\(.x){
8+
request(.x) |>
9+
req_perform() |>
10+
try(silent = TRUE)
11+
}) |>
12+
map_lgl(\(.x) {
1113
if (inherits(.x, "httr2_response")) {
1214
if (.x$status_code == 200) {
1315
TRUE

0 commit comments

Comments
 (0)