Spaces:
Sleeping
Sleeping
Commit
·
a53c091
1
Parent(s):
95869a6
Update pages/answers.py
Browse files- pages/answers.py +8 -7
pages/answers.py
CHANGED
@@ -63,24 +63,25 @@ def main():
|
|
63 |
st.divider()
|
64 |
st.markdown("### **Enter the context and question, then click on ':blue[Get Answer]' to retrieve the answer:**")
|
65 |
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
if st.button(":blue[**Random Example**]"):
|
70 |
pair = random.choice(pairs)
|
71 |
context = pair['context']
|
72 |
question = pair['question']
|
73 |
-
|
74 |
|
75 |
if st.button(":blue[**Get Answer**]"):
|
76 |
-
if context.strip() ==
|
77 |
st.warning("Please enter the context and question.")
|
78 |
else:
|
79 |
answer = get_answer(context, question)
|
80 |
st.success(f"Answer: {answer}")
|
81 |
|
82 |
|
83 |
-
|
84 |
-
|
85 |
if __name__ == "__main__":
|
86 |
-
main()
|
|
|
63 |
st.divider()
|
64 |
st.markdown("### **Enter the context and question, then click on ':blue[Get Answer]' to retrieve the answer:**")
|
65 |
|
66 |
+
context_placeholder = "Enter the context here..."
|
67 |
+
question_placeholder = "Enter the question here..."
|
68 |
+
|
69 |
+
context = st.text_area("**:blue[Context]**", context_placeholder)
|
70 |
+
question = st.text_input("**:blue[Question]**", question_placeholder)
|
71 |
|
72 |
if st.button(":blue[**Random Example**]"):
|
73 |
pair = random.choice(pairs)
|
74 |
context = pair['context']
|
75 |
question = pair['question']
|
76 |
+
st.experimental_set_query_params(context=context, question=question)
|
77 |
|
78 |
if st.button(":blue[**Get Answer**]"):
|
79 |
+
if context.strip() == context_placeholder or question.strip() == question_placeholder:
|
80 |
st.warning("Please enter the context and question.")
|
81 |
else:
|
82 |
answer = get_answer(context, question)
|
83 |
st.success(f"Answer: {answer}")
|
84 |
|
85 |
|
|
|
|
|
86 |
if __name__ == "__main__":
|
87 |
+
main()
|