Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat print method collapses newlines in user turns #246

Closed
simonpcouch opened this issue Jan 9, 2025 · 2 comments · Fixed by #250
Closed

Chat print method collapses newlines in user turns #246

simonpcouch opened this issue Jan 9, 2025 · 2 comments · Fixed by #250
Milestone

Comments

@simonpcouch
Copy link
Contributor

When I pass input to $chat that has (single) newlines, they're stripped away when the chat is printed out:

library(ellmer)

ch <- chat_claude()
res <- ch$chat("
    ```r
    library(ggplot2)
    ggplot(mtcars) + aes(x = mpg) + geom_histogram()
    ```
")
#> This R code... [redacted]

ch
#> <Chat turns=2 tokens=49/302>
#> ── user ────────────────────────────────────────────────────────────────────────
#> ```r library(ggplot2) ggplot(mtcars) + aes(x = mpg) + geom_histogram() ```
#> ── assistant ───────────────────────────────────────────────────────────────────
#> This R code...  [redacted]

Created on 2025-01-09 with reprex v2.1.1

This makes it particularly hard to read code and code output when looking back at a chat's turns.

@hadley hadley added this to the 0.1.1 milestone Jan 10, 2025
@hadley
Copy link
Member

hadley commented Jan 13, 2025

Very slightly more minimal example:

library(ellmer)

chat <- chat_claude(echo = FALSE)
. <- chat$chat("
  Explain this code in a bulleted list

  ```r
  library(ggplot2)
  ggplot(mtcars) + aes(x = mpg) + geom_histogram()
  ```
")
chat

@hadley
Copy link
Member

hadley commented Jan 13, 2025

Hmmm the problem is that method(format, ContentText) currently wraps the text to avoid very long lines. But probably better to just not wrap, given that this is mostly just a debugging function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants