Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,11 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
import tempfile
|
4 |
-
|
5 |
# Corrected model class name
|
6 |
model_name = "potsawee/t5-large-generation-squad-QuestionAnswer"
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
9 |
-
|
10 |
uploaded_file = st.file_uploader("Upload Document or Paragraph")
|
11 |
-
|
12 |
if uploaded_file is not None:
|
13 |
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
14 |
temp_file.write(uploaded_file.read())
|
@@ -16,10 +13,8 @@ if uploaded_file is not None:
|
|
16 |
st.success("Document uploaded successfully!")
|
17 |
else:
|
18 |
document_text = st.text_area("Enter Text (Optional)", height=200)
|
19 |
-
|
20 |
question = st.text_input("Ask a Question")
|
21 |
bouton_ok = st.button("Answer")
|
22 |
-
|
23 |
if bouton_ok:
|
24 |
# Improved prompt for better context
|
25 |
context = document_text if document_text else "Empty document."
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
import tempfile
|
|
|
4 |
# Corrected model class name
|
5 |
model_name = "potsawee/t5-large-generation-squad-QuestionAnswer"
|
6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
|
|
8 |
uploaded_file = st.file_uploader("Upload Document or Paragraph")
|
|
|
9 |
if uploaded_file is not None:
|
10 |
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
11 |
temp_file.write(uploaded_file.read())
|
|
|
13 |
st.success("Document uploaded successfully!")
|
14 |
else:
|
15 |
document_text = st.text_area("Enter Text (Optional)", height=200)
|
|
|
16 |
question = st.text_input("Ask a Question")
|
17 |
bouton_ok = st.button("Answer")
|
|
|
18 |
if bouton_ok:
|
19 |
# Improved prompt for better context
|
20 |
context = document_text if document_text else "Empty document."
|