Spaces:
Runtime error
Runtime error
abhi001vj
commited on
Commit
•
8440ce4
1
Parent(s):
03819ce
added the update for haystack search
Browse files
app.py
CHANGED
@@ -287,9 +287,19 @@ if st.session_state.results:
|
|
287 |
answer, context = result.answer, result.context
|
288 |
start_idx = context.find(answer)
|
289 |
end_idx = start_idx + len(answer)
|
290 |
-
source = f"[{result.meta['Title']}]({result.meta['link']})"
|
291 |
# Hack due to this bug: https://github.com/streamlit/streamlit/issues/3190
|
292 |
-
|
|
|
|
|
293 |
markdown(f'**Source:** {source} \n {context[:start_idx] } {str(annotation(answer, "ANSWER", "#8ef"))} {context[end_idx:]} \n '),
|
294 |
unsafe_allow_html=True,
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
answer, context = result.answer, result.context
|
288 |
start_idx = context.find(answer)
|
289 |
end_idx = start_idx + len(answer)
|
|
|
290 |
# Hack due to this bug: https://github.com/streamlit/streamlit/issues/3190
|
291 |
+
try:
|
292 |
+
source = f"[{result.meta['Title']}]({result.meta['link']})"
|
293 |
+
st.write(
|
294 |
markdown(f'**Source:** {source} \n {context[:start_idx] } {str(annotation(answer, "ANSWER", "#8ef"))} {context[end_idx:]} \n '),
|
295 |
unsafe_allow_html=True,
|
296 |
+
)
|
297 |
+
except:
|
298 |
+
filename = result.meta.get('filename', "")
|
299 |
+
st.write(
|
300 |
+
markdown(f'From file: {filename} \n {context[:start_idx] } {str(annotation(answer, "ANSWER", "#8ef"))} {context[end_idx:]} \n '),
|
301 |
+
unsafe_allow_html=True,
|
302 |
+
)
|
303 |
+
|
304 |
+
|
305 |
+
|