await longRunning()

in src/panels/KaitoTestPanel.ts [96:165]


        await longRunning(`Sending query...`, async () => {
            // prevents the user from sending another query while the current one is in progress
            this.isQueryInProgress = true;
            const podName = `curl-${Date.now()}`;
            try {
                // retrieving the cluster IP
                const clusterIP = await getClusterIP(this.kubeConfigFilePath, this.modelName, this.kubectl);
                if (clusterIP === "") {
                    this.isQueryInProgress = false;
                    vscode.window.showErrorMessage(`Error connecting to cluster. Please check pod logs and try again`);
                    return;
                }
                // this command creates a curl pod and executes the query
                const createCommand = await createCurlPodCommand(
                    this.kubeConfigFilePath,
                    podName,
                    this.modelName,
                    clusterIP,
                    prompt,
                    temperature,
                    topP,
                    topK,
                    repetitionPenalty,
                    maxLength,
                );
                console.log(createCommand);
                // used to delete the curl pod after query is complete
                const deleteCommand = deleteCurlPodCommand(this.kubeConfigFilePath, podName);

                // retrieve the result of curl request from the pod
                const logsCommand = getCurlPodLogsCommand(this.kubeConfigFilePath, podName);

                // create the curl pod
                await this.kubectl.api.invokeCommand(createCommand);

                // retrieve the logs from the curl pod
                const logsResult = await this.kubectl.api.invokeCommand(logsCommand);
                if (logsResult && logsResult.code === 0) {
                    console.log(logsResult.stdout);
                    const parsedOutput = JSON.parse(logsResult.stdout);
                    // v3 parsing
                    // const responseText = JSON.parse(curlResult).Result;
                    //v4 parsing
                    const responseText = (parsedOutput.choices?.[0]?.text || "").trim();
                    webview.postTestUpdate({
                        clusterName: this.clusterName,
                        modelName: this.modelName,
                        output: responseText,
                    });
                } else if (logsResult) {
                    vscode.window.showErrorMessage(
                        `Failed to retrieve logs: ${logsResult.code}\nError: ${logsResult.stderr}`,
                    );
                } else {
                    vscode.window.showErrorMessage(`Failed to connect to cluster`);
                }
                await this.kubectl.api.invokeCommand(deleteCommand);
                this.isQueryInProgress = false;
                return;
            } catch (error) {
                // deletes pod if an error occurs during log retrieval
                const failsafeDeletion = deleteCurlPodCommand(this.kubeConfigFilePath, podName);
                await this.kubectl.api.invokeCommand(failsafeDeletion);

                // display error & reset query status
                vscode.window.showErrorMessage(`Error during operation: ${error}`);
                this.isQueryInProgress = false;
                return;
            }
        });