From e7771dc18e5168d0cd885233f330273be45d70e2 Mon Sep 17 00:00:00 2001 From: Stefano Fiorucci <44616784+anakin87@users.noreply.github.com> Date: Wed, 31 Aug 2022 12:35:40 +0200 Subject: [PATCH] bug: adapt UI random question for streamlit 1.12 and pin to streamlit>=1.9.0 (#3121) * adapt for streamlit 1.12.0 and pin to streamlit>=1.9.0 * make pylint happy --- ui/setup.py | 2 +- ui/webapp.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/setup.py b/ui/setup.py index 18c01f0de..e66a7b1e1 100644 --- a/ui/setup.py +++ b/ui/setup.py @@ -36,5 +36,5 @@ setup( ], packages=find_packages(), python_requires=">=3.7, <4", - install_requires=["streamlit>=1.2.0, <2", "st-annotated-text>=2.0.0, <3", "markdown>=3.3.4, <4"], + install_requires=["streamlit>=1.9.0, <2", "st-annotated-text>=2.0.0, <3", "markdown>=3.3.4, <4"], ) diff --git a/ui/webapp.py b/ui/webapp.py index 2dbd1bcbc..04b93e9d4 100644 --- a/ui/webapp.py +++ b/ui/webapp.py @@ -164,7 +164,13 @@ Ask any question on this topic and see if Haystack can find the correct answer t st.session_state.random_question_requested = True # Re-runs the script setting the random question as the textbox value # Unfortunately necessary as the Random Question button is _below_ the textbox - raise st.scriptrunner.script_runner.RerunException(st.scriptrunner.script_requests.RerunData(None)) + if hasattr(st, "scriptrunner"): + raise st.scriptrunner.script_runner.RerunException( + st.scriptrunner.script_requests.RerunData(widget_states=None) + ) + raise st.runtime.scriptrunner.script_runner.RerunException( + st.runtime.scriptrunner.script_requests.RerunData(widget_states=None) + ) st.session_state.random_question_requested = False run_query = (