import gradio as gr from rag import respond_rag_huggingface as response_hf import shutil try: shutil.rmtree("/home/user/.cache/huggingface") shutil.rmtree("/home/user/.huggingface") except Exception as e: print("Error clearing cache:", e) chat_history = [] def respond(message): global chat_history response = response_hf(message) chat_history.append((message, response)) return "", chat_history with gr.Blocks() as demo: gr.Markdown("# Game of Thrones,harry potter Q&A bot") chatbot = gr.Chatbot(label="Chat History") msg = gr.Textbox(label="Write something about Game of Thrones or harry potter here...") submit = gr.Button("Submit") submit.click(respond, inputs=[msg], outputs=[msg, chatbot]) #clear.click(lambda: ([], ""), None, [chatbot, msg]) demo.launch()