import gradio as gr
from modules.lawbot.interface import lawbot_interface
def get_lawbot_tab():
with gr.Tab("⚖️ NyaySetu"):
gr.Markdown(
"""
Whether you’re confused about your rights or unsure where to begin,
NyaySetu gives you accurate, easy-to-understand legal help — anytime, anywhere.
"""
)
chatbot = gr.Chatbot(label="Chat History", height=400)
with gr.Row():
question = gr.Textbox(
label="Ask a Question",
placeholder="e.g., What is Section 498A?",
scale=4
)
submit_btn = gr.Button("Submit", elem_id="lawbot-submit-btn", scale=1)
clear_btn = gr.Button("Clear Chat", elem_id="lawbot-clear-btn", scale=1)
def respond(message, chat_history):
if not message.strip():
return chat_history, ""
bot_message = lawbot_interface(message, chat_history)
chat_history.append((message, bot_message))
return chat_history, ""
submit_btn.click(respond, inputs=[question, chatbot], outputs=[chatbot, question])
clear_btn.click(lambda: [], inputs=[], outputs=[chatbot])