import gradio as gr with gr.Blocks() as demo: history = gr.State([]) user_question = gr.State("") output_file_name = "chat_history.json" def slow_echo(message, history): for i in range(len(message)): yield "You typed: " + message[: i+1] def generate_json(history): pass chatbox = gr.ChatInterface( fn=slow_echo, examples=["How can I help you?"], title="Title Here", description="Description for the task", submit_btn="Enter", stop_btn="Stop generating", retry_btn="Regenerate", undo_btn="Undo last message", clear_btn="Start a new conversation" ) chatbox.queue() json_gen_btn = gr.Button("📩 Download the JSON file for your chat history!") chat_history_json = [] json_gen_btn.click(fn=generate_json, inputs=history, outputs=chat_history_json) demo.queue() demo.launch()