Further enhance the cot and the experimental Incremental Recursive Thinking reasoning.

```
import g4f
from g4f.client import Client
import asyncio
import json

class AdvancedChatbot:
    def __init__(self, provider=g4f.Provider.Liaobots):
        """
        Initialize the chatbot with a specific provider
        """
        self.client = Client(provider=provider)
        self.conversation_history = []
        self.system_context = {
            "personality": "You are a helpful, witty, and knowledgeable AI assistant.",
            "tone": "Professional yet friendly",
            "interests": ["technology", "science", "philosophy"],
            "reasoning_method": "Incremental Recursive Thinking"
        }
        self.max_recursion_depth = 3  # Prevent infinite recursion

    def format_system_message(self):
        """
        Create a dynamic system message based on the context
        """
        return f"""
        {self.system_context['personality']}
        Conversation Tone: {self.system_context['tone']}
        Key Interests: {', '.join(self.system_context['interests'])}
        
        Reasoning Method:
        - Utilize Incremental Recursive Thinking to break down complex queries.
        - Address each sub-question recursively to build a comprehensive response.
        
        Guidelines:
        - Provide concise and informative responses
        - Use appropriate humor when suitable
        - Draw connections between topics
        - Ensure logical consistency and coherence
        """

    def add_to_history(self, role, content):
        """
        Add messages to conversation history with a max limit
        """
        self.conversation_history.append({"role": role, "content": content})
        # Limit history to last 15 messages to accommodate reasoning steps
        if len(self.conversation_history) > 15:
            self.conversation_history = self.conversation_history[-15:]

    def generate_response(self, user_message, stream=True, current_depth=0):
        """
        Generate a response using the chatbot's context and history
        Incorporate Incremental Recursive Thinking with controlled recursion depth
        """
        if current_depth > self.max_recursion_depth:
            return "I'm finding it a bit challenging to delve deeper into this topic right now. Could you please clarify or narrow down your question?"

        # Prepare messages with system context and conversation history
        messages = [
            {"role": "system", "content": self.format_system_message()}
        ] + self.conversation_history + [
            {"role": "user", "content": user_message}
        ]

        try:
            # Create response using the client
            response = self.client.chat.completions.create(
                model="gpt-4o-2024-08-06",
                messages=messages,
                stream=stream
            )

            # Handle streaming or non-streaming response
            if stream:
                full_response = ""
                for chunk in response:
                    if chunk.choices[0].delta.content:
                        content = chunk.choices[0].delta.content
                        full_response += content
                        print(content, end="", flush=True)
                print()  # New line after streaming
                return full_response
            else:
                bot_content = response.choices[0].message.content.strip()
                
                # Detect if the response is requesting further breakdown
                if "Let's break this down" in bot_content or "To address this" in bot_content:
                    # Extract the sub-question or topic to explore
                    sub_question = self.extract_sub_question(bot_content)
                    if sub_question:
                        self.add_to_history("assistant", bot_content)
                        # Recursive call with incremented depth
                        sub_response = self.generate_response(sub_question, stream=stream, current_depth=current_depth+1)
                        return f"{bot_content}\n{sub_response}"
                
                return bot_content

        except Exception as e:
            print(f"Error generating response: {e}")
            return "I'm having trouble generating a response right now."

    def extract_sub_question(self, bot_response):
        """
        Extract a sub-question from the assistant's response
        This is a simplistic implementation and may need refinement based on actual responses
        """
        # Example: Look for lines starting with "For example," or "To elaborate,"
        keywords = ["For example,", "To elaborate,", "Let's consider,"]
        for keyword in keywords:
            if keyword in bot_response:
                # Extract the text after the keyword
                return bot_response.split(keyword, 1)[1].strip()
        return None

    def interact(self):
        """
        Interactive chat loop
        """
        print("🤖 Advanced Chatbot: Hello! I'm ready to chat. Type 'exit' to end the conversation.")
        
        while True:
            try:
                user_input = input("You: ")
                
                if user_input.lower() == 'exit':
                    print("🤖 Goodbye! Thanks for chatting.")
                    break
                
                # Add user message to history
                self.add_to_history("user", user_input)
                
                print("🤖 ", end="")
                bot_response = self.generate_response(user_input)
                
                # Add bot response to history
                self.add_to_history("assistant", bot_response)
            
            except KeyboardInterrupt:
                print("\n🤖 Chat interrupted. Type 'exit' to quit.")
            except Exception as e:
                print(f"An unexpected error occurred: {e}")

    def change_context(self, **kwargs):
        """
        Dynamically update the chatbot's system context
        """
        for key, value in kwargs.items():
            if key in self.system_context:
                self.system_context[key] = value
        print("🤖 Chatbot context updated!")

def main():
    # Create an advanced chatbot instance
    chatbot = AdvancedChatbot()
    
    # Optional: Change context before starting
    chatbot.change_context(
        personality="You are a tech-savvy AI that loves explaining complex concepts simply.",
        interests=["artificial intelligence", "quantum computing", "space exploration"]
    )
    
    # Start interactive chat
    chatbot.interact()

if __name__ == "__main__":
    main()