Skip to content

Custom file name for cl.Pdf #2124

@damiwee

Description

@damiwee

Is your feature request related to a problem? Please describe.
Currently, when using cl.Pdf with an existing file path, Chainlit creates a copy of the file with a new UUID-based name. This UUID is then used as the download file name when a user downloads the PDF from the chat UI, which means the original file name is lost. This makes it difficult for users to identify and manage downloaded files.

Describe the solution you'd like
I propose adding a way to customize the file name for downloads triggered from cl.Pdf elements. Ideally, this would involve:
A new parameter, such as download_name, in the cl.Pdf class.
This parameter would allow developers to specify the file name that users will see when downloading the PDF.

For example:

pdf_element = cl.Pdf(
    name="My Report",
    path="./my_report.pdf",
    display="inline",
    download_name="UserFriendlyReport.pdf"  # New parameter
)

This would ensure that when a user downloads the PDF, the file is saved as "UserFriendlyReport.pdf" instead of a UUID.

Benefits:

  • Improved user experience: Users can easily identify downloaded files.
  • Better file management: Consistent and meaningful file names facilitate organization.
  • Increased flexibility: Developers can tailor file names to specific use cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions