├── LICENSE ├── README.md ├── Console5.py └── Console.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mizogg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Console-AI 2 | CMD PYTHON AI Chat 3 | 4 | ## NEW Console.py in PyQt6 5 | 6 | https://github.com/Mizogg/Console-AI/assets/88630056/b0893eb2-0140-41ba-991f-94a46aed444b 7 | 8 | 9 | Console.py is a PyQt5-based application that provides a graphical interface for executing commands and interacting with an AI model. It allows users to execute custom commands, view the command output in a console-like window, change the console color, and perform AI interactions. 10 | 11 | ![image](https://github.com/Mizogg/Console-AI/assets/88630056/5634e93f-9342-40d8-a671-7150acfdffc7) 12 | 13 | ## Features 14 | 15 | Execute custom commands: Users can input commands in the "Custom CMD here" field and click the "Execute" button to execute them. The command output is displayed in the console window. 16 | 17 | Console output styling: Users can choose from different console color schemes using the "Pick Console Colour" dropdown menu. 18 | 19 | AI Interaction: Users can have interactive conversations with an AI model by typing questions in the input field and clicking the "AI Interaction" button. The AI's response will be displayed in the console window. 20 | 21 | AI Picture: Users can ask a question and request the AI to generate images related to the question. The images will be displayed in a separate dialog box. 22 | 23 | ## Requirements 24 | Python 3.x 25 | 26 | PyQt5 27 | 28 | OpenAI API key (replace #Your API KEY with your actual API key) 29 | 30 | ## Usage 31 | Install the required dependencies (pip install PyQt5). 32 | 33 | Replace #Your API KEY with your OpenAI API key. 34 | 35 | Run the program using python program.py. 36 | 37 | The main application window will open. 38 | 39 | Enter custom commands in the "Custom CMD here" field and click the "Execute" button to run them. 40 | 41 | Use the "Pick Console Colour" dropdown menu to change the console color scheme. 42 | 43 | Click the "AI Interaction" button to have interactive conversations with the AI. 44 | 45 | Click the "AI Picture" button to generate and view images related to a question. 46 | 47 | Note: This program requires an active internet connection to interact with the OpenAI API and retrieve image data. 48 | 49 | ## License 50 | This program is licensed under the MIT License. 51 | -------------------------------------------------------------------------------- /Console5.py: -------------------------------------------------------------------------------- 1 | 2 | import signal 3 | import subprocess 4 | from PyQt5.QtCore import QThread, pyqtSignal, pyqtSlot, Qt, QTimer 5 | from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPlainTextEdit, QHBoxLayout, QLabel, QLineEdit, QPushButton, QComboBox, QApplication, QSizePolicy, QMainWindow, QDialog, QGridLayout, QFrame, QSpinBox 6 | from PyQt5.QtGui import QFont, QPixmap 7 | import openai 8 | import requests 9 | import os, sys, platform 10 | is_windows = True if platform.system() == "Windows" else False 11 | 12 | if is_windows: 13 | os.system("title Mizogg @ github.com/Mizogg") 14 | 15 | def water(text): 16 | os.system(""); faded = "" 17 | green = 10 18 | for line in text.splitlines(): 19 | faded += (f"\033[38;2;0;{green};255m{line}\033[0m\n") 20 | if not green == 255: 21 | green += 15 22 | if green > 255: 23 | green = 255 24 | return faded 25 | 26 | def red(text): 27 | os.system(""); faded = "" 28 | for line in text.splitlines(): 29 | green = 250 30 | for character in line: 31 | green -= 5 32 | if green < 0: 33 | green = 0 34 | faded += (f"\033[38;2;255;{green};0m{character}\033[0m") 35 | faded += "\n" 36 | return faded 37 | 38 | class CommandThread(QThread): 39 | commandOutput = pyqtSignal(str) 40 | commandFinished = pyqtSignal(int) 41 | 42 | def __init__(self, command): 43 | super().__init__() 44 | self.command = command 45 | self.process = None 46 | 47 | def run(self): 48 | if self.command.startswith('python'): 49 | script = self.command[7:].strip() 50 | if script.endswith('.py'): 51 | self.process = subprocess.Popen( 52 | self.command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, 53 | universal_newlines=True 54 | ) 55 | for line in self.process.stdout: 56 | output = line.strip() 57 | self.commandOutput.emit(output) 58 | self.process.stdout.close() 59 | self.commandFinished.emit(self.process.wait()) 60 | else: 61 | try: 62 | result = eval(self.command[7:]) 63 | self.commandOutput.emit(str(result)) 64 | self.commandFinished.emit(0) 65 | except Exception as e: 66 | self.commandOutput.emit(str(e)) 67 | self.commandFinished.emit(1) 68 | else: 69 | self.process = subprocess.Popen( 70 | self.command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, 71 | universal_newlines=True 72 | ) 73 | for line in self.process.stdout: 74 | output = line.strip() 75 | self.commandOutput.emit(output) 76 | self.process.stdout.close() 77 | self.commandFinished.emit(self.process.wait()) 78 | 79 | class ConsoleWindow(QWidget): 80 | def __init__(self, parent=None): 81 | super().__init__(parent) 82 | self.layout = QVBoxLayout(self) 83 | self.consoleOutput = QPlainTextEdit(self) 84 | self.consoleOutput.setReadOnly(True) 85 | self.consoleOutput.setFont(QFont("Courier")) 86 | self.layout.addWidget(self.consoleOutput) 87 | self.layout.setContentsMargins(0, 0, 0, 0) 88 | self.consoleOutput.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) 89 | 90 | @pyqtSlot(int) 91 | def update_console_style(self, index): 92 | if index == 1: 93 | self.consoleOutput.setStyleSheet("background-color: white; color: purple; font-size: 14px;") 94 | elif index == 2: 95 | self.consoleOutput.setStyleSheet("background-color: black; color: green; font-size: 14px;") 96 | elif index == 3: 97 | self.consoleOutput.setStyleSheet("background-color: red; color: blue; font-size: 14px;") 98 | 99 | @pyqtSlot(str) 100 | def append_output(self, output): 101 | self.consoleOutput.appendPlainText(output) 102 | 103 | class ImageViewerDialog(QDialog): 104 | def __init__(self, image_urls, parent=None): 105 | super().__init__(parent) 106 | self.setWindowTitle("Image Viewer") 107 | self.layout = QGridLayout(self) 108 | 109 | row = 0 110 | col = 0 111 | for image_url in image_urls: 112 | frame = QFrame(self) 113 | frame.setFrameShape(QFrame.StyledPanel) 114 | frame.setLineWidth(1) 115 | frame_layout = QVBoxLayout(frame) 116 | image_label = QLabel(self) 117 | frame_layout.addWidget(image_label) 118 | 119 | response = requests.get(image_url) 120 | pixmap = QPixmap() 121 | pixmap.loadFromData(response.content) 122 | image_label.setPixmap(pixmap.scaledToWidth(1000)) 123 | image_label.setAlignment(Qt.AlignCenter) 124 | self.layout.addWidget(frame, row, col) 125 | col += 1 126 | if col > 1: 127 | col = 0 128 | row += 1 129 | 130 | self.setMinimumSize(900, 500) 131 | 132 | class MainWindow(QWidget): 133 | def __init__(self, parent=None): 134 | super().__init__(parent) 135 | self.setWindowTitle("Console.py") 136 | self.setGeometry(100, 100, 780, 560) 137 | self.process = None 138 | self.commandThread = None 139 | self.scanning = False 140 | self.initUI() 141 | openai.api_key = '' #Your API KEY 142 | 143 | def initUI(self): 144 | self.timer = QTimer(self) 145 | self.timer.timeout.connect(self.update_gui) 146 | self.layout = QVBoxLayout(self) 147 | self.consoleWindow = ConsoleWindow(self) 148 | self.layout.addWidget(self.consoleWindow) 149 | 150 | self.customLayout = QHBoxLayout() 151 | self.layout.addLayout(self.customLayout) 152 | self.customLabel = QLabel("Custom CMD here:", self) 153 | self.customLayout.addWidget(self.customLabel) 154 | self.inputcustomEdit = QLineEdit(self) 155 | self.inputcustomEdit.setPlaceholderText('Type command') 156 | self.inputcustomEdit.returnPressed.connect(self.custom_start) 157 | self.customLayout.addWidget(self.inputcustomEdit) 158 | 159 | self.customButton = QPushButton("Execute", self) 160 | self.customButton.setStyleSheet("color: green;") 161 | self.customButton.clicked.connect(self.custom_start) 162 | self.customLayout.addWidget(self.customButton) 163 | self.stopButton = QPushButton("Stop", self) 164 | self.stopButton.setStyleSheet("color: red;") 165 | self.stopButton.clicked.connect(self.stop_exe) 166 | self.customLayout.addWidget(self.stopButton) 167 | 168 | self.aiButton = QPushButton("AI Interaction", self) 169 | self.aiButton.setStyleSheet("color: blue;") 170 | self.aiButton.clicked.connect(self.ai_interaction) 171 | self.customLayout.addWidget(self.aiButton) 172 | 173 | self.aiPictureLayout = QHBoxLayout() 174 | self.aiPictureButton = QPushButton("AI Picture", self) 175 | self.aiPictureButton.setStyleSheet("color: orange;") 176 | self.aiPictureButton.clicked.connect(self.ai_picture) 177 | self.aiPictureLayout.addWidget(self.aiPictureButton) 178 | self.pictureSpinBox = QSpinBox(self) 179 | self.pictureSpinBox.setMinimum(1) 180 | self.pictureSpinBox.setValue(1) 181 | self.aiPictureLayout.addWidget(self.pictureSpinBox) 182 | self.customLayout.addLayout(self.aiPictureLayout) 183 | 184 | self.colourLayout = QHBoxLayout() 185 | self.colorlable = QLabel( 186 | ' Pick Console Colour ', self 187 | ) 188 | self.colorlable.setAlignment(Qt.AlignRight) 189 | self.colorComboBox = QComboBox(self) 190 | self.colorComboBox.addItem("Pick Console Colour") 191 | self.colorComboBox.addItem("Option 1: White Background, Purple Text") 192 | self.colorComboBox.addItem("Option 2: Black Background, Green Text") 193 | self.colorComboBox.addItem("Option 3: Red Background, Blue Text") 194 | self.colorComboBox.currentIndexChanged.connect(self.update_console_style) 195 | self.colourLayout.addWidget(self.colorlable) 196 | self.colourLayout.addWidget(self.colorComboBox) 197 | self.layout.addLayout(self.colourLayout) 198 | 199 | self.layout.setContentsMargins(0, 0, 0, 0) 200 | 201 | def custom_start(self): 202 | command = self.inputcustomEdit.text().strip() 203 | self.execute_command(command) 204 | 205 | def execute_command(self, command): 206 | if self.scanning: 207 | return 208 | 209 | self.scanning = True 210 | 211 | if self.commandThread and self.commandThread.isRunning(): 212 | self.commandThread.terminate() 213 | self.consoleWindow.append_output(f"> {command}") 214 | self.consoleWindow.append_output("") 215 | self.commandThread = CommandThread(command) 216 | self.commandThread.commandOutput.connect(self.append_output) 217 | self.commandThread.commandFinished.connect(self.command_finished) 218 | self.commandThread.start() 219 | self.timer.start(100) 220 | 221 | def stop_exe(self): 222 | if self.commandThread and self.commandThread.isRunning(): 223 | if platform.system() == "Windows": 224 | subprocess.Popen(["taskkill", "/F", "/T", "/PID", str(self.commandThread.process.pid)]) 225 | else: 226 | os.killpg(os.getpgid(self.commandThread.process.pid), signal.SIGTERM) 227 | 228 | self.timer.stop() 229 | self.scanning = False 230 | returncode = 'Closed' 231 | self.command_finished(returncode) 232 | 233 | @pyqtSlot(str) 234 | def append_output(self, output): 235 | self.consoleWindow.append_output(output) 236 | 237 | @pyqtSlot(int) 238 | def command_finished(self, returncode): 239 | self.timer.stop() 240 | self.scanning = False 241 | 242 | if returncode == 0: 243 | self.append_output("Command execution finished successfully") 244 | elif returncode == 'Closed': 245 | self.append_output("Process has been stopped by the user") 246 | else: 247 | self.append_output("Command execution failed") 248 | 249 | @pyqtSlot(int) 250 | def update_console_style(self, index): 251 | self.consoleWindow.update_console_style(index) 252 | 253 | def ai_interaction(self): 254 | question = self.inputcustomEdit.text().strip() 255 | self.consoleWindow.append_output(f"> {question}") 256 | self.consoleWindow.append_output("") 257 | ai_response = self.complete_chat(question) 258 | self.consoleWindow.append_output(ai_response) 259 | self.consoleWindow.append_output("") 260 | 261 | def ai_picture(self): 262 | question = self.inputcustomEdit.text().strip() 263 | self.consoleWindow.append_output(f"> {question}") 264 | self.consoleWindow.append_output("") 265 | ai_response = self.complete_chat(question) 266 | n = self.pictureSpinBox.value() 267 | res = openai.Image.create(prompt=question, n=n, size="1024x1024") 268 | image_urls = [item['url'] for item in res["data"]] 269 | 270 | dialog = ImageViewerDialog(image_urls, self) 271 | dialog.exec_() 272 | 273 | def complete_chat(self, prompt): 274 | response = openai.Completion.create( 275 | engine='text-davinci-003', 276 | prompt=prompt, 277 | max_tokens=1000, 278 | temperature=0.7, 279 | n=1, 280 | stop=None, 281 | ) 282 | return response.choices[0].text.strip() 283 | 284 | def update_gui(self): 285 | QApplication.processEvents() 286 | 287 | 288 | if __name__ == '__main__': 289 | mizogg= f''' 290 | ___ ___ 291 | (o o) (o o) 292 | ( V ) MIZOGG ( V ) 293 | --m-m------------m-m-- 294 | © mizogg.co.uk 2018 - 2023 295 | 296 | Console.py 297 | 298 | VIP PROJECT Mizogg 299 | 300 | {red(f"[>] Running with Python {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}")} 301 | 302 | 303 | ''' 304 | print(water(mizogg), end="") 305 | app = QApplication(sys.argv) 306 | mainWindow = MainWindow() 307 | mainWindow.show() 308 | sys.exit(app.exec_()) 309 | -------------------------------------------------------------------------------- /Console.py: -------------------------------------------------------------------------------- 1 | import signal 2 | import subprocess 3 | from PyQt6.QtCore import * 4 | from PyQt6.QtWidgets import * 5 | from PyQt6.QtGui import * 6 | import openai 7 | import requests 8 | import os, sys, platform 9 | is_windows = True if platform.system() == "Windows" else False 10 | 11 | mizogg1 = f''' 12 | 13 | Made by Mizogg Version 2.1 © mizogg.co.uk 2018 - 2023 {f"[>] Running with Python {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}"} 14 | 15 | ''' 16 | 17 | if is_windows: 18 | os.system("title Mizogg @ github.com/Mizogg") 19 | 20 | def water(text): 21 | os.system(""); faded = "" 22 | green = 10 23 | for line in text.splitlines(): 24 | faded += (f"\033[38;2;0;{green};255m{line}\033[0m\n") 25 | if not green == 255: 26 | green += 15 27 | if green > 255: 28 | green = 255 29 | return faded 30 | 31 | def red(text): 32 | os.system(""); faded = "" 33 | for line in text.splitlines(): 34 | green = 250 35 | for character in line: 36 | green -= 5 37 | if green < 0: 38 | green = 0 39 | faded += (f"\033[38;2;255;{green};0m{character}\033[0m") 40 | faded += "\n" 41 | return faded 42 | 43 | class CommandThread(QThread): 44 | commandOutput = pyqtSignal(str) 45 | commandFinished = pyqtSignal(int) 46 | 47 | def __init__(self, command): 48 | super().__init__() 49 | self.command = command 50 | self.process = None 51 | 52 | def run(self): 53 | if self.command.startswith('python'): 54 | script = self.command[7:].strip() 55 | if script.endswith('.py'): 56 | self.process = subprocess.Popen( 57 | self.command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, 58 | universal_newlines=True 59 | ) 60 | for line in self.process.stdout: 61 | output = line.strip() 62 | self.commandOutput.emit(output) 63 | self.process.stdout.close() 64 | self.commandFinished.emit(self.process.wait()) 65 | else: 66 | try: 67 | result = eval(self.command[7:]) 68 | self.commandOutput.emit(str(result)) 69 | self.commandFinished.emit(0) 70 | except Exception as e: 71 | self.commandOutput.emit(str(e)) 72 | self.commandFinished.emit(1) 73 | else: 74 | self.process = subprocess.Popen( 75 | self.command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, 76 | universal_newlines=True 77 | ) 78 | for line in self.process.stdout: 79 | output = line.strip() 80 | self.commandOutput.emit(output) 81 | self.process.stdout.close() 82 | self.commandFinished.emit(self.process.wait()) 83 | 84 | class ConsoleWindow(QWidget): 85 | def __init__(self, parent=None): 86 | super().__init__(parent) 87 | self.layout = QVBoxLayout(self) 88 | self.consoleOutput = QPlainTextEdit(self) 89 | self.consoleOutput.setReadOnly(True) 90 | self.consoleOutput.setFont(QFont("Courier")) 91 | self.layout.addWidget(self.consoleOutput) 92 | self.layout.setContentsMargins(10, 10, 10, 10) 93 | self.consoleOutput.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) 94 | 95 | @pyqtSlot(int) 96 | def update_console_style(self, index): 97 | if index == 1: 98 | self.consoleOutput.setStyleSheet("background-color: white; color: purple; font-size: 18px;") 99 | elif index == 2: 100 | self.consoleOutput.setStyleSheet("background-color: black; color: green; font-size: 18px;") 101 | elif index == 3: 102 | self.consoleOutput.setStyleSheet("background-color: white; color: blue; font-size: 18px;") 103 | else: 104 | self.consoleOutput.setStyleSheet("background-color: white; color: red; font-size: 18px;") 105 | 106 | @pyqtSlot(str) 107 | def append_output(self, output): 108 | self.consoleOutput.appendPlainText(output) 109 | 110 | def clear_output(self): 111 | self.consoleOutput.setPlainText("") 112 | 113 | class ImageViewerDialog(QDialog): 114 | def __init__(self, image_urls, parent=None): 115 | super().__init__(parent) 116 | self.setWindowTitle("Image Viewer") 117 | self.layout = QGridLayout(self) 118 | 119 | row = 0 120 | col = 0 121 | for image_url in image_urls: 122 | frame = QFrame(self) 123 | frame.setFrameShape(QFrame.Shape.Box) # Corrected line 124 | frame.setLineWidth(1) 125 | frame_layout = QVBoxLayout(frame) 126 | image_label = QLabel(self) 127 | frame_layout.addWidget(image_label) 128 | 129 | response = requests.get(image_url) 130 | pixmap = QPixmap() 131 | pixmap.loadFromData(response.content) 132 | image_label.setPixmap(pixmap.scaledToWidth(1000)) 133 | image_label.setAlignment(Qt.AlignmentFlag.AlignCenter) 134 | self.layout.addWidget(frame, row, col) 135 | col += 1 136 | if col > 1: 137 | col = 0 138 | row += 1 139 | 140 | self.setMinimumSize(900, 500) 141 | def show_dialog(self): 142 | self.exec() 143 | 144 | class KnightRiderWidget(QWidget): 145 | def __init__(self, parent=None): 146 | super().__init__(parent) 147 | self.timer = QTimer(self) 148 | self.timer.timeout.connect(self.update) 149 | self.position = 0 150 | self.direction = 1 151 | self.lightWidth = 20 152 | self.lightHeight = 10 153 | self.lightSpacing = 10 154 | self.lightColor = QColor(255, 0, 0) 155 | self.setContentsMargins(0, 0, 0, 0) 156 | self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) 157 | 158 | def startAnimation(self): 159 | self.timer.start(1) 160 | 161 | def stopAnimation(self): 162 | self.timer.stop() 163 | 164 | def paintEvent(self, event): 165 | painter = QPainter(self) 166 | painter.setRenderHint(QPainter.RenderHint.Antialiasing) 167 | painter.setPen(Qt.PenStyle.NoPen) 168 | 169 | for i in range(12): 170 | lightX = self.position + i * (self.lightWidth + self.lightSpacing) 171 | lightRect = QRect(lightX, 0, self.lightWidth, self.lightHeight) 172 | painter.setBrush(self.lightColor) 173 | painter.drawRoundedRect(lightRect, 5, 5) 174 | 175 | def update(self): 176 | self.position += self.direction 177 | if self.position <= 0 or self.position >= self.width() - self.lightWidth - self.lightSpacing: 178 | self.direction *= -1 179 | self.repaint() 180 | 181 | def setLightColor(self, color): 182 | self.lightColor = color 183 | self.repaint() 184 | 185 | class MainWindow(QWidget): 186 | def __init__(self, parent=None): 187 | super().__init__(parent) 188 | self.setWindowTitle("Console.py") 189 | self.setGeometry(100, 100, 780, 560) 190 | self.process = None 191 | self.commandThread = None 192 | self.scanning = False 193 | self.centralWidget = QWidget(self) 194 | 195 | self.initUI() 196 | openai.api_key = '' #Your API KEY 197 | 198 | def initUI(self): 199 | self.timer = QTimer(self) 200 | self.timer.timeout.connect(self.update_gui) 201 | self.layout = QVBoxLayout(self) 202 | self.consoleWindow = ConsoleWindow(self) 203 | self.layout.addWidget(self.consoleWindow) 204 | 205 | self.customLayout = QHBoxLayout() 206 | self.layout.addLayout(self.customLayout) 207 | self.customLabel = QLabel("Custom CMD here:", self) 208 | self.customLayout.addWidget(self.customLabel) 209 | self.inputcustomEdit = QLineEdit(self) 210 | self.inputcustomEdit.setPlaceholderText('Type command') 211 | self.inputcustomEdit.returnPressed.connect(self.custom_start) 212 | self.customLayout.addWidget(self.inputcustomEdit) 213 | 214 | self.customButton = QPushButton("Execute", self) 215 | self.customButton.setStyleSheet("color: green;") 216 | self.customButton.clicked.connect(self.custom_start) 217 | self.customLayout.addWidget(self.customButton) 218 | self.stopButton = QPushButton("Stop", self) 219 | self.stopButton.setStyleSheet("color: red;") 220 | self.stopButton.clicked.connect(self.stop_exe) 221 | self.customLayout.addWidget(self.stopButton) 222 | 223 | self.aiButton = QPushButton("AI Interaction", self) 224 | self.aiButton.setStyleSheet("color: blue;") 225 | self.aiButton.clicked.connect(self.ai_interaction) 226 | self.customLayout.addWidget(self.aiButton) 227 | 228 | self.aiPictureLayout = QHBoxLayout() 229 | self.aiPictureButton = QPushButton("AI Picture", self) 230 | self.aiPictureButton.setStyleSheet("color: orange;") 231 | self.aiPictureButton.clicked.connect(self.ai_picture) 232 | self.aiPictureLayout.addWidget(self.aiPictureButton) 233 | self.pictureSpinBox = QSpinBox(self) 234 | self.pictureSpinBox.setMinimum(1) 235 | self.pictureSpinBox.setValue(1) 236 | self.aiPictureLayout.addWidget(self.pictureSpinBox) 237 | self.customLayout.addLayout(self.aiPictureLayout) 238 | 239 | self.colourWidget = QWidget() 240 | self.colourLayout = QHBoxLayout(self.colourWidget) 241 | self.colorlable = QLabel('Pick Console Colour', self) 242 | self.colorlable.setStyleSheet("font-size: 16px; font-weight: bold; color: red;") 243 | 244 | self.colorComboBox = QComboBox(self) 245 | self.colorComboBox.addItem("Pick Console Colour") 246 | self.colorComboBox.addItem("Option 1: White Background, Purple Text") 247 | self.colorComboBox.addItem("Option 2: Black Background, Green Text") 248 | self.colorComboBox.addItem("Option 3: White Background, Blue Text") 249 | self.colorComboBox.currentIndexChanged.connect(self.update_knight_rider_color) 250 | self.colorComboBox.currentIndexChanged.connect(self.update_console_style) 251 | self.layout.addWidget(self.colorlable) 252 | self.layout.addWidget(self.colorComboBox) 253 | 254 | self.knightRiderWidget = KnightRiderWidget(self) 255 | self.knightRiderWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) 256 | self.knightRiderWidget.setMinimumHeight(25) 257 | self.knightRiderLayout = QHBoxLayout() 258 | self.knightRiderLayout.setContentsMargins(10, 10, 10, 10) 259 | self.knightRiderLayout.addWidget(self.knightRiderWidget) 260 | 261 | self.knightRiderGroupBox = QGroupBox(self) 262 | self.knightRiderGroupBox.setTitle("Running Process ") 263 | self.knightRiderGroupBox.setStyleSheet("QGroupBox { border: 3px solid red; padding: 15px; }") 264 | self.knightRiderGroupBox.setLayout(self.knightRiderLayout) 265 | self.mizogg_label = QLabel(mizogg1, self) 266 | self.mizogg_label.setStyleSheet("font-size: 16px; font-weight: bold; color: red;") 267 | self.mizogg_label.setAlignment(Qt.AlignmentFlag.AlignCenter) 268 | self.layout.addWidget(self.knightRiderGroupBox) 269 | self.layout.addWidget(self.mizogg_label) 270 | 271 | def custom_start(self): 272 | command = self.inputcustomEdit.text().strip() 273 | self.execute_command(command) 274 | 275 | def execute_command(self, command): 276 | if self.scanning: 277 | return 278 | 279 | self.scanning = True 280 | self.knightRiderWidget.startAnimation() 281 | 282 | if self.commandThread and self.commandThread.isRunning(): 283 | self.commandThread.terminate() 284 | self.consoleWindow.append_output(f"> {command}") 285 | self.consoleWindow.append_output("") 286 | self.commandThread = CommandThread(command) 287 | self.commandThread.commandOutput.connect(self.append_output) 288 | self.commandThread.commandFinished.connect(self.command_finished) 289 | self.commandThread.start() 290 | self.timer.start(100) 291 | 292 | 293 | def stop_exe(self): 294 | if self.commandThread and self.commandThread.isRunning(): 295 | if platform.system() == "Windows": 296 | subprocess.Popen(["taskkill", "/F", "/T", "/PID", str(self.commandThread.process.pid)]) 297 | else: 298 | os.killpg(os.getpgid(self.commandThread.process.pid), signal.SIGTERM) 299 | 300 | self.timer.stop() 301 | self.scanning = False 302 | returncode = 'Closed' 303 | self.command_finished(returncode) 304 | 305 | @pyqtSlot(str) 306 | def append_output(self, output): 307 | self.consoleWindow.append_output(output) 308 | 309 | @pyqtSlot(int) 310 | def command_finished(self, returncode): 311 | self.timer.stop() 312 | self.scanning = False 313 | self.knightRiderWidget.stopAnimation() 314 | if returncode == 0: 315 | self.append_output("Command execution finished successfully") 316 | elif returncode == 'Closed': 317 | self.append_output("Process has been stopped by the user") 318 | else: 319 | self.append_output("Command execution failed") 320 | 321 | def ai_interaction(self): 322 | question = self.inputcustomEdit.text().strip() 323 | self.consoleWindow.append_output(f"> {question}") 324 | self.consoleWindow.append_output("") 325 | ai_response = self.complete_chat(question) 326 | self.consoleWindow.append_output(ai_response) 327 | self.consoleWindow.append_output("") 328 | 329 | def ai_picture(self): 330 | question = self.inputcustomEdit.text().strip() 331 | self.consoleWindow.append_output(f"> {question}") 332 | self.consoleWindow.append_output("") 333 | ai_response = self.complete_chat(question) 334 | n = self.pictureSpinBox.value() 335 | res = openai.Image.create(prompt=question, n=n, size="1024x1024") 336 | image_urls = [item['url'] for item in res["data"]] 337 | 338 | dialog = ImageViewerDialog(image_urls, self) 339 | dialog.show_dialog() 340 | 341 | def complete_chat(self, prompt): 342 | response = openai.Completion.create( 343 | engine='text-davinci-003', 344 | prompt=prompt, 345 | max_tokens=1000, 346 | temperature=0.7, 347 | n=1, 348 | stop=None, 349 | ) 350 | return response.choices[0].text.strip() 351 | 352 | @pyqtSlot(int) 353 | def update_console_style(self, index): 354 | self.consoleWindow.update_console_style(index) 355 | 356 | def update_knight_rider_color(self, index): 357 | if index == 1: 358 | color = QColor(128, 0, 128) # Purple 359 | elif index == 2: 360 | color = QColor(0, 128, 0) # Green 361 | elif index == 3: 362 | color = QColor(0, 0, 255) # Blue 363 | else: 364 | color = QColor(255, 0, 0) # Default: Red 365 | border_color = f"border: 3px solid {color.name()};" 366 | style_sheet = f"QGroupBox {{ {border_color} padding: 15px; }}" 367 | for widget in self.findChildren(QGroupBox): 368 | widget.setStyleSheet(style_sheet) 369 | self.knightRiderGroupBox.setStyleSheet(style_sheet) 370 | miz = f"font-size: 16px; font-weight: bold; color: {color.name()};" 371 | self.mizogg_label.setStyleSheet(miz) 372 | color_lab = f"font-size: 16px; font-weight: bold; color: {color.name()};" 373 | self.colorlable.setStyleSheet(color_lab) 374 | self.knightRiderWidget.setLightColor(color) 375 | 376 | def update_gui(self): 377 | QApplication.processEvents() 378 | 379 | 380 | if __name__ == '__main__': 381 | mizogg= f''' 382 | ___ ___ 383 | (o o) (o o) 384 | ( V ) MIZOGG ( V ) 385 | --m-m------------m-m-- 386 | © mizogg.co.uk 2018 - 2023 387 | 388 | Console.py 389 | 390 | VIP PROJECT Mizogg 391 | 392 | {red(f"[>] Running with Python {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}")} 393 | 394 | 395 | ''' 396 | print(water(mizogg), end="") 397 | app = QApplication(sys.argv) 398 | mainWindow = MainWindow() 399 | mainWindow.show() 400 | sys.exit(app.exec()) 401 | --------------------------------------------------------------------------------