From f79d9bdca65dd4850e4219cd9396c957e3399007 Mon Sep 17 00:00:00 2001 From: Antonio De Marinis Date: Tue, 13 Jul 2021 18:59:39 +0200 Subject: [PATCH] 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 --- ui/requirements.txt | 4 ++-- ui/webapp.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/requirements.txt b/ui/requirements.txt index 20f85620e..7563be733 100644 --- a/ui/requirements.txt +++ b/ui/requirements.txt @@ -1,2 +1,2 @@ -streamlit==0.81.0 -st-annotated-text==1.0.1 \ No newline at end of file +streamlit==0.84.0 +st-annotated-text==1.1.0 diff --git a/ui/webapp.py b/ui/webapp.py index ceb2d7908..c630f9c82 100644 --- a/ui/webapp.py +++ b/ui/webapp.py @@ -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