Skip to content

Chat print method collapses newlines in user turns #246

Description

@simonpcouch

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions