Write a script to have the ai in this script below be active in my cmd window. In the case of error it should suggest the corrected command and execute it.import sys
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QTextEdit, QPushButton, QLabel, QFileDialog, QMessageBox, QHBoxLayout
from PyQt6.QtGui import QPixmap
from PyQt6.QtCore import Qt
import requests
from bs4 import BeautifulSoup
import huggingface_hub

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

class LLMInteractionGUI(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle("LLM Interaction")
        self.setGeometry(100, 100, 600, 500)

        self.layout = QHBoxLayout()

        # Input box for user prompt
        self.inputBox = QTextEdit()
        self.layout.addWidget(self.inputBox)

        # Search results display
        self.searchResultsBox = QTextEdit()
        self.searchResultsBox.setReadOnly(True)
        self.layout.addWidget(self.searchResultsBox)

        # Image display label
        self.imageLabel = QLabel(self)
        self.imageLabel.setScaledContents(True)
        self.layout.addWidget(self.imageLabel)

        # LLM response display
        self.responseBox = QTextEdit()
        self.responseBox.setReadOnly(True)
        self.layout.addWidget(self.responseBox)

        # Control buttons (attach image, send prompt)
        self.controlsLayout = QVBoxLayout()

        # Attach image button
        self.attachBtn = QPushButton("Attach Image")
        self.attachBtn.clicked.connect(self.attachImage)
        self.controlsLayout.addWidget(self.attachBtn)

        # Send button for interacting with LLM
        self.sendBtn = QPushButton("Send")
        self.sendBtn.clicked.connect(self.interactWithLLM)
        self.controlsLayout.addWidget(self.sendBtn)

        # Add control buttons layout
        self.layout.addLayout(self.controlsLayout)

        # Set the layout for the main window
        self.setLayout(self.layout)

    def attachImage(self):
        """Attach an image and display it in the label."""
        image_path, _ = QFileDialog.getOpenFileName(self, 'Attach Image', '', 'Image files (*.png *.jpg *.jpeg)')
        if image_path:
            img = QPixmap(image_path)
            img = img.scaled(150, 150, Qt.AspectRatioMode.KeepAspectRatio)
            self.imageLabel.setPixmap(img)

    def interactWithLLM(self):
        """Send input to the LLM and display the response."""
        user_input = self.inputBox.toPlainText()

        if "search the web for" in user_input.lower():
            query = user_input.split("search the web for")[-1].strip()
            search_results = self.perform_web_search(query)
            self.searchResultsBox.setPlainText(search_results)

            # Combine search results for LLM processing
            combined_prompt = f"Based on the following search results for '{query}':\n{search_results}\n\nProvide a summary or answer."
            llm_response = self.get_llm_response(combined_prompt)
        else:
            llm_response = self.get_llm_response(user_input)

        self.responseBox.setPlainText(llm_response.strip())
        
        # Check for image URLs in the LLM response and display the image if found
        image_url = self.extract_image_url(llm_response)
        if image_url:
            self.display_image(image_url)

    def perform_web_search(self, query):
        """Perform a web search and return the results."""
        search_results = ""
        try:
            url = f"https://duckduckgo.com/?q={query}"
            headers = {"User-Agent": "Mozilla/5.0"}
            response = requests.get(url, headers=headers)
            response.raise_for_status()

            soup = BeautifulSoup(response.text, 'html.parser')
            results = soup.find_all('a', class_='result__a')
            if not results:
                return "No results found."

            for item in results:
                title = item.get_text()
                link = item['href']
                search_results += f"{title}: {link}\n"
        except Exception as e:
            search_results = f"Failed to perform web search: {e}"

        return search_results

    def get_llm_response(self, prompt):
        """Get a response from the Hugging Face LLM based on the user's prompt."""
        output_text = ""
        try:
            for message in client.chat_completion(
                messages=[{"role": "user", "content": prompt}],
                max_tokens=4096,
                stream=True,
            ):
                content = message['choices'][0]['delta']['content']
                output_text += content
        except Exception as e:
            output_text = f"Error interacting with LLM: {e}"
        
        return output_text

    def extract_image_url(self, response):
        """Extract an image URL from the LLM response, if any."""
        if "http" in response and (response.endswith(".jpg") or response.endswith(".png")):
            return response.strip()  # Return the URL if found
        return None

    def display_image(self, url):
        """Display an image in the GUI from the given URL."""
        try:
            response = requests.get(url)
            img = QPixmap()
            img.loadFromData(response.content)
            img = img.scaled(150, 150, Qt.AspectRatioMode.KeepAspectRatio)
            self.imageLabel.setPixmap(img)
        except Exception as e:
            QMessageBox.critical(self, "Error", f"Failed to load image: {e}")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    gui = LLMInteractionGUI()
    gui.show()
    sys.exit(app.exec())