import os
import tkinter as tk
from tkinter import Label, Entry, Button, Text, Scrollbar

import langchain
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.chat_models import ChatOpenAI

class ProjectEvaluatorApp:
    def __init__(self, root):
        self.root = root
        self.root.title('Project Evaluator')

        self.experience_label = Label(root, text='Rate your coding ability on a scale of 1 to 5:')
        self.experience_input = Entry(root)

        self.frameworks_label = Label(root, text='Which coding languages have you used?')
        self.frameworks_input = Entry(root)

        self.learn_label = Label(root, text='What would you like to learn?')
        self.learn_input = Entry(root)

        self.evaluate_button = Button(root, text='Evaluate Project', command=self.evaluate_project)

        self.result_text = Text(root, wrap='word', height=10, width=50)
        self.result_scrollbar = Scrollbar(root, command=self.result_text.yview)
        self.result_text['yscrollcommand'] = self.result_scrollbar.set

        self.experience_label.pack()
        self.experience_input.pack()
        self.frameworks_label.pack()
        self.frameworks_input.pack()
        self.learn_label.pack()
        self.learn_input.pack()
        self.evaluate_button.pack()
        self.result_text.pack(side='left', padx=5)
        self.result_scrollbar.pack(side='right', fill='y')  # Corrected argument

    def evaluate_project(self):
        experience_level = self.experience_input.get()
        frameworks_used = self.frameworks_input.get()
        what_to_learn = self.learn_input.get()

        CREATE_CONTEXT_PROMPT = f"""Summarize this student's coding experience level and learning goals using the following information: 
              The student's experience level on a scale of 0 to 5: {experience_level}
              The coding languages the student has used: {frameworks_used}
              The thing the student wants to learn: {what_to_learn}"""

        llm = ChatOpenAI(
            openai_api_key=os.environ["OPENAI_API_KEY"],
            model_name='gpt-4',
            temperature=0.0
        )
        context = llm.invoke(CREATE_CONTEXT_PROMPT)

        PROMPT = f"""You are evaluating potential project ideas. Each idea has a hierarchy based on difficulty and applicability in the industry, rated on a scale from 1 to 5. Your goal is to organize these ideas in ascending order of difficulty and descending order of applicability: {context} Given their coding experience, what simple example project could the student build to learn the topic they want to learn? """

        project = llm.invoke(str(PROMPT))

        self.result_text.config(state='normal')  # Enable editing
        self.result_text.delete('1.0', 'end')  # Clear preavious content
        self.result_text.insert('1.0', f"{project}\n")  # Insert new content
        self.result_text.config(state='disabled')  # Disable editing

if __name__ == '__main__':
    root = tk.Tk()
    app = ProjectEvaluatorApp(root)
    root.mainloop()
langchain.chat_models.ChatOpenAI
[((3005, 3012), 'tkinter.Tk', 'tk.Tk', ([], {}), '()\n', (3010, 3012), True, 'import tkinter as tk\n'), ((380, 446), 'tkinter.Label', 'Label', (['root'], {'text': '"""Rate your coding ability on a scale of 1 to 5:"""'}), "(root, text='Rate your coding ability on a scale of 1 to 5:')\n", (385, 446), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((479, 490), 'tkinter.Entry', 'Entry', (['root'], {}), '(root)\n', (484, 490), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((524, 581), 'tkinter.Label', 'Label', (['root'], {'text': '"""Which coding languages have you used?"""'}), "(root, text='Which coding languages have you used?')\n", (529, 581), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((614, 625), 'tkinter.Entry', 'Entry', (['root'], {}), '(root)\n', (619, 625), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((654, 703), 'tkinter.Label', 'Label', (['root'], {'text': '"""What would you like to learn?"""'}), "(root, text='What would you like to learn?')\n", (659, 703), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((731, 742), 'tkinter.Entry', 'Entry', (['root'], {}), '(root)\n', (736, 742), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((775, 843), 'tkinter.Button', 'Button', (['root'], {'text': '"""Evaluate Project"""', 'command': 'self.evaluate_project'}), "(root, text='Evaluate Project', command=self.evaluate_project)\n", (781, 843), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((872, 916), 'tkinter.Text', 'Text', (['root'], {'wrap': '"""word"""', 'height': '(10)', 'width': '(50)'}), "(root, wrap='word', height=10, width=50)\n", (876, 916), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((949, 996), 'tkinter.Scrollbar', 'Scrollbar', (['root'], {'command': 'self.result_text.yview'}), '(root, command=self.result_text.yview)\n', (958, 996), False, 'from tkinter import Label, Entry, Button, Text, Scrollbar\n'), ((2024, 2120), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'openai_api_key': "os.environ['OPENAI_API_KEY']", 'model_name': '"""gpt-4"""', 'temperature': '(0.0)'}), "(openai_api_key=os.environ['OPENAI_API_KEY'], model_name='gpt-4',\n    temperature=0.0)\n", (2034, 2120), False, 'from langchain.chat_models import ChatOpenAI\n')]