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

Read More
  1. Helpers
  2. UndoData

New to Gradio? Start here: Getting Started

See the Release History

UndoData

gradio.UndoData(ยทยทยท)

Description

The gr.UndoData class is a subclass of gr.Event data that specifically carries information about the .undo() event. When gr.UndoData is added as a type hint to an argument of an event listener method, a gr.UndoData 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 undo(retry_data: gr.UndoData, history: list[gr.MessageDict]):
    history_up_to_retry = history[:retry_data.index]
    return history_up_to_retry

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

Attributes

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

The index of the user message that should be undone.

๐Ÿ”—
value: Any

The value of the user message that should be undone.