File size: 1,005 Bytes
1bebdef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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.")