import requests import gradio as gr import os address = os.getenv("address") thread = "new" cc = "DUMY99" def reset(): global thread thread = "new" def chat_history(message,history): global thread response = requests.post(address, json={ "query": message, "thread": thread, "cc": cc, }).json() thread = response['thread'] return response['result'] chat = gr.ChatInterface( chat_history, chatbot=gr.Chatbot(), title="Grade Analyst", description="Ask this bot any question about the csv", theme="soft", examples=["How many students are in the dataset? ", "How many students are at-risk, and how many of them are international students?"], retry_btn=None, undo_btn=None, clear_btn="Clear", ) with gr.Blocks() as demo: chat.render() gr.Button("Reset").click(reset) demo.launch()