OOlajide commited on
Commit
69a7629
·
1 Parent(s): ef6bd85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -46,16 +46,19 @@ if option == "Extractive question answering":
46
  with st.spinner(text="Getting answer..."):
47
  answer = question_answerer(context=context, question=question)
48
  answer = answer["answer"]
49
- st.write(f"Answer: {answer}")
50
  elif source == "I want to upload a file":
51
  uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
52
- question = st.text_input(label='Enter your question')
53
- button = st.button('Get answer')
 
 
 
54
  if button:
55
  question_answerer = question_model()
56
  with st.spinner(text="Getting answer..."):
57
- answer = question_answerer(context=uploaded_file, question=question)
58
- st.write(f"Answer: {answer}")
59
 
60
  elif option == 'Text summarization':
61
  st.markdown("<h2 style='text-align: center; color:red;'>Summarize text</h2>", unsafe_allow_html=True)
 
46
  with st.spinner(text="Getting answer..."):
47
  answer = question_answerer(context=context, question=question)
48
  answer = answer["answer"]
49
+ st.write(f"Answer ---> {answer}")
50
  elif source == "I want to upload a file":
51
  uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
52
+ if uploaded_file is not None:
53
+ sample_text = uploaded_file.read()
54
+ context = st.text_area("", value=sample_text, height=330)
55
+ question = st.text_input(label="Enter your question")
56
+ button = st.button("Get answer")
57
  if button:
58
  question_answerer = question_model()
59
  with st.spinner(text="Getting answer..."):
60
+ answer = question_answerer(context=context, question=question)
61
+ st.write(f"Answer ---> {answer}")
62
 
63
  elif option == 'Text summarization':
64
  st.markdown("<h2 style='text-align: center; color:red;'>Summarize text</h2>", unsafe_allow_html=True)