Streamlit and Cloud Run

I am building a Web application that gives an accurate and precise list of businesses in a particular city. My app relies heavily on LLMs from openai, anthropic, and also gemini. The backend of the app is in python while I am trying to build the frontend with streamlit.

I have been successful in deploying and even running my app on the cloud run. The app is running fine on cloud run but I face two challenges

  1. Automatic Reruns: The app gives a list of business in the city of your choice based on the product and service. The results are more refined when compared to google places api which gives a more generic result. So, in middle of the search the app sometimes restarts from the beginning. That is it builds the a new fresh database again and repeats the entire process of identifying the most relevant business as per the search.
    This doesn’t happen always but sometimes. So, I want to understand why is this happening. Is it because of the web socket connection breaks and connects again and this is seen as an interaction with the widget?
  2. Tried to use SessionInfo before it was initialized: This also happens sometimes and not always. Is it because Sometimes a request might be sent to instances before startup probe results are known

I really want to dig deep into this an understand the issue as to why it is happening. If anyone’s up for discussion & debugging let’s connect and come up with a definitive answer.

I am a mechanical engineer and not a computer science engineer. My basics might not be in place but I am a fast learner.