Saathi / ui /lawbot_ui.py
MP44's picture
Upload 125 files
bde00fb verified
import gradio as gr
from modules.lawbot.interface import lawbot_interface
def get_lawbot_tab():
with gr.Tab("⚖️ NyaySetu"):
gr.Markdown(
"""
<div style='font-size: 18px; color: #ffffff; line-height: 1.8; max-width: 850px; padding: 10px 20px; text-align: center; margin: auto;'>
Whether you’re confused about your rights or unsure where to begin,<br>
<strong style="color:#ff6600;">NyaySetu gives you accurate, easy-to-understand legal help — anytime, anywhere.</strong>
</div>
"""
)
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])