ignaciaginting commited on
Commit
d75400e
·
verified ·
1 Parent(s): 1798e36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -37,4 +37,8 @@ if pdf_file and question:
37
  # Run the pipeline
38
  with st.spinner("Searching for the answer..."):
39
  result = qa_pipeline(img, question)
40
- st.success(f"**Answer:** {result['answer']} (score: {result['score']:.2f})")
 
 
 
 
 
37
  # Run the pipeline
38
  with st.spinner("Searching for the answer..."):
39
  result = qa_pipeline(img, question)
40
+ if results:
41
+ top_answer = results[0] # get the highest-scoring answer
42
+ st.success(f"**Answer:** {top_answer['answer']} (score: {top_answer['score']:.2f})")
43
+ else:
44
+ st.warning("No answer found.")