Gradio 迈向每月 100 万用户的旅程!
阅读更多Gradio 迈向每月 100 万用户的旅程!
阅读更多gradio.UndoData(···)
.undo()
事件的信息。当 gr.UndoData 作为类型提示添加到事件监听器方法的参数时,gr.UndoData 对象将自动作为该参数的值传递。此对象的属性包含有关触发监听器的事件的信息。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()