Please upgrade, redesign and improve this gui with all the features and flashy animations and verbose logging every step that you could possibly implement to have this look and be as impressive as possible: import os
import subprocess
from huggingface_hub import InferenceClient
import tkinter as tk
from tkinter import scrolledtext

# Initialize the LLM client
client = InferenceClient(
    "mistralai/Mistral-7B-Instruct-v0.3",
    token="<TRUFFLEHOG_REDACTED_HUGGINGFACE>"
)

def create_debug_window():
    """Creates a debug window with a text area to display messages."""
    window = tk.Tk()
    window.title("Debug Window")
    window.geometry("300x800")
    text_area = scrolledtext.ScrolledText(window, wrap=tk.WORD, font=("Courier", 10), bg="lightblue", fg="black")
    text_area.pack(expand=True, fill=tk.BOTH)
    return window, text_area

def update_debug_window(text_area, message):
    """Updates the debug window with a new message."""
    text_area.insert(tk.END, message + "\n")
    text_area.see(tk.END)
    text_area.update_idletasks()

def interact_with_llm(prompt, text_area, attempts=15):
    """Interacts with the LLM to generate or correct code based on the provided prompt."""
    output_text = ""
    attempt = 0
    while attempt < attempts:
        try:
            for message in client.chat_completion(
                messages=[{"role": "user", "content": prompt}],
                max_tokens=4096,
                stream=True,
            ):
                content = message['choices'][0].get('delta', {}).get('content', '')
                output_text += content
                update_debug_window(text_area, content)  # Update debug window with LLM response
            return output_text
        except Exception as e:
            error_msg = f"BAD RESPONSE: {e}"
            update_debug_window(text_area, error_msg)
            if attempt == attempts - 1:
                update_debug_window(text_area, "This is going sideways - Halting process.")
                return None
            attempt += 1
            error_prompt = f"The previous code response was incomplete or had placeholders. NEVER USE PLACEHOLDERS. Please respond with the fully complete revision enclosed in backticks, do not print anything else. Fix:\n{output_text}\n"
            output_text = interact_with_llm(error_prompt, text_area)
    return None

def extract_code_from_llm_response(response, text_area):
    """Extracts code blocks from the LLM's response."""
    if response is None:
        return ""
    code_blocks = []
    in_code_block = False
    for line in response.splitlines():
        if line.startswith("```"):
            in_code_block = not in_code_block
        elif in_code_block:
            code_blocks.append(line)

    extracted_code = "\n".join(code_blocks)
    update_debug_window(text_area, f"Extracted code:\n{extracted_code}")
    return extracted_code

def write_code_to_file(code, project_folder, output_format, text_area):
    """Writes the extracted code to a file in the specified project folder."""
    file_extension = {"Python": ".py", "HTML": ".html", "Text": ".txt"}.get(output_format, ".txt")
    file_name = os.path.join(project_folder, f"{project_folder}{file_extension}")

    with open(file_name, 'w') as file:
        file.write(code)
        update_debug_window(text_area, f"Code written to {file_name}")
    return file_name

def execute_code(file_path, text_area):
    """Executes the code file and returns the result."""
    try:
        result = subprocess.run(["python", file_path], capture_output=True, text=True)
        update_debug_window(text_area, "Execution Output:\n" + result.stdout)
        update_debug_window(text_area, "Execution Errors:\n" + result.stderr)
        return result.returncode, result.stdout, result.stderr
    except Exception as e:
        error_msg = f"Error executing code: {e}"
        update_debug_window(text_area, error_msg)
        return 1, "", error_msg

def debug_code(code, project_folder, output_format, text_area, max_attempts=15):
    """Attempts to debug the code by interacting with the LLM until it successfully runs."""
    attempt = 0
    while attempt < max_attempts:
        update_debug_window(text_area, f"Attempt {attempt + 1}:\n")

        file_path = write_code_to_file(code, project_folder, output_format, text_area)

        returncode, stdout, stderr = execute_code(file_path, text_area)

        if returncode == 0:
            success_msg = "Code executed successfully." if output_format == "Python" else "Non-Python code, no debugging performed."
            update_debug_window(text_area, success_msg)
            update_debug_window(text_area, stdout)
            return stdout
        else:
            error_msg = "LLM is attempting to solve issues with the code:"
            update_debug_window(text_area, error_msg)
            update_debug_window(text_area, stderr)

            error_prompt = f"The following Python code has errors:\n\n{code}\n\nErrors:\n{stderr}\n\nPlease respond with only the fully corrected and complete code enclosed in backticks without using placeholders and do not print anything else."
            corrected_code = interact_with_llm(error_prompt, text_area)
            if corrected_code is None:
                break
            code = extract_code_from_llm_response(corrected_code, text_area)

        attempt += 1

    final_msg = "The LLM quit."
    update_debug_window(text_area, final_msg)
    return None

if __name__ == "__main__":
    # Create the debug window
    debug_window, debug_text_area = create_debug_window()

    # Ask for the project folder and ensure it exists
    project_folder = input("Please provide the project folder name: ")
    os.makedirs(project_folder, exist_ok=True)
    update_debug_window(debug_text_area, f"Project folder created/verified: {project_folder}")

    # Ask for the expected output format
    output_format = input("What format should the output file be (Python, HTML, Text, etc.)? ")
    update_debug_window(debug_text_area, f"Output format selected: {output_format}")

    # Ask the user for input
    structured_prompt = input("Please provide your request: ")
    update_debug_window(debug_text_area, f"User Request: {structured_prompt}")

    # Interact with the LLM to generate the initial code
    llm_response = interact_with_llm(structured_prompt, debug_text_area)
    extracted_code = extract_code_from_llm_response(llm_response, debug_text_area)

    # Debug the generated code
    debugged_code_output = debug_code(extracted_code, project_folder, output_format, debug_text_area)

    # Save the final output
    if debugged_code_output:
        final_output_file = write_code_to_file(debugged_code_output, project_folder, output_format, debug_text_area)
        final_output_msg = f"Final output saved to {final_output_file}"
        update_debug_window(debug_text_area, final_output_msg)

    # Start the Tkinter main loop to display the debug window
    debug_window.mainloop()