Pretty way to change a function’s parameters via st.dropdown if these parameters are not in app.py?

How about using session state to hold kwargs selected in the dropdown? Can’t you pass them directly as parameters?

Alternatively, put the components that are serving the app behind a FastAPI microservice running on a separate thread.

HOST = 'localhost'
PORT = 8000

def thread_runner(app, host, port):
    uvicorn.run(app, host=host, port=port)

app = FastAPI()
@app.get('/prepare_query')
def prepare_query(**kwargs):
    for name, val in kwargs.items():
        # build your query string here, do the work, and return response
        pass

thread = threading.Thread(name='QueryServer', target=thread_runner, args=(app, HOST, PORT))
thread.start()
2 Likes