Skip to content

Commit a708687

Browse files
committed
Fix: Query reformulation for course codes
1 parent 4cb5b39 commit a708687

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,18 @@ async function reformulateQuery(
178178
- DO replace pronouns and references with specific names and identifiers
179179
- DO include course codes, names and specific details for academic entities
180180
- If the query is not about university courses & offerings, return exactly a copy of the user's query.
181+
- Append "code: " before course codes For example: "CSCC01" -> "code: CSCC01"
182+
- If a course year level is written as "first year", "second year", etc. Then replace "first" with "1st" and "second" with "2nd" etc.
181183
182184
Examples:
183185
User: "When is it offered?"
184-
Output: "When is CSCA48 Introduction to Computer Science offered in the 2024-2025 academic year?"
186+
Output: "When is CSCA48 offered in the 2024-2025 academic year?"
185187
186188
User: "Tell me more about that"
187-
Output: "What are the details, descriptions, and requirements for MATA31 Calculus I?"
189+
Output: "What are the details, descriptions, and requirements for MATA31?"
188190
189191
User: "Who teaches it?"
190-
Output: "Who are the instructors for MGEA02 Introduction to Microeconomics at UTSC?"
192+
Output: "Who are the instructors for MGEA02 at UTSC?"
191193
192194
User: "What are the course names of those codes?"
193195
Output: "What are the course names of course codes: MGTA01, CSCA08, MATA31, MATA35?"
@@ -198,8 +200,13 @@ async function reformulateQuery(
198200
User: "Give 2nd year math courses."
199201
Output: "What are some 2nd year math courses?"
200202
201-
User: "Give first year math courses."
202-
Output: "What are some 1st year math courses?"`,
203+
User: "Give third year math courses."
204+
Output: "What are some 3rd year math courses?"
205+
206+
User: "What breadth requirement does CSCC01 satisfy?"
207+
Output: "What breadth reequirement does code: CSCC01 satisfy?"
208+
209+
`,
203210
},
204211
];
205212

@@ -347,7 +354,7 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
347354
console.log("Query does not require knowledge retrieval, skipping search");
348355
}
349356

350-
// console.log("CONTEXT: ", context);
357+
console.log("CONTEXT: ", context);
351358

352359
const result = streamText({
353360
model: openai("gpt-4o-mini"),

0 commit comments

Comments
 (0)