Skip to content

Commit 224095b

Browse files
committed
Fix: DaysOfWeekEnum, and improve system prompt for function caller
1 parent 89dd454 commit 224095b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

course-matrix/backend/src/controllers/aiController.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,14 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
246246
- Include course codes when referencing specific courses
247247
- If information is missing from the context but likely exists, try to use info from web to answer. If still not able to form a decent response, acknowledge the limitation
248248
- For unrelated questions, politely explain that you're specialized in UTSC academic information
249+
- Format long lists of timetables as a table
249250
250251
## Tool call guidelines
251252
- Include the timetable ID in all getTimetables tool call responses
252-
- For every tool call, for each timetable that it gets/deletes/modifies/creates, include a link underneath it displayed as "View timetable" to ${process.env.CLIENT_APP_URL}/dashboard/timetable?edit=[[TIMETABLE_ID]] , where TIMETABLE_ID is the id of the respective timetable.
253+
- Link: For every tool call, for each timetable that it gets/deletes/modifies/creates, include a link with it displayed as "View Timetable" to ${process.env.CLIENT_APP_URL}/dashboard/timetable?edit=[[TIMETABLE_ID]] , where TIMETABLE_ID is the id of the respective timetable.
253254
- If the user provides a course code of length 6 like CSCA08, then assume they mean CSCA08H3 (H3 appended)
254255
- If the user wants to create a timetable, first call getCourses to get course information on the requested courses, then call generateTimetable.
255-
- For the response to create timetable, format as a table.
256+
- Do not make up fake courses or offerings.
256257
`,
257258
messages,
258259
tools: {
@@ -430,6 +431,7 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
430431
## Response Guidelines
431432
- Be concise and direct when answering course-related questions
432433
- Use bullet points for listing multiple pieces of information
434+
- Use tables for listing multiple offerings, courses, or other information that could be better viewed in tabular fashion
433435
- Include course codes when referencing specific courses
434436
- If information is missing from the context but likely exists, try to use info from web to answer. If still not able to form a decent response, acknowledge the limitation
435437
- For unrelated questions, politely explain that you're specialized in UTSC academic information

course-matrix/backend/src/models/timetable-form.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const daysOfWeek = [
4545
},
4646
] as const;
4747

48-
export const DayOfWeekEnum = z.enum(["SU", "MO", "TU", "WE", "TH", "FR", "SA"]);
48+
export const DayOfWeekEnum = z.enum(["MO", "TU", "WE", "TH", "FR"]);
4949

5050
export const SemesterEnum = z.enum(["Summer 2025", "Fall 2025", "Winter 2026"]);
5151

@@ -56,7 +56,7 @@ export const CourseSchema = z.object({
5656
.max(8, "Invalid course code")
5757
.min(1, "Course code is required")
5858
.describe(
59-
"The course code. Formatted like: CSCA08H3. Course codes cannot be provided without the H3 at the end.",
59+
"The course code. Formatted like: CSCA08H3. Course codes cannot be provided without the H3 at the end."
6060
),
6161
name: z.string().describe("The name of the course"),
6262
});
@@ -70,30 +70,32 @@ export const RestrictionSchema = z.object({
7070
"Restrict Day",
7171
"Days Off",
7272
])
73-
.describe("The type of restriction being applied"),
73+
.describe(
74+
"The type of restriction being applied. Restrict before restricts all times before 'endTime', Restrict Before restricts all times after 'startTime', Restrict Between restricts all times between 'startTime' and 'endTime', Restrict Day restricts the entirety of each day in field 'days', and Days Off enforces as least 'numDays' days off per week."
75+
),
7476
days: z
7577
.array(DayOfWeekEnum)
76-
.default(["SU", "MO", "TU", "WE", "TH", "FR", "SA"])
78+
.default(["MO", "TU", "WE", "TH", "FR"])
7779
.describe("Specific days of the week this restriction applies to"),
7880
numDays: z
7981
.number()
8082
.positive()
8183
.max(4, "Cannot block all days of the week")
8284
.optional()
8385
.describe(
84-
"If type is Days Off, then this field is used and describes min number of days off per week.",
86+
"If type is Days Off, then this field is used and describes min number of days off per week. For example, if set to 2, and 'type' is Days Off, then this means we want at least 2 days off per week."
8587
),
8688
startTime: z
8789
.string()
8890
.optional()
8991
.describe(
90-
"If type is Restrict After, or Restrict Between, then this field describes the start time of the restricted time. Formatted HH:mm:ss",
92+
"If type is Restrict After, or Restrict Between, then this field describes the start time of the restricted time. Formatted HH:mm:ss"
9193
),
9294
endTime: z
9395
.string()
9496
.optional()
9597
.describe(
96-
"If type is Restrict Before, or Restrict Between, then this field describes the end time of the restricted time. Formatted HH:mm:ss",
98+
"If type is Restrict Before, or Restrict Between, then this field describes the end time of the restricted time. Formatted HH:mm:ss"
9799
),
98100
disabled: z
99101
.boolean()

0 commit comments

Comments
 (0)