I am using chatgpt API to make a call, display the response in a new page. Since the api call completion takes significant time I want to minimize the time caused by other processing like database write to a minimum. With that goal, I display the result on a page first and then record it. However as I do this I am re-processing the response at step #4 and #5, is there a way to avoid this re-processing (like I do for "prompt" in steps #1, #2, #3)? I can not select the screen #2 variable I assign the value in the firestore update document, it only shows the screen #1 variables. Do I need to create an App, is there a better way?
My current steps are
Process the user inputs with custom function #1 and assign it to "prompt" page state variable
Make an API call to chatgpt by using the "prompt" page state
Create a Firestore Document by using the "prompt" page state
Navigate to a new page and display the response after processing it with custom function #2
Update the Firestore Document by re-processing the same response with the same custom function #2