Streamlit refreshes and app runs again and again

I developed a GPT-based Chatbot with streamlit. As I write the questions people ask in a database, I recognized that often the same question is asked over and over again. Always in a five-minutes intervall. So it seems streamlit somehow refreshes? This of course causes lots of costs, as GPT API is used again and again. The app runs as Docker on Google Cloud. Thanks for any help!

So a refresh causes you application call the GPT API and write to the database? You should probably fix that, unless you want to track refreshes.

Correct, my question is how to fix it :slight_smile:

In three easy steps:

  1. Delete the code that calls the API on every refresh.
  2. Write new code that calls the API only when it is appropriate in the context of your applcation.
  3. Profit!

If you get stuck in any of these steps, try showing the code to somebody more knowledgeable and ask them for advice.