Skip to content

Commit

Permalink
fixed integration bugs due to prisma mismatch. Now finds lesson slug …
Browse files Browse the repository at this point in the history
…via id - lessonPlan - lesson - slug
  • Loading branch information
gclomax committed Dec 16, 2024
1 parent ea7e542 commit 45c17e9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/aila/src/core/chat/AilaChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export class AilaChat implements AilaChatService {
quizRatingSchema: testRatingSchema,
quizSelector: "simple",
quizReranker: "return-first",
quizGenerators: ["ml", "rag", "basedOnRag"],
// quizGenerators: ["ml", "rag", "basedOnRag"],
quizGenerators: ["basedOnRag"],
});
}
// TODO: GCLOMAX This should be put in a new class called AilaQuizService, in the ailaservices class.
Expand Down
6 changes: 3 additions & 3 deletions packages/aila/src/core/quiz/generators/BaseQuizGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export abstract class BaseQuizGenerator implements AilaQuizGeneratorService {

public async getLessonSlugFromPlanId(planId: string): Promise<string | null> {
try {
const result = await prisma.lesson.findUnique({
const result = await prisma.lessonPlan.findUnique({
where: { id: planId },
select: {
slug: true,
lesson: true,
},
});

return result?.slug || null;
return result?.lesson.slug || null;
} catch (error) {
console.error("Error fetching lesson slug:", error);
return null;
Expand Down
23 changes: 23 additions & 0 deletions packages/aila/src/core/quiz/generators/BaseQuizGeneratorTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,28 @@ export const runCommonQuizGeneratorTests = (
).rejects.toBeDefined();
});
});

// [
// 'DSemIaiDytA0PtrHTo9Zq',
// '0ChBXkONXh8IOVS00iTlm',
// 'LnViNV0cVTEaiunKzumPs',
// 'R3IrL-ct9sSAhpsz7lgrE',
// 'AGtKSucW7OTUKiswiHfJ9'
// ]
describe("Question Array From Plan Id", () => {
it("should handle invalid lesson plans gracefully", async () => {
await expect(
generator.questionArrayFromPlanId("invalid-plan-id"),
).rejects.toBeDefined();
});
it("should handle valid lesson plans gracefully", async () => {
const result = await generator.questionArrayFromPlanId(
"clna7lofy0og0p4qxju5j6z56",
);
expect(result).toBeDefined();
expect(Array.isArray(result)).toBe(true);
expect(result.length).toBeGreaterThan(0);
});
});
});
};
6 changes: 2 additions & 4 deletions packages/aila/src/core/quiz/generators/MLQuizGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ export class MLQuizGenerator extends BaseQuizGenerator {
// Check for minimum required properties
if (
!(
typeof lessonPlan === "object" &&
"title" in lessonPlan &&
"keyStage" in lessonPlan &&
"topic" in lessonPlan
("title" in lessonPlan && "keyStage" in lessonPlan)
// "topic" in lessonPlan
)
) {
throw new Error("Invalid lesson plan: missing required properties");
Expand Down

0 comments on commit 45c17e9

Please sign in to comment.