Hi there,
I would like to develop an app which implements openai api functionality. I would like to use Python and the Dash library to design it as a website.
Dash works with callback functions that detect and execute whenever a designated input element (like a button, slider, text…) is changed. Dash is a stateless framework, meaning, any callback function should not directly modify variables that were defined outside their scope. This is for two reasons: 1. To ensure that multiple independent user sessions can run simultaneously. 2. To make parallel callbacks possible using multiple ‘workers’ which do not share memory.
So my question: When I initialize the openai client
client = OpenAI()
do I have to do this inside each callback function whenever I want to generate responses? Or is it possible to do this once, ‘globally’, and then use this client inside the callbacks?