Skip to content

Commit 87aee28

Browse files
committed
2 parents ba7d991 + 2d05546 commit 87aee28

File tree

4 files changed

+70
-24
lines changed

4 files changed

+70
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# CounselAI-Python
2-
A submission to the Honolulu Tech Week Hackathon & the Congressional App Challenge
2+
A submission to the Honolulu Tech Week Hackathon, the 2024 Congressional App Challenge, and the National STEM Festival

main.py

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ def __init__(self, app:CTk.CTk) :
120120
self.app_hieght = 800
121121

122122
app.resizable(False, False)
123-
123+
124+
self.chatHistory = [
125+
{"role" : "system", "content" : systemPrompt}
126+
]
127+
124128
## Spawns screen constants...
125129
header = CTk.CTkFrame(self.app, width=600, height=75, fg_color=self.bg_color_light, bg_color=self.bg_color, corner_radius=0)
126130
header.place(x=0, y=0)
@@ -131,9 +135,8 @@ def __init__(self, app:CTk.CTk) :
131135
settings_button = CTk.CTkButton(header, text="⚙️", font=self.header_font, fg_color=self.bg_color_light, hover_color=self.bg_color, border_width=0, command = lambda : self.director("SettingButton"), width=60, height=50)
132136
settings_button.place(x=525, y=12)
133137

134-
self.chatHistory = [
135-
{"role" : "system", "content" : systemPrompt}
136-
]
138+
ai_chat_button = CTk.CTkButton(self.app, 100, border_width=0, command=self.chat_with_ai, bg_color=self.bg_color_light, fg_color=self.bg_color_light, text="Chat with AI!", font=self.header_font)
139+
ai_chat_button.place(x=200, y=550)
137140

138141
self.parse_unis()
139142

@@ -164,7 +167,7 @@ def intro_1st_slide(self,) :
164167
self.all_screen_obj.append(intro_text_2)
165168

166169
next_button = CTk.CTkButton(self.app, text="Next", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command=self.intro_2nd_slide, width=100, height=50)
167-
next_button.place(x=150, y=400)
170+
next_button.place(x=350, y=450)
168171
self.all_screen_obj.append(next_button)
169172

170173
def intro_2nd_slide(self,) :
@@ -179,11 +182,11 @@ def intro_2nd_slide(self,) :
179182
self.all_screen_obj.append(self.name_tb)
180183

181184
back_button = CTk.CTkButton(self.app, text="Back", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command = self.intro_1st_slide, width=100, height=50)
182-
back_button.place(x=150, y=400)
185+
back_button.place(x=150, y=450)
183186
self.all_screen_obj.append(back_button)
184187

185188
next_button = CTk.CTkButton(self.app, text="Next", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command = self.intro_3rd_slide, width=100, height=50)
186-
next_button.place(x=350, y=400)
189+
next_button.place(x=350, y=450)
187190
self.all_screen_obj.append(next_button)
188191

189192
def intro_3rd_slide(self,) :
@@ -268,11 +271,11 @@ def intro_4th_slide_ap_selector(self) :
268271
self.all_screen_obj.append(self.ap_score)
269272

270273
back_button = CTk.CTkButton(self.app, text="Back", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command=self.intro_4th_slide, width=100, height=50)
271-
back_button.place(x=150, y=400)
274+
back_button.place(x=150, y=450)
272275
self.all_screen_obj.append(back_button)
273276

274277
next_button = CTk.CTkButton(self.app, text="Next", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command=self.intro_4th_slide_ap_selector_validator, width=100, height=50)
275-
next_button.place(x=350, y=400)
278+
next_button.place(x=350, y=450)
276279
self.all_screen_obj.append(next_button)
277280

278281
def intro_4th_slide_ap_selector_validator(self,) :
@@ -549,7 +552,7 @@ def intro_7th_slide_club_entry_validator(self,) :
549552
if club_purpose == "Academic" :
550553
club_purpose = 3
551554
elif club_purpose == "Volunteering" :
552-
club_purpose = 2
555+
club_purpose = 2.5
553556
else :
554557
club_purpose = 1
555558

@@ -852,13 +855,13 @@ def generate_report(self,) :
852855
career_path = self.career_dd.get()
853856
assert (career_path != "-")
854857

855-
self.student_score = self.sat_score/50 + self.gpa*5
858+
self.student_score = self.sat_score/50 + self.gpa*4.5
856859

857860
## Very dumb but it works so :shrug:
858861
tempTotal = 0
859862
for i in self.taken_APs :
860863
tempTotal += i.apValue
861-
864+
862865
for i in self.taken_clubs :
863866
tempTotal += i.clubValue
864867

@@ -941,18 +944,14 @@ def generate_report(self,) :
941944
uni_text.place(x=15, y=20)
942945
self.all_screen_obj.append(uni_text)
943946

944-
uni_button = CTk.CTkButton(layer, 75, border_width=0, command=lambda : webbrowser.open(f"https://google.com/search?q={uni.name}"), text="More info", font=self.small_font)
947+
uni_button = CTk.CTkButton(layer, 75, border_width=0, command=lambda university = uni.name: self.spawn_university_information_window(university), text="More info", font=self.small_font)
945948
uni_button.place(x=485, y=20)
946949

947950

948951
self.all_screen_obj.append(layer)
949952

950-
ai_chat_button = CTk.CTkButton(self.app, 100, border_width=0, command=self.chat_with_ai, bg_color=self.bg_color_light, fg_color=self.bg_color_light, text="Chat with AI!", font=self.header_font)
951-
ai_chat_button.place(x=250, y=550)
952-
self.all_screen_obj.append(ai_chat_button)
953-
954953
except :
955-
messagebox.showerror("Invalid Career Path", "Invalid Career Path!")
954+
messagebox.showerror("Invalid Career Field", "Invalid Career Field!")
956955
self.intro_11th_slide()
957956

958957
def chat_with_ai(self,) :
@@ -985,6 +984,7 @@ def parse_unis(self, ) :
985984
for i in tier1s :
986985
## Ugly but works
987986
self.T1_UNIS.append(universities.university(i, tier1s[i]["acc_rate"], 5, tier1s[i]["75_sat"], tier1s[i]["50_sat"], tier1s[i]["25_sat"], tier1s[i]["tags"]))
987+
print(self.T1_UNIS[len(self.T1_UNIS)-1].universityDifficulty)
988988

989989
with open("tier2.json", 'r') as t2 :
990990
tier2s = json.load(t2)
@@ -1009,11 +1009,11 @@ def parse_unis(self, ) :
10091009

10101010
for i in tier5s :
10111011
self.T5_UNIS.append(universities.university(i, tier5s[i]["acc_rate"], 1, tier5s[i]["75_sat"], tier5s[i]["50_sat"], tier5s[i]["25_sat"], tier5s[i]["tags"]))
1012+
print(self.T5_UNIS[len(self.T5_UNIS)-1].universityDifficulty)
10121013

10131014
## Also a bit janky but also works
10141015
self.ALL_UNIS = self.T1_UNIS + self.T2_UNIS + self.T3_UNIS + self.T4_UNIS + self.T5_UNIS
10151016

1016-
10171017
def sendMessage(self) :
10181018
user_input = self.ai_entry.get()
10191019
self.ai_entry.delete(0, CTk.END)
@@ -1030,8 +1030,6 @@ def sendMessage(self) :
10301030
ai_message.place(x=15, y=self.current_y_ai)
10311031
self.current_y_ai += int(len(ai_response)/2) + 35
10321032

1033-
1034-
10351033
def sendOPENAIMessage(self, user_input) -> str :
10361034
try :
10371035
self.chatHistory.append({"role" : "user", "content" : user_input})
@@ -1048,6 +1046,52 @@ def sendOPENAIMessage(self, user_input) -> str :
10481046
return response.choices[0].message.content
10491047
except Exception as e :
10501048
return f"An error occurred: {str(e)}"
1049+
1050+
def spawn_university_information_window(self, university_name) :
1051+
temp_chat = [{"role" : "system", "content" : systemPrompt + ". Please do not use lists and keep the reponse in a paragraph."}] ## Janky but works
1052+
temp_chat.append({"role" : "user", "content" : "Generate a short description of " + university_name + ". But be sure to include some tips for how to get in."})
1053+
1054+
try :
1055+
response = openai.chat.completions.create(
1056+
model="gpt-4o",
1057+
messages=temp_chat,
1058+
max_tokens=300,
1059+
n=1,
1060+
stop=None,
1061+
temperature=0.7
1062+
)
1063+
1064+
uni_description = response.choices[0].message.content
1065+
print(uni_description)
1066+
except Exception as e :
1067+
messagebox.showerror("Error!", f"An error occurred: {str(e)}")
10511068

1069+
## Programming crimes
1070+
uni_description = list(uni_description)
1071+
1072+
space_count = 0
1073+
1074+
for i in range(len(uni_description)):
1075+
if uni_description[i] == " ":
1076+
space_count += 1
1077+
if space_count % 6 == 0:
1078+
uni_description[i] = "\n" ## Very janky method of line seperation.
1079+
i = i-1 ## to deal with the fact that we technically added an additional character.
1080+
uni_description = "".join(uni_description)
1081+
1082+
uni_description_window = CTk.CTkToplevel(self.app,)
1083+
uni_description_window.config(bg=self.bg_color)
1084+
uni_description_window.geometry("600x600")
1085+
uni_description_window.title("About " + university_name)
1086+
1087+
header = CTk.CTkFrame(uni_description_window, 600, 75, 0, 0, self.bg_color_light, self.bg_color_light, )
1088+
header.place(x=0, y=0)
1089+
1090+
uni_name_header = CTk.CTkLabel(header, text=university_name, width=360, height=50, font=self.medium_font, text_color=self.app_text_color, bg_color=self.bg_color_light, fg_color=self.bg_color_light, )
1091+
uni_name_header.place(x=20, y=15)
1092+
1093+
uni_text = CTk.CTkLabel(uni_description_window, 600, 80, bg_color=self.bg_color, fg_color=self.bg_color, text=uni_description, font=self.button_font)
1094+
uni_text.place(x=0, y = 100)
1095+
10521096

10531097
var = app(CTk.CTk())

sports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ def __init__(self, name, position, totalMonths) :
33
self.name = name
44
self.position = position
55
self.totalMonths = totalMonths
6-
self.sportsValue = position * totalMonths / 4
6+
self.sportsValue = position * (totalMonths^2/5) ## This leads to the gradual decline of extra months of sports, from 8 months compared to 4 months is large, but 20 to 24 is smaller

universities.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ def __init__(self, name, acc_rate, tier, sat75, sat50, sat25, tags) :
99
self.sat25 = sat25
1010
self.tags = tags
1111

12-
self.universityDifficulty = (1-self.acc_rate)*10*tier+sat50/40
12+
self.universityDifficulty = (1-self.acc_rate)*8*tier + sat50/40
13+
if (self.tier <= 3 ) :
14+
self.universityDifficulty -= (8*(2-self.tier))

0 commit comments

Comments
 (0)