Tuana commited on
Commit
2ad73ca
·
1 Parent(s): d014921
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -48,11 +48,11 @@ def ask_question(question):
48
  prediction = pipeline.run(query=question, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}})
49
  results = []
50
  for answer in prediction["answers"]:
51
- if answer.get("answer", None):
52
  results.append(
53
  {
54
  "context": "..." + answer["context"] + "...",
55
- "answer": answer.get("answer", None),
56
  "relevance": round(answer["score"] * 100, 2),
57
  "offset_start_in_doc": answer["offsets_in_document"][0]["start"],
58
  }
@@ -73,6 +73,7 @@ def ask_question(question):
73
 
74
  if question:
75
  try:
 
76
  st.session_state.results = ask_question(question)
77
  except Exception as e:
78
  logging.exception(e)
 
48
  prediction = pipeline.run(query=question, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}})
49
  results = []
50
  for answer in prediction["answers"]:
51
+ if answer["answer"]:
52
  results.append(
53
  {
54
  "context": "..." + answer["context"] + "...",
55
+ "answer": answer["answer"],
56
  "relevance": round(answer["score"] * 100, 2),
57
  "offset_start_in_doc": answer["offsets_in_document"][0]["start"],
58
  }
 
73
 
74
  if question:
75
  try:
76
+ logging.log('Asked ' + question)
77
  st.session_state.results = ask_question(question)
78
  except Exception as e:
79
  logging.exception(e)