Skip to content

Commit 869087a

Browse files
committed
switch to 2.5 flash
1 parent f212be1 commit 869087a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def fetch_announcements():
394394
prompt = f"You are a meticulous and organized secretary at a Canadian high school. Your job is to accurately assign titles to announcements and figure out which club that announcement belongs to. Accuracy and consistency are paramount. The titles should be no more than 64 characters long. It should be descriptive of the announcement itself. Do not go over the limit. You will be provided an array of announcements. Each element in the array will contain the data for one announcement. The element will be in the format of a json object containing the body (what will be announced out) and the club_name (students may mistype clubs names, etc so you will need to pick which one you think they were trying to reference). The available names of all the clubs of the school will be provided below to you in the format of an array (E.g. ['club name 1', 'club name 2', 'club name 3', ... ]). \nWhen outputting, output a single array object. The array order must match the order of the one provided to you. DO NOT CHANGE THE ORDER UNDER ANY CIRCUMSTANCE. The array format should be the same as announcements array given to you. Each element are to be a json object, one key will be the title and the other will be the club name. Should no club match the one the student was trying to pick, then and ONLY then will you put down the club name they have listed. In this scenario, please output it in pascal case and remove any unnecessary information that is not relating to the club name itself. For example, if it's written as 'CLUB NAME (OTHER INFORMATION)', it should be outputted as just 'Club Name'. If you do find a club name in the club name array that matches the one the student was trying to write, it should be EXACTLY the same during output. Do not output anything besides the array.\nClub names: {organizations}\nAnnouncements to be titled: {dumps(prompt_data)}"
395395

396396
try:
397-
response = prompt_gemini(prompt)
397+
response = prompt_gemini(prompt, model = "models/gemini-2.5-flash")
398398
response = response.text.replace("```json", "").replace("```", "")
399399
response = loads(response)
400400
except Exception:

core/utils/ai.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
from django.conf import settings
33

44

5-
def prompt_gemini(prompt):
5+
def prompt_gemini(prompt, model=None):
66
if settings.GEMINI_API_KEY is None:
77
raise Exception("Gemini api key not found")
88

99
client = genai.Client(api_key=settings.GEMINI_API_KEY)
10-
model = settings.GEMINI_MODEL or "models/gemini-2.0-flash"
10+
11+
if model is None:
12+
try:
13+
model = settings.GEMINI_MODEL or "models/gemini-2.0-flash"
14+
except AttributeError:
15+
model = "models/gemini-2.0-flash"
1116

1217
response = client.models.generate_content(
1318
model=model,

0 commit comments

Comments
 (0)