wedo2910 commited on
Commit
1598ad8
·
verified ·
1 Parent(s): dc2778c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -29,10 +29,9 @@ default_settings = {
29
 
30
  # Streamlit UI
31
  st.title("Arabic AI Question Answering")
32
- st.subheader("Provide context and ask a question to get answers.")
33
 
34
- # Input fields
35
- context = st.text_area("Context", placeholder="Enter the context here...", height=200)
36
  question = st.text_input("Question", placeholder="Enter your question here...")
37
 
38
  # Settings sliders
@@ -50,13 +49,13 @@ doc_stride = st.number_input("Document Stride", min_value=1, value=128)
50
 
51
  # Generate Answer button
52
  if st.button("Get Answer"):
53
- if not context or not question:
54
- st.error("Both context and question fields are required.")
55
  else:
56
  # Generate answer
57
  try:
58
  prediction = qa_pipeline(
59
- {"context": context, "question": question},
60
  max_answer_len=max_answer_len,
61
  doc_stride=doc_stride
62
  )
@@ -64,4 +63,4 @@ if st.button("Get Answer"):
64
  st.write(f"**Question:** {question}")
65
  st.write(f"**Answer:** {prediction['answer']}")
66
  except Exception as e:
67
- st.error(f"Error: {e}")
 
29
 
30
  # Streamlit UI
31
  st.title("Arabic AI Question Answering")
32
+ st.subheader("Ask a question to get an answer.")
33
 
34
+ # Input field for the question only
 
35
  question = st.text_input("Question", placeholder="Enter your question here...")
36
 
37
  # Settings sliders
 
49
 
50
  # Generate Answer button
51
  if st.button("Get Answer"):
52
+ if not question:
53
+ st.error("The question field is required.")
54
  else:
55
  # Generate answer
56
  try:
57
  prediction = qa_pipeline(
58
+ {"question": question},
59
  max_answer_len=max_answer_len,
60
  doc_stride=doc_stride
61
  )
 
63
  st.write(f"**Question:** {question}")
64
  st.write(f"**Answer:** {prediction['answer']}")
65
  except Exception as e:
66
+ st.error(f"Error: {e}")