Initial addition of the Arcade study feature. Add connections as the first working game.
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m4s

This commit is contained in:
Elijah 2026-07-13 17:35:18 -07:00
parent 7b90409f2e
commit 611a585757
43 changed files with 5990 additions and 68 deletions

View file

@ -1,4 +1,7 @@
import { prisma } from "@/lib/db";
import { ARCADE_SERVER_REGISTRY } from "@/lib/arcade/registry";
export type LlmInstructionType = "flashcards" | "quizzes" | "connections";
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
@ -48,9 +51,14 @@ Rules:
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;
function instructionConfig(type: LlmInstructionType) {
if (type === "flashcards") return { key: "llmInstructionsFlashcards", value: DEFAULT_LLM_INSTRUCTIONS_FLASHCARDS };
if (type === "quizzes") return { key: "llmInstructionsQuizzes", value: DEFAULT_LLM_INSTRUCTIONS_QUIZZES };
return { key: "llmInstructionsConnections", value: ARCADE_SERVER_REGISTRY.connections.defaultInstructions };
}
export async function getLlmInstructions(type: LlmInstructionType): Promise<string> {
const { key, value: def } = instructionConfig(type);
const setting = await prisma.setting.findUnique({
where: { key },
@ -58,8 +66,8 @@ export async function getLlmInstructions(type: "flashcards" | "quizzes"): Promis
return setting?.value ?? def;
}
export async function updateLlmInstructions(type: "flashcards" | "quizzes", value: string) {
const key = type === "flashcards" ? "llmInstructionsFlashcards" : "llmInstructionsQuizzes";
export async function updateLlmInstructions(type: LlmInstructionType, value: string) {
const { key } = instructionConfig(type);
return prisma.setting.upsert({
where: { key },
@ -68,9 +76,8 @@ export async function updateLlmInstructions(type: "flashcards" | "quizzes", valu
});
}
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;
export async function resetLlmInstructions(type: LlmInstructionType) {
const { key, value: def } = instructionConfig(type);
return prisma.setting.upsert({
where: { key },
@ -78,4 +85,3 @@ export async function resetLlmInstructions(type: "flashcards" | "quizzes") {
create: { key, value: def },
});
}