-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
99 lines (77 loc) · 3.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import os
import openai
import customtkinter as ctk
import pyttsx3
engine = pyttsx3.init()
def generate():
prompt = "Please generate 10 ideas for coding projects."
language = language_dropdown.get()
prompt += "The programming language is " + language + ". "
difficulty = difficulty_value.get()
prompt += "The difficulty is " + difficulty + ". "
if checkbox1.get():
prompt += "The project should include a database."
if checkbox2.get():
prompt += "The project should include a API"
print(prompt)
#replace OPENAI_API_KEY with your API key
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}])
answer = response.choices[0].message.content
print(answer)
result.insert("0.0", answer)
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.say(answer)
engine.runAndWait()
window = ctk.CTk()
window.geometry("900x550")
window.title("ChatGPT Project Generator")
ctk.set_appearance_mode("dark")
title_label = ctk.CTkLabel(window,text="Project Idea Generator",
font=ctk.CTkFont(size=30, weight="bold"))
title_label.pack(padx=10, pady=(1,1))
frame = ctk.CTkFrame(window)
frame.pack(fill="x", padx=100)
language_frame = ctk.CTkFrame(frame)
language_frame.pack(padx=100, pady=(20,5), fill="both")
language_label = ctk.CTkLabel(
language_frame, text="Programming Language",font=ctk.CTkFont(weight="bold")
)
language_label.pack()
language_dropdown = ctk.CTkComboBox(
language_frame, values=["Python","Java","C++","Javascript","Golang"])
language_dropdown.pack(pady=10)
difficulty_frame = ctk.CTkFrame(frame)
difficulty_frame.pack(padx=100, pady=5, fill="both")
difficulty_label = ctk.CTkLabel(
difficulty_frame, text="Project Difficulty", font=ctk.CTkFont(weight="bold"))
difficulty_label.pack()
difficulty_value = ctk.StringVar(value="Easy")
radiobutton1 = ctk.CTkRadioButton(
difficulty_frame, text="Easy", variable=difficulty_value,value="Easy"
)
radiobutton1.pack(side="left", padx=(20, 10), pady=10)
radiobutton2 = ctk.CTkRadioButton(
difficulty_frame, text="Normal", variable=difficulty_value,value="Normal"
)
radiobutton2.pack(side="left",padx=(20,10), pady=10)
radiobutton3 = ctk.CTkRadioButton(
difficulty_frame, text="Hard", variable=difficulty_value,value="Hard"
)
radiobutton3.pack(side="left",padx=(20,10), pady=10)
features_frame = ctk.CTkFrame(frame)
features_frame.pack(padx=100,pady=5, fill="both")
features_label = ctk.CTkLabel(
features_frame, text="Features", font=ctk.CTkFont(weight="bold")
)
features_label.pack()
checkbox1 = ctk.CTkCheckBox(features_frame, text="Database")
checkbox1.pack(side="left",padx=50, pady=10)
checkbox2 = ctk.CTkCheckBox(features_frame, text="API")
checkbox2.pack(side="left",padx=50, pady=10)
button = ctk.CTkButton(frame, text="Generate Ideas", command=generate)
button.pack(padx=100, fill="x", pady=(5, 20))
result = ctk.CTkTextbox(window, font=ctk.CTkFont(size=15))
result.pack(pady=10, fill="x", padx=100)
window.mainloop()