Spaces:
Runtime error
Runtime error
Update appStore/keyword_search.py
Browse files- 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 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
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)
|