Skip to content

Commit d8c50fc

Browse files
kevin-lanngithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent f6cf933 commit d8c50fc

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

course-matrix/backend/src/constants/availableFunctions.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { supabase } from "../db/setupDb";
22
import { Request } from "express";
33

44
// Add all possible function names here
5-
export type FunctionNames = "getTimetables" | "updateTimetable" | "deleteTimetable";
5+
export type FunctionNames =
6+
| "getTimetables"
7+
| "updateTimetable"
8+
| "deleteTimetable";
69

710
type AvailableFunctions = {
811
[K in FunctionNames]: (args: any, req: Request) => Promise<any>;
@@ -43,7 +46,7 @@ export const availableFunctions: AvailableFunctions = {
4346
},
4447
updateTimetable: async (args: any, req: Request) => {
4548
try {
46-
const { id, timetable_title, semester } = args;
49+
const { id, timetable_title, semester } = args;
4750

4851
if (!timetable_title && !semester) {
4952
return {
@@ -69,16 +72,19 @@ export const availableFunctions: AvailableFunctions = {
6972
const timetable_user_id = timetableUserData?.user_id;
7073

7174
if (timetableUserError)
72-
return {status: 400, error: timetableUserError.message };
75+
return { status: 400, error: timetableUserError.message };
7376

7477
//Validate timetable validity:
7578
if (!timetableUserData || timetableUserData.length === 0) {
76-
return {status: 404, error: "Calendar id not found" };
79+
return { status: 404, error: "Calendar id not found" };
7780
}
7881

7982
//Validate user access
8083
if (user_id !== timetable_user_id) {
81-
return { status: 401, error: "Unauthorized access to timetable events" };
84+
return {
85+
status: 401,
86+
error: "Unauthorized access to timetable events",
87+
};
8288
}
8389

8490
let updateData: any = {};
@@ -97,8 +103,7 @@ export const availableFunctions: AvailableFunctions = {
97103
const { data: timetableData, error: timetableError } =
98104
await updateTimetableQuery;
99105

100-
if (timetableError)
101-
return { status: 400, error: timetableError.message };
106+
if (timetableError) return { status: 400, error: timetableError.message };
102107

103108
// If no records were updated due to non-existence timetable or it doesn't belong to the user.
104109
if (!timetableData || timetableData.length === 0) {
@@ -109,7 +114,7 @@ export const availableFunctions: AvailableFunctions = {
109114
}
110115
return { status: 200, data: timetableData };
111116
} catch (error) {
112-
return { status: 500, error: error };
117+
return { status: 500, error: error };
113118
}
114119
},
115120
deleteTimetable: async (args: any, req: Request) => {
@@ -135,12 +140,15 @@ export const availableFunctions: AvailableFunctions = {
135140

136141
//Validate timetable validity:
137142
if (!timetableUserData || timetableUserData.length === 0) {
138-
return { status: 404, error: "Calendar id not found" };
143+
return { status: 404, error: "Calendar id not found" };
139144
}
140145

141146
//Validate user access
142147
if (user_id !== timetable_user_id) {
143-
return { status: 401, error: "Unauthorized access to timetable events" };
148+
return {
149+
status: 401,
150+
error: "Unauthorized access to timetable events",
151+
};
144152
}
145153

146154
// Delete only if the timetable belongs to the authenticated user
@@ -153,12 +161,11 @@ export const availableFunctions: AvailableFunctions = {
153161

154162
const { error: timetableError } = await deleteTimetableQuery;
155163

156-
if (timetableError)
157-
return { status: 400, error: timetableError.message };
164+
if (timetableError) return { status: 400, error: timetableError.message };
158165

159-
return { status: 200, data: "Timetable successfully deleted"};
166+
return { status: 200, data: "Timetable successfully deleted" };
160167
} catch (error) {
161168
return { status: 500, error: error };
162169
}
163-
}
170+
},
164171
};

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,27 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
256256
},
257257
}),
258258
updateTimetable: tool({
259-
description:
260-
"Update a user's timetable by title and/or semester",
259+
description: "Update a user's timetable by title and/or semester",
261260
parameters: z.object({
262261
id: z.number().positive(),
263262
timetable_title: z.string().optional(),
264-
semester: z.enum(["Fall 2025", "Summer 2025", "Winter 2026"]).optional(),
263+
semester: z
264+
.enum(["Fall 2025", "Summer 2025", "Winter 2026"])
265+
.optional(),
265266
}),
266267
execute: async (args) => {
267268
return await availableFunctions.updateTimetable(args, req);
268-
}
269+
},
269270
}),
270271
deleteTimetable: tool({
271-
description:
272-
"Delete a user's timetable",
272+
description: "Delete a user's timetable",
273273
parameters: z.object({
274274
id: z.number().positive(),
275275
}),
276276
execute: async (args) => {
277-
return await availableFunctions.deleteTimetable(args, req)
278-
}
279-
})
277+
return await availableFunctions.deleteTimetable(args, req);
278+
},
279+
}),
280280
},
281281
maxSteps: CHATBOT_TOOL_CALL_MAX_STEPS, // Controls how many back and forths the model can take with user or calling multiple tools
282282
experimental_repairToolCall: async ({

0 commit comments

Comments
 (0)