Skip to content

Implement __str__ in Message #1639

@RdoubleA

Description

@RdoubleA

Currently, if you print a Message object of a list of Messages it just shows the memory address of the class, which is lame.

[<torchtune.data._messages.Message at 0x7fc0e5f6cd30>,
 <torchtune.data._messages.Message at 0x7fc0e67f2470>]

We should implement a proper __str__ method to make the output legible. Ideally, something like:

Message(role="user", content="Hello world!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    better engineeringTasks which help improve eng productivity e.g. building tools, cleaning up code, writing docscommunity help wantedWe would love the community's help completing this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions