Change Dropdown Options on_change in Text Input Widget

Hey guys,

I am trying to create this app where users can input a URL and depending on that URL, some other options are populated.

I have 3 inputs:

  • User inputs a URL (this url contains a 3d model with some metadata in it. I am using an external library to access the model and the data in it.)
  • User selects a Category. (This categories gets populated depending on the received data from the URL. I want to cache the received data so when user changes the Category, i don’t receive everything again.)
  • User selects parameter. (The parameters are filtered from the selected category. Again, when any change happens in the category input, i don’t want to rerun the whole script, and use the cached data.)

Question is

How can i populate options on the second dropdown depending on_change in the Text input without running the whole script from scratch and make it as performative as possible?

PS. Dropdown options are fetched from an external database as a list.

I am open to any help? I can even do a Zoom call if needed.

Sample Code

# import streamlit
import streamlit as st

# specklepy libraries
from specklepy.api.wrapper import StreamWrapper
from specklepy.api.client import SpeckleClient
from specklepy.api import operations
from specklepy.objects import Base

#input container
input = st.container()

with input:
    commit_url = st.text_input(
        "Commit URL",

# wrapper
wrapper = StreamWrapper(commit_url)
# client 👨‍🍳
client = wrapper.get_client()
# transport 🚚
transport = wrapper.get_transport()

# get speckle commit
commit = client.commit.get(wrapper.stream_id, wrapper.commit_id)
# get obj id from commit
obj_id = commit.referencedObject
# receive objects from speckle
commit_data = operations.receive(obj_id, transport)

with input:
    selected_category = st.selectbox(
        "Select Category",
    parameters = commit_data[selected_category][0][
    category_elements = commit_data[selected_category]
    selected_parameters = st.multiselect(
        "Select parameters",