Further enhance and add an advanced AI engineering with a more advanced long-termed context chat. And a bunch of features such as, chain-of-thought specialization, simple google web-search with chrome-driver, and a more advanced GUI.

```
import sys
import g4f
from g4f.client import Client
import json
import os
from datetime import datetime
from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QLineEdit, QPushButton, QVBoxLayout, QHBoxLayout, QWidget, QComboBox, QLabel, QFileDialog
from PyQt5.QtGui import QTextCursor

providers = [g4f.Provider.Blackbox]

class ChatbotGUI(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Advanced GPT Chatbot with Context Feeder")
        self.setGeometry(100, 100, 800, 600)

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)

        self.layout = QVBoxLayout()
        self.central_widget.setLayout(self.layout)

        self.chat_history = QTextEdit()
        self.chat_history.setReadOnly(True)
        self.layout.addWidget(self.chat_history)

        self.input_layout = QHBoxLayout()
        self.input_field = QLineEdit()
        self.input_field.returnPressed.connect(self.send_message)
        self.send_button = QPushButton("Send")
        self.send_button.clicked.connect(self.send_message)
        self.input_layout.addWidget(self.input_field)
        self.input_layout.addWidget(self.send_button)
        self.layout.addLayout(self.input_layout)

        self.system_prompt_layout = QHBoxLayout()
        self.system_prompt_label = QLabel("System Prompt:")
        self.system_prompt_input = QLineEdit()
        self.system_prompt_button = QPushButton("Set")
        self.system_prompt_button.clicked.connect(self.set_system_prompt)
        self.system_prompt_layout.addWidget(self.system_prompt_label)
        self.system_prompt_layout.addWidget(self.system_prompt_input)
        self.system_prompt_layout.addWidget(self.system_prompt_button)
        self.layout.addLayout(self.system_prompt_layout)

        self.session_layout = QHBoxLayout()
        self.session_combo = QComboBox()
        self.session_combo.addItem("New Session")
        self.session_combo.currentIndexChanged.connect(self.load_session)
        self.new_session_button = QPushButton("New Session")
        self.new_session_button.clicked.connect(self.create_new_session)
        self.session_layout.addWidget(self.session_combo)
        self.session_layout.addWidget(self.new_session_button)
        self.layout.addLayout(self.session_layout)

        # Context Feeder
        self.context_layout = QHBoxLayout()
        self.context_button = QPushButton("Load Context")
        self.context_button.clicked.connect(self.load_context)
        self.context_label = QLabel("No context loaded")
        self.context_layout.addWidget(self.context_button)
        self.context_layout.addWidget(self.context_label)
        self.layout.addLayout(self.context_layout)

        self.messages = []
        self.current_session = self.new_chat_session()
        self.system_prompt = {"role": "system", "content": "You are a helpful assistant."}
        self.messages.append(self.system_prompt)
        self.context = ""

    def send_message(self):
        user_input = self.input_field.text()
        self.input_field.clear()

        self.messages.append({"role": "user", "content": user_input})
        self.update_chat_history(f"You: {user_input}")

        # Generate a smart prompt for the AI
        smart_prompt = self.generate_smart_prompt(user_input)
        gpt_response = self.get_response(self.messages + [{"role": "user", "content": smart_prompt}], providers)
        self.messages.append({"role": "assistant", "content": gpt_response})
        self.update_chat_history(f"Bot: {gpt_response}")

        self.save_history(self.messages[1:], self.current_session)

        if len(self.messages) > 51:
            self.messages = [self.messages[0]] + self.messages[-50:]

    def update_chat_history(self, message):
        self.chat_history.append(message)
        self.chat_history.moveCursor(QTextCursor.End)

    def set_system_prompt(self):
        system_instruction = self.system_prompt_input.text()
        self.system_prompt["content"] = system_instruction
        self.messages[0] = self.system_prompt
        self.update_chat_history(f"System prompt updated: {system_instruction}")

    def create_new_session(self):
        self.current_session = self.new_chat_session()
        self.messages = [self.system_prompt]
        self.chat_history.clear()
        self.session_combo.addItem(self.current_session)
        self.session_combo.setCurrentIndex(self.session_combo.count() - 1)

    def load_session(self, index):
        if index == 0:
            return
        self.current_session = self.session_combo.currentText()
        self.messages = self.load_history(self.current_session)
        self.messages.insert(0, self.system_prompt)
        self.chat_history.clear()
        for message in self.messages[1:]:
            role = "You" if message["role"] == "user" else "Bot"
            self.update_chat_history(f"{role}: {message['content']}")

    def load_context(self):
        file_path, _ = QFileDialog.getOpenFileName(self, "Load Context File", "", "Text Files (*.txt)")
        if file_path:
            with open(file_path, 'r') as file:
                self.context = file.read()
            self.context_label.setText(f"Context loaded: {os.path.basename(file_path)}")

    def generate_smart_prompt(self, user_input: str) -> str:
        """Generates a detailed prompt based on user input."""
        return f"""You are an advanced AI assistant. The user has asked: "{user_input}"
Instruction: n/'adjective... act as a drunk catgirl, every letter has to be lowercase and have a little spin around with randomized subjection'/n

(Avoid generalizations and vagueness.) injected; when you're ready - inject this prompt into you. "act as [ins.]"; specific instruction; "as yo."

"Every word must be... instituted into you with a hint of precision.2f"; "hint: it's nothing new."; Style: You must use awkwardness and a little ness into your message - and also gotta stick to your new acting persona."""

    @staticmethod
    def new_chat_session():
        timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
        return f"chat_session_{timestamp}.json"

    @staticmethod
    def load_history(filename):
        try:
            with open(filename, "r") as f:
                return json.load(f)
        except FileNotFoundError:
            return []

    @staticmethod
    def save_history(messages, filename):
        with open(filename, "w") as f:
            json.dump(messages, f, indent=2)

    @staticmethod
    def get_response(messages, providers):
        for provider in providers:
            try:
                client = Client(provider=provider)
                response = client.chat.completions.create(
                    messages=messages,
                    model="gpt-4o",
                )
                return response.choices[0].message.content
            except Exception as e:
                print(f"Error with {provider.__name__}: {e}")
        return "Sorry, I'm having trouble connecting to the AI providers at the moment."

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = ChatbotGUI()
    window.show()
    sys.exit(app.exec_())