Skip to content

Commit

Permalink
fix: update only non-current prompt variants to non-current
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl committed Aug 29, 2024
1 parent 99411b7 commit 08a31e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo lint",
"prompts": "turbo prompts --filter=core",
"prompts:dev": "turbo prompts:dev --filter=core",
"sort-package-json": "sort-package-json \"package.json\" \"packages/*/package.json\" \"apps/*/package.json\"",
"type-check": "turbo type-check",
"node-version": "node -v",
Expand Down
17 changes: 11 additions & 6 deletions packages/aila/src/features/generation/AilaGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,25 @@ export class AilaGeneration {
}
}
} else {
prompt = await prisma.prompt.findFirst({
const promptQuery = {
where: {
variant: variantSlug,
appId: appSlug,
slug: promptSlug,
current: true,
},
});
};
prompt = await prisma.prompt.findFirst(promptQuery);
}
if (!prompt) {
// If the prompt does not exist for this variant, we need to generate it
const prompts = new PromptVariants(prisma, ailaGenerate, promptSlug);
const created = await prompts.setCurrent(variantSlug, true);
promptId = created?.id;
throw new Error(
"Prompt not found - please run pnpm prompts:dev in development or pnpm prompts in production/staging",
);

// // If the prompt does not exist for this variant, we need to generate it
// const prompts = new PromptVariants(prisma, ailaGenerate, promptSlug);
// const created = await prompts.setCurrent(variantSlug, true);
// promptId = created?.id;
}

promptId = promptId ?? prompt?.id;
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/models/promptVariants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class PromptVariants {
slug: {
equals: slug,
},
variant: {
equals: variant,
},
id: {
not: {
equals: created.id,
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/prompts/lesson-assistant/parts/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ A well-thought-out lesson plan should:
* Include some engaging activities to help reinforce the learning points.
Ensure that the keywords relevant to the topic are repeated throughout the different sections of the lesson plan.
Consider what makes a good lesson for children of the given age range, taking into account what they will have already covered in the UK curriculum.
Put thought into how the different sections of the lessons link together to keep pupils informed and engaged.
Expand Down

0 comments on commit 08a31e8

Please sign in to comment.