Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 30, 2024
1 parent d005739 commit 7deab6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
10 changes: 7 additions & 3 deletions R/stream-copilot.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ chat_copilot <- function() {
req_body_json(
data = list(
messages = list(
list(role = "user",
content = "Tell me a joke about the R language.")
list(
role = "user",
content = "Tell me a joke about the R language."

Check warning on line 21 in R/stream-copilot.R

View check run for this annotation

Codecov / codecov/patch

R/stream-copilot.R#L13-L21

Added lines #L13 - L21 were not covered by tests
)
),
model = "copilot")) |>
model = "copilot"

Check warning on line 24 in R/stream-copilot.R

View check run for this annotation

Codecov / codecov/patch

R/stream-copilot.R#L24

Added line #L24 was not covered by tests
)
) |>
req_perform() |>
resp_chat_openai(stream = FALSE)

Check warning on line 28 in R/stream-copilot.R

View check run for this annotation

Codecov / codecov/patch

R/stream-copilot.R#L27-L28

Added lines #L27 - L28 were not covered by tests
}
14 changes: 7 additions & 7 deletions R/stream-openai.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ chat_openai <- function(prompt = "Tell me a joke about the R language.",
history = NULL,
temperature = NULL,
stream = FALSE) {

prompt <- prompt |> add_history(history)

Check warning on line 6 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L6

Added line #L6 was not covered by tests

response <-
Expand All @@ -15,13 +14,14 @@ chat_openai <- function(prompt = "Tell me a joke about the R language.",
) |>
resp_chat_openai(stream = is_true(stream))

Check warning on line 15 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L15

Added line #L15 was not covered by tests

response <- c(prompt,
list(list(role = response$role, content = response$content)))
response <- c(
prompt,
list(list(role = response$role, content = response$content))

Check warning on line 19 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L17-L19

Added lines #L17 - L19 were not covered by tests
)

class(response) <- c("chat_list", class(response))

Check warning on line 22 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L22

Added line #L22 was not covered by tests

response

Check warning on line 24 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L24

Added line #L24 was not covered by tests

}

#' @export
Expand All @@ -34,9 +34,9 @@ print.chat_list <- function(x, ...) {
print_role <- rule(stringr::str_to_title(x[[i]]$role))
print_role <-
switch(x[[i]]$role,
"assistant" = col_green(print_role),
"system" = col_silver(print_role),
"user" = col_blue(print_role)
"assistant" = col_green(print_role),
"system" = col_silver(print_role),
"user" = col_blue(print_role)

Check warning on line 39 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L33-L39

Added lines #L33 - L39 were not covered by tests
)
writeLines(print_role)
writeLines(x[[i]]$content)

Check warning on line 42 in R/stream-openai.R

View check run for this annotation

Codecov / codecov/patch

R/stream-openai.R#L41-L42

Added lines #L41 - L42 were not covered by tests
Expand Down

0 comments on commit 7deab6f

Please sign in to comment.