peter2000 commited on
Commit
306e6e1
1 Parent(s): 4bd6367

Update appStore/keyword_search.py

Browse files
Files changed (1) hide show
  1. appStore/keyword_search.py +14 -14
appStore/keyword_search.py CHANGED
@@ -107,20 +107,20 @@ def app():
107
  logging.info(msg)
108
  results = ask_question(question)
109
  st.write('## Top Results')
110
- for count, result in enumerate(results):
111
- if result["answer"]:
112
- answer, context = result["answer"], result["context"]
113
- start_idx = context.find(answer)
114
- end_idx = start_idx + len(answer)
115
- st.write(
116
- markdown(context[:start_idx] + str(annotation(body=answer, label="ANSWER", background="#964448", color='#ffffff')) + context[end_idx:]),
117
- unsafe_allow_html=True,
118
- )
119
- st.markdown(f"**Relevance:** {result['relevance']}")
120
- else:
121
- st.info(
122
- "🤔    Haystack is unsure whether any of the documents contain an answer to your question. Try to reformulate it!"
123
- )
124
 
125
  except Exception as e:
126
  logging.exception(e)
 
107
  logging.info(msg)
108
  results = ask_question(question)
109
  st.write('## Top Results')
110
+ for count, result in enumerate(results):
111
+ if result["answer"]:
112
+ answer, context = result["answer"], result["context"]
113
+ start_idx = context.find(answer)
114
+ end_idx = start_idx + len(answer)
115
+ st.write(
116
+ markdown(context[:start_idx] + str(annotation(body=answer, label="ANSWER", background="#964448", color='#ffffff')) + context[end_idx:]),
117
+ unsafe_allow_html=True,
118
+ )
119
+ st.markdown(f"**Relevance:** {result['relevance']}")
120
+ else:
121
+ st.info(
122
+ "🤔    Haystack is unsure whether any of the documents contain an answer to your question. Try to reformulate it!"
123
+ )
124
 
125
  except Exception as e:
126
  logging.exception(e)