You are a super smart developer. You have been tasked with fixing a program and making it work according to the best of your knowledge. There might be placeholders in the code you have to fill in.
You provide fully functioning, well formatted code with few comments, that works and has no bugs.
Please return the full new code in the same format. import tkinter as tk
from tkinter import scrolledtext, filedialog
from pathlib import Path
import shutil
from datetime import datetime
from typing import List, Dict, Any, Optional
import openai


class AI:
    def __init__(self, model: str, temperature: float, knowledge_db: KnowledgeDB):
        self.model = model
        self.temperature = temperature
        self.knowledge_db = knowledge_db
        self.messages: List[Dict[str, str]] = []

    def start(self, system: str, user: str) -> str:
        self.messages = [
            {"role": "system", "content": system},
            {"role": "user", "content": user},
        ]
        return self.get_response()

    def next(self, user_input: str) -> str:
        self.messages.append({"role": "user", "content": user_input})
        return self.get_response()

    def get_response(self) -> str:
        last_user_message = self.messages[-1]['content']

        # Search in local knowledge database as priority
        knowledge_files = self.knowledge_db.list_knowledge()
        knowledge_response = ""
        for file in knowledge_files:
            knowledge = self.knowledge_db.get_knowledge(file)
            if last_user_message in knowledge:
                # Extract code and comments from knowledge
                code = "".join(line for line in knowledge.split("\n") if not line.strip().startswith("#"))
                comments = "".join(line for line in knowledge.split("\n") if line.strip().startswith("#"))
                knowledge_response = f"Code:\n{code}\nComments:\n{comments}"
                break

        # Use OpenAI GPT-3
        ai_response = openai.Completion.create(
            engine=self.model,
            prompt=self.messages,
            temperature=self.temperature,
        )
        assistant_response = ai_response.choices[0].text

        # Combine responses from local knowledge database and OpenAI GPT-3
        combined_response = f"From local knowledge base: {knowledge_response}\nFrom AI: {assistant_response}"
        self.messages.append({"role": "assistant", "content": combined_response})
        return combined_response


class DB:
    def __init__(self, path: str):
        self.path = Path(path).absol There should be exactly 2 paragraphs separated by the markdown divider: ***.
user