Introducing FastRTC, a new way to build real-time AI apps

Read More
  1. Helpers
  2. EditData

New to Gradio? Start here: Getting Started

See the Release History

To install Gradio from main, run the following command:

pip install https://gradio-builds.s3.amazonaws.com/373007b3e9d019ee41589d1dbb09a7511a024a51/gradio-5.20.1-py3-none-any.whl

*Note: Setting share=True in launch() will not work.

EditData

gradio.EditData(ยทยทยท)

Description

The gr.EditData class is a subclass of gr.Event data that specifically carries information about the .edit() event. When gr.EditData is added as a type hint to an argument of an event listener method, a gr.EditData object will automatically be passed as the value of that argument. The attributes of this object contains information about the event that triggered the listener.

Example Usage

import gradio as gr

def edit(edit_data: gr.EditData, history: list[gr.MessageDict]):
    history_up_to_edit = history[:edit_data.index]
    history_up_to_edit[-1] = edit_data.value
    return history_up_to_edit

with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    chatbot.undo(edit, chatbot, chatbot)
demo.launch()

Attributes

Parameters
๐Ÿ”—
index: int | tuple[int, int]

The index of the message that was edited.

๐Ÿ”—
previous_value: Any

The previous content of the message that was edited.

๐Ÿ”—
value: Any

The new content of the message that was edited.