Initial working commit
Some checks failed
Automated Container Build / build-and-push (push) Failing after 7s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 7s
This commit is contained in:
parent
666ceb7325
commit
b7ce314f01
105 changed files with 35510 additions and 11 deletions
81
src/services/settingsService.ts
Normal file
81
src/services/settingsService.ts
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
import { prisma } from "@/lib/db";
|
||||
|
||||
const DEFAULT_LLM_INSTRUCTIONS_FLASHCARDS = `You are generating study materials in a strict JSON format for import into a
|
||||
personal study app. The overall output must be raw JSON with no wrapping
|
||||
markdown code fence and no commentary before or after. Markdown formatting
|
||||
INSIDE string values (lists, **bold**, tables) is fine, see the formatting
|
||||
rule below.
|
||||
|
||||
For flashcards, use this shape:
|
||||
{ "type": "flashcards", "deckName": "...", "description": "...", "cards": [{"front": "...", "back": "..."}] }
|
||||
|
||||
Rules:
|
||||
- CRITICAL: Output MUST be valid JSON. All strings must be wrapped in double quotes.
|
||||
- Use Markdown formatting (bullet lists, **bold**, tables) inside "back"
|
||||
text wherever it improves clarity. You MUST escape any newlines in the string as \n. Do not use raw newlines.
|
||||
- Base everything strictly on the material below. Do not add outside facts.
|
||||
|
||||
Material:
|
||||
[paste your notes or lecture content here]`;
|
||||
|
||||
const DEFAULT_LLM_INSTRUCTIONS_QUIZZES = `You are generating study materials in a strict JSON format for import into a
|
||||
personal study app. The overall output must be raw JSON with no wrapping
|
||||
markdown code fence and no commentary before or after. Markdown formatting
|
||||
INSIDE string values (lists, **bold**, tables) is fine, see the formatting
|
||||
rule below.
|
||||
|
||||
For quizzes, use this shape:
|
||||
{ "type": "quiz", "quizName": "...", "description": "...", "questions": [
|
||||
{"type": "multiple_choice" | "sata", "prompt": "...", "category": "...",
|
||||
"options": [{"text": "...", "correct": true|false}], "rationale": "..."}
|
||||
]}
|
||||
|
||||
Rules:
|
||||
- CRITICAL: Output MUST be valid JSON. All strings must be wrapped in double quotes.
|
||||
- "multiple_choice" questions must have exactly one option with correct: true.
|
||||
- "sata" questions must have two or more options with correct: true.
|
||||
- Every question needs a rationale explaining why the correct option(s) are
|
||||
correct, and briefly why the others are not.
|
||||
- Every question must include a "category" field: a short topic tag you
|
||||
choose based on the content (e.g. "thyroid", "limbic system"). Reuse the
|
||||
exact same label across questions on the same topic rather than inventing
|
||||
a new variant each time, and keep the total number of distinct categories
|
||||
small relative to the number of questions.
|
||||
- Use Markdown formatting (bullet lists, **bold**, tables) inside
|
||||
"rationale" text wherever it improves clarity. You MUST escape any newlines in the string as \n. Do not use raw newlines.
|
||||
- Base everything strictly on the material below. Do not add outside facts.
|
||||
|
||||
Material:
|
||||
[paste your notes or lecture content here]`;
|
||||
|
||||
export async function getLlmInstructions(type: "flashcards" | "quizzes"): Promise<string> {
|
||||
const key = type === "flashcards" ? "llmInstructionsFlashcards" : "llmInstructionsQuizzes";
|
||||
const def = type === "flashcards" ? DEFAULT_LLM_INSTRUCTIONS_FLASHCARDS : DEFAULT_LLM_INSTRUCTIONS_QUIZZES;
|
||||
|
||||
const setting = await prisma.setting.findUnique({
|
||||
where: { key },
|
||||
});
|
||||
return setting?.value ?? def;
|
||||
}
|
||||
|
||||
export async function updateLlmInstructions(type: "flashcards" | "quizzes", value: string) {
|
||||
const key = type === "flashcards" ? "llmInstructionsFlashcards" : "llmInstructionsQuizzes";
|
||||
|
||||
return prisma.setting.upsert({
|
||||
where: { key },
|
||||
update: { value },
|
||||
create: { key, value },
|
||||
});
|
||||
}
|
||||
|
||||
export async function resetLlmInstructions(type: "flashcards" | "quizzes") {
|
||||
const key = type === "flashcards" ? "llmInstructionsFlashcards" : "llmInstructionsQuizzes";
|
||||
const def = type === "flashcards" ? DEFAULT_LLM_INSTRUCTIONS_FLASHCARDS : DEFAULT_LLM_INSTRUCTIONS_QUIZZES;
|
||||
|
||||
return prisma.setting.upsert({
|
||||
where: { key },
|
||||
update: { value: def },
|
||||
create: { key, value: def },
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue