legalai / app.py
CodeXRyu's picture
Create app.py
1bebdef verified
import streamlit as st
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load the model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("varma007ut/Indian_Legal_Assistant")
model = AutoModelForCausalLM.from_pretrained("varma007ut/Indian_Legal_Assistant")
# Function to generate a response from the chatbot
def chatbot_response(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=200)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
# Streamlit interface
st.title("Indian Legal Assistant Chatbot")
st.write("Ask questions related to Indian law.")
# User input
user_input = st.text_input("You:", placeholder="Type your question here...")
# When the user submits a question, generate the response
if st.button("Send"):
if user_input:
response = chatbot_response(user_input)
st.write("Chatbot: ", response)
else:
st.write("Please enter a question.")