Stefano Fiorucci commited on
Commit
d4647c0
1 Parent(s): ca216e5

update app

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -15,6 +15,8 @@ from haystack.nodes import FARMReader
15
  from haystack.pipelines import ExtractiveQAPipeline
16
  from annotated_text import annotation
17
  import shutil
 
 
18
 
19
  # FAISS index directory
20
  INDEX_DIR = 'data/index'
@@ -207,7 +209,7 @@ and see if the AI ​​can find an answer...
207
  if result["answer"]:
208
  if alert_irrelevance and result['score']<0.50:
209
  alert_irrelevance = False
210
- st.write("<h3 style='color: red'>Attention, the following answers have low score:</h3>", unsafe_allow_html=True)
211
 
212
  answer, context = result["answer"], result["context"]
213
  start_idx = context.find(answer)
@@ -215,7 +217,7 @@ and see if the AI ​​can find an answer...
215
  # Hack due to this bug: https://github.com/streamlit/streamlit/issues/3190
216
  st.write(markdown("- ..."+context[:start_idx] + str(annotation(answer, "ANSWER", "#3e1c21")) + context[end_idx:]+"..."), unsafe_allow_html=True)
217
  source = ""
218
- name = result['meta']['name'].replace('_',' ')
219
  url = result['meta']['url']
220
  source = f"[{name}]({url})"
221
  st.markdown(f"**Score:** {result['score']:.2f} - **Source:** {source}")
15
  from haystack.pipelines import ExtractiveQAPipeline
16
  from annotated_text import annotation
17
  import shutil
18
+ from urllib.parse import unquote
19
+
20
 
21
  # FAISS index directory
22
  INDEX_DIR = 'data/index'
209
  if result["answer"]:
210
  if alert_irrelevance and result['score']<0.50:
211
  alert_irrelevance = False
212
+ st.write("<h4 style='color: darkred'>Attention, the following answers have low score:</h3>", unsafe_allow_html=True)
213
 
214
  answer, context = result["answer"], result["context"]
215
  start_idx = context.find(answer)
217
  # Hack due to this bug: https://github.com/streamlit/streamlit/issues/3190
218
  st.write(markdown("- ..."+context[:start_idx] + str(annotation(answer, "ANSWER", "#3e1c21")) + context[end_idx:]+"..."), unsafe_allow_html=True)
219
  source = ""
220
+ name = unquote(result['meta']['name'])
221
  url = result['meta']['url']
222
  source = f"[{name}]({url})"
223
  st.markdown(f"**Score:** {result['score']:.2f} - **Source:** {source}")