Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,34 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from hf_model import load_model, summarize_text
|
| 3 |
|
| 4 |
-
#
|
| 5 |
st.title("Legal NLP Application")
|
| 6 |
st.sidebar.title("Options")
|
| 7 |
|
| 8 |
# Select the task
|
| 9 |
task = st.sidebar.radio("Select Task", ["Summarization", "Question Answering"])
|
| 10 |
|
| 11 |
-
#
|
| 12 |
if task == "Summarization":
|
| 13 |
st.header("Summarize Legal Text")
|
| 14 |
-
user_input = st.text_area("Enter Legal Text", height=200)
|
| 15 |
-
|
| 16 |
if st.button("Summarize"):
|
| 17 |
-
|
|
|
|
| 18 |
summary = summarize_text(model, user_input)
|
| 19 |
st.write("### Summary")
|
| 20 |
st.write(summary)
|
| 21 |
|
|
|
|
| 22 |
elif task == "Question Answering":
|
| 23 |
st.header("Legal Question Answering")
|
| 24 |
-
context = st.text_area("Enter Context
|
| 25 |
-
question = st.text_input("Ask a Question")
|
| 26 |
-
|
| 27 |
if st.button("Get Answer"):
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
st.write("### Answer")
|
| 31 |
st.write(answer)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from hf_model import load_model, summarize_text, answer_question
|
| 3 |
|
| 4 |
+
# Title and Sidebar
|
| 5 |
st.title("Legal NLP Application")
|
| 6 |
st.sidebar.title("Options")
|
| 7 |
|
| 8 |
# Select the task
|
| 9 |
task = st.sidebar.radio("Select Task", ["Summarization", "Question Answering"])
|
| 10 |
|
| 11 |
+
# Task 1: Summarization
|
| 12 |
if task == "Summarization":
|
| 13 |
st.header("Summarize Legal Text")
|
| 14 |
+
user_input = st.text_area("Enter Legal Text", height=200, placeholder="Paste a legal text or case summary here...")
|
| 15 |
+
|
| 16 |
if st.button("Summarize"):
|
| 17 |
+
st.write("Loading model...")
|
| 18 |
+
model = load_model(task="summarization") # Load summarization model
|
| 19 |
summary = summarize_text(model, user_input)
|
| 20 |
st.write("### Summary")
|
| 21 |
st.write(summary)
|
| 22 |
|
| 23 |
+
# Task 2: Question Answering
|
| 24 |
elif task == "Question Answering":
|
| 25 |
st.header("Legal Question Answering")
|
| 26 |
+
context = st.text_area("Enter Context", height=200, placeholder="Paste a legal document or case description here...")
|
| 27 |
+
question = st.text_input("Ask a Legal Question", placeholder="Type your legal question here...")
|
| 28 |
+
|
| 29 |
if st.button("Get Answer"):
|
| 30 |
+
st.write("Loading model...")
|
| 31 |
+
model = load_model(task="question-answering") # Load QA model
|
| 32 |
+
answer = answer_question(model, question, context)
|
| 33 |
st.write("### Answer")
|
| 34 |
st.write(answer)
|