# Install required libraries
!pip install sentence-transformers faiss-cpu gradio transformers
# Import libraries
from sentence_transformers import SentenceTransformer
from transformers import pipeline
import faiss
import numpy as np
import gradio as gr
# Step 1: Build Knowledge Base from Legal Texts
legal_texts = [
# Dowry and Marriage
"Is dowry illegal in India? -> Yes, under the Dowry Prohibition Act, 1961, giving, taking, or demanding dowry is illegal and punishable by up to 3 years of imprisonment and fines.",
"What are a woman's rights after marriage? -> A woman has rights to residence, maintenance, dignity, and protection against domestic violence under Indian law.",
# Divorce
"How can a woman file for divorce? -> A woman can file for divorce on grounds such as cruelty, adultery, desertion, conversion, mental disorder, and mutual consent under the Hindu Marriage Act, 1955.",
"Can a divorced woman claim maintenance? -> Yes, under Section 125 of the Crimi…