I have a script that should open a dialog when the user clicks on a button. It works fine the first time the user clicks in the button, but after this, the dialog doesn’t open again if the user clicks on the button.
This is a screenshot of the dashboard, it displays containers with some text, links, and an image in columns. Interestingly, if the containers show fewer things (like only the images and nothing else), everything works as it should.
Thank you for the reply @raethlein. The PR’s wheel file works fine!
Is there a version of this but in version 1.34.0? For some reason, my app gets VERY slow when using streamlit > 1.34.0. So slow that my browser says that the site isn’t responding.
Great to hear that the issue would be solved by it! Thanks for testing it
And sorry to hear that you are experiencing issues with Streamlit > 1.34.0
Unfortunately, we don’t backport this kind of fixes to older versions of the library.
Though, is there an easy way to run your app locally for me? I would be really interested in looking deeper into this performance issue.
The app depends on an API, which depends on a database. To run it all you need docker to start the DB and golang installed to start the API, and also set some environment variables. It’s a little complicated, so I can’t provide an easier way.
The performance is bad only when there are more of these containers on the dashboard, and you have to add one by one to the dashboard. However, I can also upload my database volume with all set up, if you want.
Alrighty, I got it running! Do you have an idea how many items would need to exist in order for me to see the performance degradation? If it is a lot, maybe sharing your db would be nice
Great, thank you! I think I have found when this started to happen! It looks like the CSS styling introduced in this PR is problematic. I will discuss it with the team and we should hopefully come up with a fix soonish! I’ll keep you posted.
Same issue as above. When a user click on X or outside of the modal, it won’t open again.
st.rerun inside the decorated dialog function seems to rerun everything, not just the fragment. I can give an example if needed.
Here is my code for references:
import streamlit as st
from ai.assistants.chat import get_chat_assistant
from app.copilot.base import Streaming, clear_dialog, CONTAINER_HEIGHT
def set_auto_prompt(value):
st.session_state.auto_prompt = value
@st.dialog(title="Copilot", width='large')
def copilot_messenger(**copilot_params):
if 'auto_prompt' not in st.session_state:
st.session_state.auto_prompt = None
# Display the chat messages
chat_container = st.container(height=CONTAINER_HEIGHT, border=False)
with chat_container.container(): # Using the container
st.markdown("Ask me anything.")
st.markdown(":gray[EXAMPLE QUESTIONS]")
# Define columns and example buttons
cols = st.columns(2)
cols[0].button(
'What is Sharpe ratio?',
key='ex-sharpe',
on_click=set_auto_prompt,
args=('What is Sharpe ratio?',),
use_container_width=True
)
cols[1].button(
'What is Sortino ratio?',
key='ex-sortino',
on_click=set_auto_prompt,
args=('What is Sortino ratio?',),
use_container_width=True
)
cols = st.columns(2)
cols[0].button(
'What is MFE?',
key='ex-mfe',
on_click=set_auto_prompt,
args=('What is Maximum Favorable Excursion (MFE)?',),
use_container_width=True
)
cols[1].button(
'What is a frontier efficient?',
key='ex-f-eff',
on_click=set_auto_prompt,
args=('What is a frontier efficient?',),
use_container_width=True
)
# Instantiate the copilot object
streaming = Streaming(get_chat_assistant, chat_container)
# Input section
cols = st.columns([4, 1, 1])
with cols[0]:
user_prompt = st.chat_input("Ask me anything...")
with cols[1]:
cleared = st.button(
'Clear',
key='clear-ai',
use_container_width=True
)
if cleared:
clear_dialog(chat_container)
with cols[2]:
canceled = st.button(
'Cancel',
key='cancel-ai',
type='primary',
use_container_width=True
)
if canceled:
clear_dialog(chat_container)
st.rerun()
# Run copilot with the current prompt
prompt = (
user_prompt
if st.session_state.auto_prompt is None
else st.session_state.auto_prompt
)
streaming.run(prompt=prompt, **copilot_params)
# Reset the prompt input
st.session_state.auto_prompt = None
This should be fixed in the next version 1.39 which we will hopefully release this week (see this PR).
You can pass the scope argument to st.rerun like st.rerun(scope="fragment") to limit the rerun to the current fragment (which dialog uses under-the-hood).
I had a discussion with @lukasmasuch and I believe he has a solution which isn’t too nice though, which is why he wanted to spend a little more time thinking about it. So, best to keep an eye on the GitHub issue which will get updated e.g. with a relevant PR etc.
Sorry that no fix made it into 1.39, but I hope 1.40 is the one!
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.