Skip to content

Commit

Permalink
Don't wrap long lines when printing (#250)
Browse files Browse the repository at this point in the history
Fixes #246
  • Loading branch information
hadley authored Jan 13, 2025
1 parent 4d3aca9 commit 4a8592a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ellmer (development version)

* `print(Chat)` no longer wraps long lines, making it easier to read code and bulleted lists (#246).

* `chat_openai()` should be less likely to timeout when not streaming chat results (#213).

# ellmer 0.1.0
Expand Down
2 changes: 1 addition & 1 deletion R/content.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ContentText <- new_class(
properties = list(text = prop_string()),
)
method(format, ContentText) <- function(x, ...) {
paste0(unlist(strwrap(x@text, width = getOption("width"))), collapse = "\n")
x@text
}

method(contents_text, ContentText) <- function(content) {
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/_snaps/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
-- system ----------------------------------------------------------------------
You're a helpful assistant that returns very minimal output
-- user ------------------------------------------------------------------------
What's 1 + 1? What's 1 + 2?
What's 1 + 1?
What's 1 + 2?
-- assistant -------------------------------------------------------------------
2
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-chat.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ test_that("has a basic print method", {
chat <- chat_openai(
"You're a helpful assistant that returns very minimal output",
turns = list(
Turn("user", "What's 1 + 1? What's 1 + 2?"),
Turn("user", "What's 1 + 1?\nWhat's 1 + 2?"),
Turn("assistant", "2\n\n3", tokens = c(15, 5))
)
)
Expand Down

0 comments on commit 4a8592a

Please sign in to comment.