Upgrade streamlit and adjust height of result texts dynamically (#1279)

* update to latest streamlit and st-annotated-text

* improve ui results by passing dynamic height to annotated-text
This commit is contained in:
Antonio De Marinis 2021-07-13 18:59:39 +02:00 committed by GitHub
parent 2f93c2ddd5
commit f79d9bdca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -1,2 +1,2 @@
streamlit==0.81.0
st-annotated-text==1.0.1
streamlit==0.84.0
st-annotated-text==1.1.0

View File

@ -22,8 +22,9 @@ def annotate_answer(answer, context):
from the API that we highlight in the given context"""
start_idx = context.find(answer)
end_idx = start_idx + len(answer)
annotated_text(context[:start_idx], (answer, "ANSWER", "#8ef"), context[end_idx:])
# calculate dynamic height depending on context length
height = int(len(context) * 0.50) + 5
annotated_text(context[:start_idx], (answer, "ANSWER", "#8ef"), context[end_idx:], height=height)
def show_plain_documents(text):
""" If we are using a plain document search pipeline, i.e. only retriever, we'll get plain documents