Gradio 达成每月百万用户的旅程!
阅读更多Gradio 达成每月百万用户的旅程!
阅读更多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()