import gradio as gr from model.controller import Controller # Initialize your controller bot = Controller() # Define chatbot function def chatbot_interface(user_input, chat_id=2311): return bot.handle_message(chat_id, user_input) # Define Gradio interface with gr.Blocks() as interface: gr.Markdown("## RAG Law Chatbot") chatbot = gr.Chatbot() user_input = gr.Textbox(show_label=False, placeholder="Enter your law question...").style(container=False) send_button = gr.Button("Send") def chat_update(user_message, history): history = history or [] bot_reply = chatbot_interface(user_message) history.append((user_message, bot_reply)) return history, "" send_button.click(chat_update, [user_input, chatbot], [chatbot, user_input]) # Launch the Gradio interface interface.launch()