Gradio Agents & MCP 黑客松
获胜者Gradio Agents & MCP 黑客松
获胜者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()