kxx-kkk commited on
Commit
e0567f7
1 Parent(s): 2a40cd6

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -31,7 +31,7 @@ def question_answering(context, question):
31
  answer = answer["answer"]
32
  # display the result in container
33
  container = st.container(border=True)
34
- container.write("<h5><b>Answer:</b></h5>" + answer + "<p><small>(F1 score: " + answer_score + ")</small></p><br>", unsafe_allow_html=True)
35
 
36
  # choose the source with different tabs
37
  tab1, tab2 = st.tabs(["Input text", "Upload File"])
@@ -62,10 +62,10 @@ with tab1:
62
  # perform question answering when "get answer" button clicked
63
  button = st.button("Get answer", key="textInput")
64
  if button:
65
- if context is not None and question is not None:
66
- question_answering(context, question)
67
- else:
68
  st.warning ("Please enter BOTH the context and the question")
 
 
69
 
70
 
71
  # if upload file as input
@@ -77,12 +77,15 @@ with tab2:
77
  if uploaded_file is not None:
78
  raw_text = str(uploaded_file.read(),"utf-8")
79
  context = st.text_area("", value=raw_text, height=330)
80
- question = st.text_input(label="Enter your question", value=sample_question)
81
 
82
  # perform question answering when "get answer" button clicked
83
  button2 = st.button("Get answer", key="fileInput")
84
  if button2:
85
- question_answering(context, question)
 
 
 
86
 
87
  st.markdown("<br><br><br><br><br>", unsafe_allow_html=True)
88
 
 
31
  answer = answer["answer"]
32
  # display the result in container
33
  container = st.container(border=True)
34
+ container.write("<h5><b>Answer:</b></h5>"+answer+"<p><small>(F1 score: "+answer_score+")</small></p><br>", unsafe_allow_html=True)
35
 
36
  # choose the source with different tabs
37
  tab1, tab2 = st.tabs(["Input text", "Upload File"])
 
62
  # perform question answering when "get answer" button clicked
63
  button = st.button("Get answer", key="textInput")
64
  if button:
65
+ if context is None and question is None:
 
 
66
  st.warning ("Please enter BOTH the context and the question")
67
+ else:
68
+ question_answering(context, question)
69
 
70
 
71
  # if upload file as input
 
77
  if uploaded_file is not None:
78
  raw_text = str(uploaded_file.read(),"utf-8")
79
  context = st.text_area("", value=raw_text, height=330)
80
+ question = st.text_input(label="Enter your question", value="Enter question here")
81
 
82
  # perform question answering when "get answer" button clicked
83
  button2 = st.button("Get answer", key="fileInput")
84
  if button2:
85
+ if context is None and question is None:
86
+ st.warning ("Please enter BOTH the context and the question")
87
+ else:
88
+ question_answering(context, question)
89
 
90
  st.markdown("<br><br><br><br><br>", unsafe_allow_html=True)
91