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