Skip to content

Commit 910cec3

Browse files
kevin-lanngithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent 64b9180 commit 910cec3

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,8 @@ export const availableFunctions: AvailableFunctions = {
261261
});
262262
}
263263

264-
const groupedOfferingsList: GroupedOfferingList[] = await groupOfferings(
265-
courseOfferingsList
266-
);
264+
const groupedOfferingsList: GroupedOfferingList[] =
265+
await groupOfferings(courseOfferingsList);
267266

268267
// console.log(JSON.stringify(groupedOfferingsList, null, 2));
269268

@@ -276,7 +275,7 @@ export const availableFunctions: AvailableFunctions = {
276275
}
277276

278277
const categorizedOfferings = await categorizeValidOfferings(
279-
validCourseOfferingsList
278+
validCourseOfferingsList,
280279
);
281280

282281
// console.log(typeof categorizedOfferings);
@@ -289,7 +288,7 @@ export const availableFunctions: AvailableFunctions = {
289288
[],
290289
0,
291290
categorizedOfferings.length,
292-
maxdays
291+
maxdays,
293292
);
294293

295294
// Return error if no valid schedules are found

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const pinecone = new Pinecone({
5656
});
5757

5858
const index: Index<RecordMetadata> = pinecone.Index(
59-
process.env.PINECONE_INDEX_NAME!
59+
process.env.PINECONE_INDEX_NAME!,
6060
);
6161

6262
console.log("Connected to OpenAI API");
@@ -65,7 +65,7 @@ export async function searchSelectedNamespaces(
6565
query: string,
6666
k: number,
6767
namespaces: string[],
68-
filters?: Object
68+
filters?: Object,
6969
): Promise<Document[]> {
7070
let allResults: Document[] = [];
7171

@@ -87,7 +87,7 @@ export async function searchSelectedNamespaces(
8787
const results = await namespaceStore.similaritySearch(
8888
query,
8989
Math.max(k, namespaceToMinResults.get(namespace)),
90-
namespace === "courses_v3" ? filters : undefined
90+
namespace === "courses_v3" ? filters : undefined,
9191
);
9292
console.log(`Found ${results.length} results in namespace: ${namespace}`);
9393
allResults = [...allResults, ...results];
@@ -108,7 +108,7 @@ export async function searchSelectedNamespaces(
108108
// Reformulate user query to make more concise query to database, taking into consideration context
109109
export async function reformulateQuery(
110110
latestQuery: string,
111-
conversationHistory: any[]
111+
conversationHistory: any[],
112112
): Promise<string> {
113113
try {
114114
const openai2 = new OpenAI({
@@ -320,7 +320,7 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
320320
toolCall.args,
321321
`The tool accepts the following schema:`,
322322
parameterSchema(toolCall),
323-
"Please fix the arguments."
323+
"Please fix the arguments.",
324324
);
325325

326326
const { object: repairedArgs } = await generateObject({
@@ -355,7 +355,7 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
355355
// Use GPT-4o to reformulate the query based on conversation history
356356
const reformulatedQuery = await reformulateQuery(
357357
latestMessage,
358-
conversationHistory.slice(-CHATBOT_MEMORY_THRESHOLD) // last K messages
358+
conversationHistory.slice(-CHATBOT_MEMORY_THRESHOLD), // last K messages
359359
);
360360
console.log(">>>> Original query:", latestMessage);
361361
console.log(">>>> Reformulated query:", reformulatedQuery);
@@ -369,8 +369,8 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
369369
if (requiresSearch) {
370370
console.log(
371371
`Query requires knowledge retrieval, searching namespaces: ${relevantNamespaces.join(
372-
", "
373-
)}`
372+
", ",
373+
)}`,
374374
);
375375

376376
const filters = includeFilters(reformulatedQuery);
@@ -381,7 +381,7 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
381381
reformulatedQuery,
382382
3,
383383
relevantNamespaces,
384-
Object.keys(filters).length === 0 ? undefined : filters
384+
Object.keys(filters).length === 0 ? undefined : filters,
385385
);
386386
// console.log("Search Results: ", searchResults);
387387

@@ -391,7 +391,7 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
391391
}
392392
} else {
393393
console.log(
394-
"Query does not require knowledge retrieval, skipping search"
394+
"Query does not require knowledge retrieval, skipping search",
395395
);
396396
}
397397

@@ -456,15 +456,15 @@ export const testSimilaritySearch = asyncHandler(
456456
if (requiresSearch) {
457457
console.log(
458458
`Query requires knowledge retrieval, searching namespaces: ${relevantNamespaces.join(
459-
", "
460-
)}`
459+
", ",
460+
)}`,
461461
);
462462

463463
// Search only the relevant namespaces
464464
const searchResults = await searchSelectedNamespaces(
465465
message,
466466
3,
467-
relevantNamespaces
467+
relevantNamespaces,
468468
);
469469
console.log("Search Results: ", searchResults);
470470

@@ -474,11 +474,11 @@ export const testSimilaritySearch = asyncHandler(
474474
}
475475
} else {
476476
console.log(
477-
"Query does not require knowledge retrieval, skipping search"
477+
"Query does not require knowledge retrieval, skipping search",
478478
);
479479
}
480480

481481
console.log("CONTEXT: ", context);
482482
res.status(200).send(context);
483-
}
483+
},
484484
);

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,10 @@ export default {
408408
return res.status(404).json({ error: "No valid schedules found." });
409409
}
410410
// Return the valid schedules
411-
return res
412-
.status(200)
413-
.json({
414-
amount: validSchedules.length,
415-
schedules: trim(validSchedules),
416-
});
411+
return res.status(200).json({
412+
amount: validSchedules.length,
413+
schedules: trim(validSchedules),
414+
});
417415
} catch (error) {
418416
// Catch any error and return the error message
419417
const errorMessage =

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});
@@ -81,19 +81,19 @@ export const RestrictionSchema = z.object({
8181
.max(4, "Cannot block all days of the week")
8282
.optional()
8383
.describe(
84-
"If type is Days Off, then this field is used and describes min number of days off per week."
84+
"If type is Days Off, then this field is used and describes min number of days off per week.",
8585
),
8686
startTime: z
8787
.date()
8888
.optional()
8989
.describe(
90-
"If type is Restrict After, or Restrict Between, then this field describes the start boundary of the restricted time"
90+
"If type is Restrict After, or Restrict Between, then this field describes the start boundary of the restricted time",
9191
),
9292
endTime: z
9393
.date()
9494
.optional()
9595
.describe(
96-
"If type is Restrict Before, or Restrict Between, then this field describes the end boundary of the restricted time"
96+
"If type is Restrict Before, or Restrict Between, then this field describes the end boundary of the restricted time",
9797
),
9898
disabled: z
9999
.boolean()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ export const CreateTimetableArgs = z.object({
4949
notes: z.string().optional(),
5050
code: z.string().describe("Course code"),
5151
})
52-
.describe("A course event")
52+
.describe("A course event"),
5353
),
5454
});

0 commit comments

Comments
 (0)