Spaces:
Runtime error
Runtime error
iamviveksrk
commited on
Commit
β’
2ea27b8
1
Parent(s):
bd2f707
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ query = st.text_input('Enter a query to get started:', value=st.session_state.qu
|
|
44 |
|
45 |
def ask_question(query):
|
46 |
start = time.time()
|
47 |
-
prediction = pipeline.run(query=query, params={"Retriever": {"top_k":
|
48 |
st.write('Time taken: %s s' % round(time.time()-start, 2))
|
49 |
|
50 |
results = []
|
@@ -89,11 +89,12 @@ if st.session_state.results:
|
|
89 |
answer, context = result["answer"], result["context"]
|
90 |
start_idx = context.find(answer)
|
91 |
end_idx = start_idx + len(answer)
|
|
|
92 |
st.write(
|
93 |
-
markdown(context[:start_idx] + str(annotation(body=answer, label="RELEVANT", background="#
|
94 |
unsafe_allow_html=True,
|
95 |
)
|
96 |
-
st.markdown(f"**
|
97 |
else:
|
98 |
st.info(
|
99 |
"π€ Haystack is unsure whether any of the documents contain an answer to your question. Try to reformulate it!"
|
|
|
44 |
|
45 |
def ask_question(query):
|
46 |
start = time.time()
|
47 |
+
prediction = pipeline.run(query=query, params={"Retriever": {"top_k": 6}, "Reader": {"top_k": 3}})
|
48 |
st.write('Time taken: %s s' % round(time.time()-start, 2))
|
49 |
|
50 |
results = []
|
|
|
89 |
answer, context = result["answer"], result["context"]
|
90 |
start_idx = context.find(answer)
|
91 |
end_idx = start_idx + len(answer)
|
92 |
+
st.markdown(f"**Title:** [{result['title']}]({result['link']})")
|
93 |
st.write(
|
94 |
+
markdown(context[:start_idx] + str(annotation(body=answer, label="RELEVANT", background="#67a17a", color='#ffffff')) + context[end_idx:]),
|
95 |
unsafe_allow_html=True,
|
96 |
)
|
97 |
+
st.markdown(f"**Relevance:** {result['score']}")
|
98 |
else:
|
99 |
st.info(
|
100 |
"π€ Haystack is unsure whether any of the documents contain an answer to your question. Try to reformulate it!"
|