Gradio Agents & MCP 黑客马拉松
获奖者Gradio Agents & MCP 黑客马拉松
获奖者gradio.RetryData(···)
.retry()
事件的信息。当 gr.RetryData 作为类型提示添加到事件监听器方法的参数时,一个 gr.RetryData 对象将自动作为该参数的值传递。此对象的属性包含有关触发监听器的事件的信息。import gradio as gr
def retry(retry_data: gr.RetryData, history: list[gr.MessageDict]):
history_up_to_retry = history[:retry_data.index]
new_response = ""
for token in api.chat_completion(history):
new_response += token
yield history + [new_response]
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
chatbot.retry(retry, chatbot, chatbot)
demo.launch()