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

little improvements

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -127,7 +127,7 @@ and see if the AI ​​can find an answer...
127
  }}
128
  </style>
129
  <div class="haystack-footer">
130
- <p><a href="https://github.com/anakin87/who-killed-laura-palmer">GitHub</a> &nbsp;&nbsp; - &nbsp;&nbsp;
131
  Built with <a href="https://github.com/deepset-ai/haystack/">Haystack</a><br/>
132
  <small>Data crawled from <a href="https://twinpeaks.fandom.com/wiki/Twin_Peaks_Wiki">Twin Peaks Wiki</a>.</small>
133
  </p>
@@ -205,22 +205,20 @@ and see if the AI ​​can find an answer...
205
  for count, result in enumerate(st.session_state.results['answers']):
206
  result=result.to_dict()
207
  if result["answer"]:
208
- if alert_irrelevance and result['score']<=0.40:
209
  alert_irrelevance = False
210
- st.write("<h3 style='color: red'>Attention, the following answers have low relevance:</h3>", unsafe_allow_html=True)
211
 
212
  answer, context = result["answer"], result["context"]
213
- #authors, title = result["meta"]["authors"], result["meta"]["title"]
214
  start_idx = context.find(answer)
215
  end_idx = start_idx + len(answer)
216
- #url = get_backlink(result, my_ip)
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 = result['meta']['name']
221
  url = result['meta']['url']
222
  source = f"[{name}]({url})"
223
  st.markdown(f"**Score:** {result['score']:.2f} - **Source:** {source}")
224
- else:
225
- st.info("🤔 &nbsp;&nbsp; Haystack is unsure whether any of the documents contain an answer to your question. Try to reformulate it!")
226
  main()
 
127
  }}
128
  </style>
129
  <div class="haystack-footer">
130
+ <p><a href="https://github.com/anakin87/who-killed-laura-palmer">GitHub</a> -
131
  Built with <a href="https://github.com/deepset-ai/haystack/">Haystack</a><br/>
132
  <small>Data crawled from <a href="https://twinpeaks.fandom.com/wiki/Twin_Peaks_Wiki">Twin Peaks Wiki</a>.</small>
133
  </p>
 
205
  for count, result in enumerate(st.session_state.results['answers']):
206
  result=result.to_dict()
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)
214
  end_idx = start_idx + len(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}")
222
+ else:
223
+ st.info("🤔 &nbsp;&nbsp; Haystack is unsure whether any of the documents contain an answer to your question. Try to reformulate it!")
224
  main()