async () => { const urlParams = new URLSearchParams(window.location.search); const username = urlParams.get('username'); const artworkId = urlParams.get('artworkId'); const LOAD_URL = `http://127.0.0.1:5000/v1/api/load-parameters/${artworkId}`; const response = await fetch(LOAD_URL, { method: 'GET', headers: { 'X-Requested-With': 'XMLHttpRequest', } }); // Check if the response is okay if (!response.ok) { console.error("An error occurred while fetching the parameters."); return; } const parameters = await response.json(); // Assuming you're getting a JSON response // Get the necessary elements const gradioEl = document.querySelector('gradio-app'); const promptInput = gradioEl.querySelector('#prompt-text-input textarea'); const negativePromptInput = gradioEl.querySelector('#negative-prompt-text-input textarea'); // Get the slider inputs const guidanceScaleInput = gradioEl.querySelector('#guidance-scale-slider input'); const numInferenceStepInput = gradioEl.querySelector('#num-inference-step-slider input'); const imageSizeInput = gradioEl.querySelector('#image-size-slider input'); const seedInput = gradioEl.querySelector('#seed-slider input'); // Get the dropdown inputs const modelDropdown = gradioEl.querySelector('#model-dropdown input'); const schedulerDropdown = gradioEl.querySelector('#scheduler-dropdown input'); // Set the values based on the parameters received promptInput.value = parameters.text_prompt; negativePromptInput.value = parameters.negative_prompt; guidanceScaleInput.value = parameters.model_guidance_scale; numInferenceStepInput.value = parameters.model_num_steps; imageSizeInput.value = parameters.model_image_size; seedInput.value = parameters.seed; modelDropdown.value = parameters.model_name; schedulerDropdown.value = parameters.scheduler_name; }