diff --git a/apps/nextjs/src/components/ContextProviders/AnalyticsProvider.tsx b/apps/nextjs/src/components/ContextProviders/AnalyticsProvider.tsx
index 8ed3b2680..40523e770 100644
--- a/apps/nextjs/src/components/ContextProviders/AnalyticsProvider.tsx
+++ b/apps/nextjs/src/components/ContextProviders/AnalyticsProvider.tsx
@@ -227,7 +227,7 @@ export const AnalyticsProvider: React.FC
= ({
/**
* Legacy event tracking
- * Calls PostHog tracking directly rather than using Avos tracking plan.
+ * Calls PostHog tracking directly rather than using Avo's tracking plan.
* @todo remove this once all events are migrated to Avo
* @deprecated Use the `track` function from the analytics context instead
*/
@@ -265,7 +265,7 @@ export const AnalyticsProvider: React.FC = ({
page,
posthogAiBetaClient: posthogAiBeta.client,
};
- }, [track, trackEvent, identify, reset, page]);
+ }, [track, trackEvent, identify, reset, page, posthogAiBeta.client]);
const onClerkIdentify = useCallback(
(user: { userId: string; email: string; isDemoUser?: boolean }) => {
diff --git a/apps/nextjs/src/components/ContextProviders/ChatProvider.tsx b/apps/nextjs/src/components/ContextProviders/ChatProvider.tsx
index de9fac36b..8a006eb4a 100644
--- a/apps/nextjs/src/components/ContextProviders/ChatProvider.tsx
+++ b/apps/nextjs/src/components/ContextProviders/ChatProvider.tsx
@@ -13,10 +13,12 @@ import { generateMessageId } from "@oakai/aila/src/helpers/chat/generateMessageI
import { parseMessageParts } from "@oakai/aila/src/protocol/jsonPatchProtocol";
import type {
AilaPersistedChat,
+ LessonPlanKeys,
LooseLessonPlan,
} from "@oakai/aila/src/protocol/schema";
import { isToxic } from "@oakai/core/src/utils/ailaModeration/helpers";
import type { PersistedModerationBase } from "@oakai/core/src/utils/ailaModeration/moderationSchema";
+import { camelCaseToTitleCase } from "@oakai/core/src/utils/camelCaseConversion";
import type { Moderation } from "@oakai/db";
import { aiLogger } from "@oakai/logger";
import * as Sentry from "@sentry/nextjs";
@@ -24,11 +26,13 @@ import type { Message } from "ai";
import { nanoid } from "ai";
import type { ChatRequestOptions, CreateMessage } from "ai";
import { useChat } from "ai/react";
-import { useTemporaryLessonPlanWithStreamingEdits } from "hooks/useTemporaryLessonPlanWithStreamingEdits";
-import { redirect, usePathname, useRouter } from "next/navigation";
+import { useLessonPlanScrollManagement } from "hooks/useLessonPlanScrollManagement";
+import { usePathname, useRouter } from "next/navigation";
import { useLessonPlanTracking } from "@/lib/analytics/lessonPlanTrackingContext";
import useAnalytics from "@/lib/analytics/useAnalytics";
+import { nextSectionsToGenerate } from "@/lib/lessonPlan/nextSectionToGenerate";
+import { useLessonPlanManager } from "@/lib/lessonPlan/useLessonPlanManager";
import { trpc } from "@/utils/trpc";
import type { AilaStreamingStatus } from "../AppComponents/Chat/Chat/hooks/useAilaStreamingStatus";
@@ -42,28 +46,37 @@ import {
const log = aiLogger("chat");
export type ChatContextProps = {
- id: string;
- chat: AilaPersistedChat | undefined;
- initialModerations: Moderation[];
- toxicModeration: PersistedModerationBase | null;
- lastModeration: PersistedModerationBase | null;
- messages: Message[];
- isLoading: boolean;
- isStreaming: boolean;
- lessonPlan: LooseLessonPlan;
ailaStreamingStatus: AilaStreamingStatus;
append: (
message: Message | CreateMessage,
chatRequestOptions?: ChatRequestOptions | undefined,
) => Promise;
- reload: () => void;
- stop: () => void;
- input: string;
- setInput: React.Dispatch>;
+ chat: AilaPersistedChat | undefined | null;
chatAreaRef: React.RefObject;
+ executeQueuedAction: () => Promise;
+ id: string;
+ initialModerations: Moderation[];
+ input: string;
+ isLoading: boolean;
+ isStreaming: boolean;
+ iteration: number | undefined;
+ lastModeration: PersistedModerationBase | null;
+ lessonPlan: LooseLessonPlan;
+ messages: Message[];
queuedUserAction: string | null;
queueUserAction: (action: string) => void;
- executeQueuedAction: () => Promise;
+ reload: () => void;
+ sectionRefs: Record<
+ LessonPlanKeys,
+ React.MutableRefObject
+ >;
+ setInput: React.Dispatch>;
+ setSectionRef: (section: LessonPlanKeys, el: HTMLDivElement | null) => void;
+ stop: () => void;
+ streamingSection: LessonPlanKeys | undefined;
+ streamingSectionCompleted: LessonPlanKeys | undefined;
+ streamingSections: LessonPlanKeys[] | undefined;
+ toxicModeration: PersistedModerationBase | null;
};
const ChatContext = createContext(null);
@@ -73,16 +86,6 @@ export type ChatProviderProps = {
children: React.ReactNode;
};
-const messageHashes = {};
-
-function clearHashCache() {
- for (const key in messageHashes) {
- if (messageHashes.hasOwnProperty(key)) {
- delete messageHashes[key];
- }
- }
-}
-
function useActionMessages() {
const analytics = useAnalytics();
@@ -158,6 +161,7 @@ export function ChatProvider({ id, children }: Readonly) {
const hasAppendedInitialMessage = useRef(false);
const lessonPlanSnapshot = useRef({});
+ const { lessonPlanManager, lessonPlan, iteration } = useLessonPlanManager();
const [overrideLessonPlan, setOverrideLessonPlan] = useState<
LooseLessonPlan | undefined
@@ -213,9 +217,6 @@ export function ChatProvider({ id, children }: Readonly) {
if (hasFinished) {
setHasFinished(false);
}
- if (!path?.includes("chat/[id]")) {
- window.history.pushState({}, "", `/aila/${id}`);
- }
},
onFinish(response) {
log.info("Chat: On Finish", new Date().toISOString(), {
@@ -232,15 +233,39 @@ export function ChatProvider({ id, children }: Readonly) {
}
invokeActionMessages(response.content);
-
- trpcUtils.chat.appSessions.getChat.invalidate({ id });
-
+ setStreamingSectionCompleted(undefined);
setHasFinished(true);
shouldTrackStreamFinished.current = true;
chatAreaRef.current?.scrollTo(0, chatAreaRef.current?.scrollHeight);
},
});
+ useEffect(() => {
+ if (chat?.lessonPlan) {
+ log.info(
+ "Setting lesson plan from chat",
+ chat?.iteration,
+ chat.lessonPlan,
+ );
+ lessonPlanManager.setLessonPlanWithDelay(chat.lessonPlan, chat.iteration);
+ }
+ }, [chat?.lessonPlan, chat?.iteration, lessonPlanManager]);
+
+ useEffect(() => {
+ const loggingLessonPlan = chat?.lessonPlan;
+ if (loggingLessonPlan) {
+ const keys = (Object.keys(loggingLessonPlan) as LessonPlanKeys[]).filter(
+ (k) => loggingLessonPlan[k],
+ );
+ log.info(
+ "Updated chat from server",
+ chat?.iteration,
+ `${keys.length} keys`,
+ keys.join("|"),
+ );
+ }
+ }, [chat?.lessonPlan, chat?.iteration]);
+
useEffect(() => {
/**
* This is a hack to ensure that the assistant messages have a stable id
@@ -268,14 +293,6 @@ export function ChatProvider({ id, children }: Readonly) {
});
}, [messages]);
- const { tempLessonPlan, partialPatches, validPatches } =
- useTemporaryLessonPlanWithStreamingEdits({
- lessonPlan: chat?.lessonPlan ?? {},
- messages,
- isStreaming: !hasFinished,
- messageHashes,
- });
-
// Handle queued user actions and messages
const [queuedUserAction, setQueuedUserAction] = useState(null);
@@ -285,6 +302,23 @@ export function ChatProvider({ id, children }: Readonly) {
setQueuedUserAction(action);
}, []);
+ const generateContinueAction = useCallback(() => {
+ const sectionsToGenerate = nextSectionsToGenerate(lessonPlan);
+ if (sectionsToGenerate.length === 0) {
+ return "Continue - check the lesson plan for consistency and correctness";
+ } else {
+ const sentenceCaseSections = sectionsToGenerate
+ .map((section) => camelCaseToTitleCase(section))
+ .join(", ")
+ .replace(/, ([^,]*)$/, " and $1");
+ return `Continue. Generate the ${sentenceCaseSections} section${sectionsToGenerate.length > 1 ? "s" : ""}.`;
+ }
+ }, [
+ // Ensure this re-renders with any changes to the lesson plan
+ JSON.stringify(Object.keys(lessonPlan).filter((k) => lessonPlan[k])),
+ lessonPlan,
+ ]);
+
const executeQueuedAction = useCallback(async () => {
if (!queuedUserAction || !hasFinished || isExecutingAction.current) return;
@@ -294,8 +328,9 @@ export function ChatProvider({ id, children }: Readonly) {
try {
if (actionToExecute === "continue") {
+ const continueAction = generateContinueAction();
await append({
- content: "Continue",
+ content: continueAction,
role: "user",
});
} else if (actionToExecute === "regenerate") {
@@ -312,7 +347,7 @@ export function ChatProvider({ id, children }: Readonly) {
} finally {
isExecutingAction.current = false;
}
- }, [queuedUserAction, hasFinished, append, reload]);
+ }, [append, generateContinueAction, hasFinished, queuedUserAction, reload]);
useEffect(() => {
if (hasFinished) {
@@ -342,33 +377,34 @@ export function ChatProvider({ id, children }: Readonly) {
}
}, [chat?.startingMessage, append, router, path, hasAppendedInitialMessage]);
- // Clear the hash cache each completed message
- useEffect(() => {
- clearHashCache();
- }, [hasFinished]);
-
/**
* Update the lesson plan if the chat has finished updating
* Fetch the state from the last "state" command in the most recent assistant message
*/
useEffect(() => {
if (!hasFinished || !messages) return;
- trpcUtils.chat.appSessions.getChat.invalidate({ id });
+ const timeout = setTimeout(() => {
+ // Delay fetching the lesson plan to ensure the UI has updated
+ trpcUtils.chat.appSessions.getChat.invalidate({ id });
+ }, 2000);
if (shouldTrackStreamFinished.current) {
lessonPlanTracking.onStreamFinished({
prevLesson: lessonPlanSnapshot.current,
- nextLesson: tempLessonPlan,
+ nextLesson: lessonPlan,
messages,
});
shouldTrackStreamFinished.current = false;
}
+ return () => {
+ clearTimeout(timeout);
+ };
}, [
id,
trpcUtils.chat.appSessions.getChat,
hasFinished,
messages,
lessonPlanTracking,
- tempLessonPlan,
+ lessonPlan,
]);
/**
@@ -382,7 +418,40 @@ export function ChatProvider({ id, children }: Readonly) {
? lastModeration
: toxicInitialModeration;
- const ailaStreamingStatus = useAilaStreamingStatus({ isLoading, messages });
+ const {
+ status: ailaStreamingStatus,
+ streamingSection,
+ streamingSections,
+ } = useAilaStreamingStatus({ isLoading, messages });
+
+ log.info("*** ailaStreamingStatus", ailaStreamingStatus);
+ const [streamingSectionCompleted, setStreamingSectionCompleted] = useState<
+ LessonPlanKeys | undefined
+ >(undefined);
+
+ const { sectionRefs, setSectionRef } = useLessonPlanScrollManagement(
+ streamingSection,
+ streamingSectionCompleted,
+ );
+
+ // We have to snapshot the message using a ref so that we don't get a render loop
+ // because messages updates each time we receive a token from the server
+ const workingMessage = useRef(undefined);
+
+ useEffect(() => {
+ if (messages.length > 0) {
+ workingMessage.current = messages[messages.length - 1];
+ }
+ }, [messages]);
+
+ useEffect(() => {
+ if (streamingSection !== streamingSectionCompleted) {
+ if (workingMessage.current) {
+ lessonPlanManager.onMessageUpdated(workingMessage.current);
+ }
+ setStreamingSectionCompleted(streamingSection);
+ }
+ }, [streamingSection, streamingSectionCompleted, lessonPlanManager]);
useEffect(() => {
if (toxicModeration) {
@@ -393,61 +462,65 @@ export function ChatProvider({ id, children }: Readonly) {
const value: ChatContextProps = useMemo(
() => ({
+ ailaStreamingStatus,
+ append,
+ chat,
+ chatAreaRef,
+ executeQueuedAction,
+ hasAppendedInitialMessage,
+ hasFinished,
id,
- chat: chat ?? undefined,
initialModerations: moderations ?? [],
- toxicModeration,
- lessonPlan: overrideLessonPlan ?? tempLessonPlan,
- hasFinished,
- hasAppendedInitialMessage,
- chatAreaRef,
- append,
- messages,
- ailaStreamingStatus,
+ input,
isLoading,
isStreaming: !hasFinished,
+ iteration,
lastModeration,
- reload,
- stop,
- input,
- setInput,
- partialPatches,
- validPatches,
+ lessonPlan: overrideLessonPlan ?? lessonPlan,
+ messages,
queuedUserAction,
queueUserAction,
- executeQueuedAction,
+ reload,
+ setInput,
+ stop,
+ streamingSection,
+ streamingSections,
+ streamingSectionCompleted,
+ toxicModeration,
+ sectionRefs,
+ setSectionRef,
}),
[
- id,
+ ailaStreamingStatus,
+ append,
chat,
- moderations,
- toxicModeration,
- tempLessonPlan,
- hasFinished,
- hasAppendedInitialMessage,
chatAreaRef,
- messages,
- ailaStreamingStatus,
+ executeQueuedAction,
+ hasAppendedInitialMessage,
+ hasFinished,
+ id,
+ input,
isLoading,
+ iteration,
lastModeration,
- reload,
- stop,
- input,
- setInput,
- append,
- partialPatches,
- validPatches,
+ lessonPlan,
+ messages,
+ moderations,
overrideLessonPlan,
queuedUserAction,
queueUserAction,
- executeQueuedAction,
+ reload,
+ setInput,
+ stop,
+ streamingSection,
+ streamingSections,
+ streamingSectionCompleted,
+ toxicModeration,
+ sectionRefs,
+ setSectionRef,
],
);
- if (!chat && !isChatLoading) {
- redirect("/aila");
- }
-
return (
{isChatLoading || isModerationsLoading ? null : children}
diff --git a/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts b/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts
new file mode 100644
index 000000000..55d23d38a
--- /dev/null
+++ b/apps/nextjs/src/hooks/useLessonPlanScrollManagement.ts
@@ -0,0 +1,155 @@
+import { useCallback, useEffect, useRef, useState } from "react";
+
+import { LessonPlanKeys } from "@oakai/aila/src/protocol/schema";
+import { aiLogger } from "@oakai/logger";
+
+const log = aiLogger("lessons");
+
+export const useLessonPlanScrollManagement = (
+ streamingSection: LessonPlanKeys | undefined,
+ streamingSectionCompleted: LessonPlanKeys | undefined,
+) => {
+ const [recentlyScrolledSection, setRecentlyScrolledSection] = useState<
+ LessonPlanKeys | undefined
+ >(undefined);
+
+ const [userHasCancelledAutoScroll, setUserHasCancelledAutoScroll] =
+ useState(false);
+
+ const sectionRefs = useRef<
+ Record>
+ >({
+ title: { current: null },
+ subject: { current: null },
+ keyStage: { current: null },
+ topic: { current: null },
+ learningOutcome: { current: null },
+ learningCycles: { current: null },
+ priorKnowledge: { current: null },
+ keyLearningPoints: { current: null },
+ misconceptions: { current: null },
+ keywords: { current: null },
+ basedOn: { current: null },
+ starterQuiz: { current: null },
+ exitQuiz: { current: null },
+ cycle1: { current: null },
+ cycle2: { current: null },
+ cycle3: { current: null },
+ additionalMaterials: { current: null },
+ });
+
+ const setSectionRef = useCallback(
+ (section: LessonPlanKeys, el: HTMLDivElement | null) => {
+ sectionRefs.current[section].current = el;
+ },
+ [],
+ );
+
+ const scrollQueueRef = useRef([]);
+ const activeScrollRef = useRef(null);
+
+ const processScrollQueue = useCallback(() => {
+ if (activeScrollRef.current || scrollQueueRef.current.length === 0) {
+ return;
+ }
+
+ const section = scrollQueueRef.current.shift();
+ activeScrollRef.current = section || null;
+
+ if (section) {
+ const sectionRef = sectionRefs.current[section];
+
+ if (sectionRef && sectionRef.current) {
+ const scrollableParent = document.querySelector(
+ '[data-testid="chat-right-hand-side-lesson"]',
+ ) as HTMLElement;
+
+ if (scrollableParent && sectionRef.current) {
+ const parentRect = scrollableParent.getBoundingClientRect();
+ const sectionRect = sectionRef.current.getBoundingClientRect();
+ const targetScrollPosition =
+ sectionRect.top - parentRect.top + scrollableParent.scrollTop - 160;
+
+ scrollableParent.scrollTo({
+ top: targetScrollPosition,
+ behavior: "smooth",
+ });
+ }
+ }
+ }
+ }, []);
+
+ const scrollToSection = useCallback(
+ (section: LessonPlanKeys) => {
+ if (section === recentlyScrolledSection) {
+ log.info("Skipping scrolling: it's the recent section we scrolled to");
+ return;
+ }
+ if (userHasCancelledAutoScroll) {
+ log.info("Skipping scrolling: user has cancelled auto scroll");
+ return;
+ }
+
+ scrollQueueRef.current.push(section);
+ setRecentlyScrolledSection(section);
+ },
+ [userHasCancelledAutoScroll, recentlyScrolledSection],
+ );
+
+ useEffect(() => {
+ const handleUserScroll = () => {
+ setUserHasCancelledAutoScroll(true);
+
+ const timeoutId = setTimeout(() => {
+ setUserHasCancelledAutoScroll(false);
+ }, 5000);
+
+ return () => {
+ clearTimeout(timeoutId);
+ };
+ };
+
+ window.addEventListener("wheel", handleUserScroll);
+
+ return () => {
+ window.removeEventListener("wheel", handleUserScroll);
+ };
+ }, []);
+
+ useEffect(() => {
+ const intervalId = setInterval(() => {
+ if (activeScrollRef.current) {
+ activeScrollRef.current = null;
+ } else {
+ processScrollQueue();
+ }
+ }, 500);
+
+ return () => {
+ clearInterval(intervalId);
+ };
+ }, [processScrollQueue]);
+
+ useEffect(() => {
+ if (
+ streamingSectionCompleted === undefined &&
+ streamingSection !== undefined
+ ) {
+ // This is the first section being generated
+ // so we scroll to it and show the user what is happening
+ log.info("Scroll - first section", streamingSection);
+ scrollToSection(streamingSection);
+ } else if (
+ streamingSectionCompleted !== undefined &&
+ streamingSectionCompleted !== streamingSection
+ ) {
+ // We are moving to a new section but we don't want to show
+ // this content until it is fully generated,
+ // so we only scroll to it when it is completed
+ log.info("Scroll - completed section", streamingSectionCompleted);
+ scrollToSection(streamingSectionCompleted);
+ }
+ }, [streamingSection, streamingSectionCompleted, scrollToSection]);
+
+ return { sectionRefs: sectionRefs.current, setSectionRef };
+};
diff --git a/apps/nextjs/src/hooks/useMobileLessonPullOutControl.ts b/apps/nextjs/src/hooks/useMobileLessonPullOutControl.ts
index e39bdb4a8..15d8c1f88 100644
--- a/apps/nextjs/src/hooks/useMobileLessonPullOutControl.ts
+++ b/apps/nextjs/src/hooks/useMobileLessonPullOutControl.ts
@@ -21,13 +21,24 @@ export const useMobileLessonPullOutControl = ({
useEffect(() => {
if (
!userHasOverRiddenAutoPullOut &&
- ailaStreamingStatus === "StreamingLessonPlan" &&
+ ["StreamingLessonPlan", "Moderating"].includes(ailaStreamingStatus) &&
lessonPlan.title
) {
- setShowLessonMobile(true);
+ console.log("Show lesson mobile");
+ if (!showLessonMobile) {
+ setShowLessonMobile(true);
+ }
+ } else {
+ console.log("Not showing lesson mobile", {
+ userHasOverRiddenAutoPullOut,
+ lessonPlanTitle: lessonPlan.title,
+ ailaStreamingStatus,
+ });
}
if (ailaStreamingStatus === "Idle") {
- setUserHasOverRiddenAutoPullOut(false);
+ if (userHasOverRiddenAutoPullOut) {
+ setUserHasOverRiddenAutoPullOut(false);
+ }
}
}, [
ailaStreamingStatus,
@@ -35,7 +46,9 @@ export const useMobileLessonPullOutControl = ({
userHasOverRiddenAutoPullOut,
setUserHasOverRiddenAutoPullOut,
setShowLessonMobile,
+ showLessonMobile,
lessonPlan.title,
+ lessonPlan,
]);
function closeMobileLessonPullOut() {
diff --git a/apps/nextjs/src/hooks/useTemporaryLessonPlanWithStreamingEdits.ts b/apps/nextjs/src/hooks/useTemporaryLessonPlanWithStreamingEdits.ts
deleted file mode 100644
index ec963f1a3..000000000
--- a/apps/nextjs/src/hooks/useTemporaryLessonPlanWithStreamingEdits.ts
+++ /dev/null
@@ -1,162 +0,0 @@
-import { useEffect, useRef, useMemo } from "react";
-
-import type { PatchDocument } from "@oakai/aila/src/protocol/jsonPatchProtocol";
-import {
- applyLessonPlanPatch,
- extractPatches,
-} from "@oakai/aila/src/protocol/jsonPatchProtocol";
-import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
-import { useThrottle } from "@uidotdev/usehooks";
-import type { Message } from "ai/react";
-import { deepClone } from "fast-json-patch";
-import hash from "object-hash";
-import { equals } from "remeda";
-
-type PatchDocumentWithHash = PatchDocument & { hash: string };
-
-const hashFor = (obj: object, messageHashes) => {
- const cached = messageHashes[JSON.stringify(obj)];
- if (cached) return cached;
- const h = hash(obj, { algorithm: "md5" });
- messageHashes[JSON.stringify(obj)] = h;
- return h;
-};
-
-function extractPatchesFromMessage(message: Message) {
- const { validPatches, partialPatches } = extractPatches(message.content);
- return { validPatches, partialPatches };
-}
-
-function patchHasBeenApplied(
- patch: PatchDocument,
- appliedPatches: PatchDocumentWithHash[],
- messageHashes: Record,
-): { patch: PatchDocumentWithHash | null; hasBeenApplied: boolean } {
- const hash = hashFor(patch, messageHashes);
- const hasBeenApplied = appliedPatches.some(
- (appliedPatch) => hash === appliedPatch.hash,
- );
- return { hasBeenApplied, patch: { ...patch, hash } };
-}
-
-export const useTemporaryLessonPlanWithStreamingEdits = ({
- lessonPlan,
- messages,
- //isStreaming, // Disable partial patches for now
- messageHashes,
-}: {
- lessonPlan?: LooseLessonPlan;
- messages?: Message[];
- isStreaming?: boolean;
- messageHashes: Record;
-}): {
- tempLessonPlan: LooseLessonPlan;
- validPatches: PatchDocument[];
- partialPatches: PatchDocument[];
-} => {
- const throttledAssistantMessages = useThrottle(messages, 100);
- const tempLessonPlanRef = useRef(lessonPlan ?? {});
- const appliedPatchesRef = useRef([]);
-
- // Update the ref when lessonPlan changes
- useEffect(() => {
- if (lessonPlan && !equals(lessonPlan, tempLessonPlanRef.current)) {
- // Update existing keys and add new ones
- Object.keys(lessonPlan).forEach((key) => {
- tempLessonPlanRef.current[key] = deepClone(lessonPlan[key]);
- });
- // Remove keys that are no longer in lessonPlan
- Object.keys(tempLessonPlanRef.current).forEach((key) => {
- if (!(key in lessonPlan)) {
- delete tempLessonPlanRef.current[key];
- }
- });
- appliedPatchesRef.current = [];
- }
- }, [lessonPlan]);
-
- const applyPatch = (
- patch: PatchDocumentWithHash,
- workingLessonPlan: LooseLessonPlan,
- ) => {
- const newLessonPlan: LooseLessonPlan | undefined = applyLessonPlanPatch(
- workingLessonPlan,
- patch,
- );
- if (newLessonPlan) {
- Object.assign(tempLessonPlanRef.current, newLessonPlan);
- appliedPatchesRef.current.push(patch);
- }
- return newLessonPlan ?? workingLessonPlan;
- };
-
- // Disable partial patches for now
- // const applyPatchWhileStillStreaming = useCallback(
- // (patch: PatchDocument, workingLessonPlan: LooseLessonPlan) => {
- // if (!isStreaming) {
- // return workingLessonPlan;
- // }
- // const newLessonPlan: LooseLessonPlan | undefined = applyLessonPlanPatch(
- // { ...workingLessonPlan },
- // patch,
- // );
- // return newLessonPlan ?? workingLessonPlan;
- // },
- // [isStreaming],
- // );
-
- return useMemo(() => {
- if (!throttledAssistantMessages || !throttledAssistantMessages.length) {
- return {
- tempLessonPlan: tempLessonPlanRef.current,
- partialPatches: [],
- validPatches: [],
- };
- }
-
- const lastMessage =
- throttledAssistantMessages[throttledAssistantMessages.length - 1];
- if (!lastMessage?.content) {
- return {
- tempLessonPlan: tempLessonPlanRef.current,
- partialPatches: [],
- validPatches: [],
- };
- }
-
- const { validPatches, partialPatches } =
- extractPatchesFromMessage(lastMessage);
-
- let workingLessonPlan = { ...tempLessonPlanRef.current };
-
- for (const patch of validPatches) {
- const { patch: patchToApply, hasBeenApplied } = patchHasBeenApplied(
- patch,
- appliedPatchesRef.current,
- messageHashes,
- );
-
- if (!hasBeenApplied && patchToApply) {
- workingLessonPlan = applyPatch(patchToApply, workingLessonPlan);
- }
- }
-
- // Do not apply partial patches for now
- // Keeping this commented out for now because we
- // will probably want to reintroduce this feature
- // const streamingPatch = partialPatches[partialPatches.length - 1];
-
- // if (streamingPatch) {
- // workingLessonPlan = applyPatchWhileStillStreaming(
- // streamingPatch,
- // workingLessonPlan,
- // );
- // }
-
- return {
- tempLessonPlan: workingLessonPlan,
- validPatches,
- partialPatches,
- };
- }, [throttledAssistantMessages, messageHashes]);
-};
diff --git a/apps/nextjs/src/instrumentation.ts b/apps/nextjs/src/instrumentation.ts
index 72a66aa19..d83242578 100644
--- a/apps/nextjs/src/instrumentation.ts
+++ b/apps/nextjs/src/instrumentation.ts
@@ -1,6 +1,9 @@
import * as Sentry from "@sentry/nextjs";
export async function register() {
+ if (process.env.TURBOPACK) {
+ return;
+ }
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("../sentry.server.config");
}
diff --git a/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts b/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts
new file mode 100644
index 000000000..ca383d555
--- /dev/null
+++ b/apps/nextjs/src/lib/lessonPlan/LessonPlanManager.ts
@@ -0,0 +1,134 @@
+import {
+ PatchDocument,
+ applyLessonPlanPatch,
+} from "@oakai/aila/src/protocol/jsonPatchProtocol";
+import { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
+import { aiLogger } from "@oakai/logger";
+import { Message } from "ai";
+import { createHash } from "crypto";
+import { EventEmitter } from "events";
+import { deepClone } from "fast-json-patch";
+
+import { extractPatchesFromMessage } from "./extractPatches";
+
+const log = aiLogger("lessons");
+
+export class LessonPlanManager {
+ private lessonPlan: LooseLessonPlan;
+ private appliedPatchHashes: Set = new Set();
+ private eventEmitter: EventEmitter = new EventEmitter();
+ private iteration: number | undefined;
+
+ constructor(initialLessonPlan: LooseLessonPlan = {}) {
+ this.lessonPlan = deepClone(initialLessonPlan);
+ }
+
+ public getLessonPlan(): LooseLessonPlan {
+ return this.lessonPlan;
+ }
+
+ public setLessonPlan(
+ newLessonPlan: LooseLessonPlan,
+ newIteration: number | undefined,
+ ): void {
+ if (
+ newIteration === undefined ||
+ this.iteration === undefined ||
+ newIteration > this.iteration
+ ) {
+ const currentKeys = Object.keys(this.lessonPlan).filter(
+ (k) => this.lessonPlan[k],
+ );
+ const newKeys = Object.keys(newLessonPlan).filter(
+ (k) => newLessonPlan[k],
+ );
+ log.info("Updating lesson plan from server", {
+ iteration: this.iteration,
+ newIteration,
+ keys: newKeys.length,
+ currentKeys: currentKeys.join("|"),
+ newKeys: newKeys.join("|"),
+ });
+ if (newKeys.length < currentKeys.length) {
+ log.warn(
+ `New lesson plan has fewer keys than current lesson plan: ${newKeys.length} < ${currentKeys.length}`,
+ );
+ }
+ this.lessonPlan = deepClone(newLessonPlan);
+ this.iteration = newIteration;
+ this.emitLessonPlan();
+ } else {
+ log.info(
+ `LessonPlanManager: Skipping setting lesson plan with iteration ${newIteration} because current iteration is ${this.iteration}`,
+ );
+ }
+ }
+
+ private emitLessonPlan = (): void => {
+ this.eventEmitter.emit("lessonPlanUpdated", {
+ lessonPlan: this.lessonPlan,
+ iteration: this.iteration,
+ });
+ };
+
+ public setLessonPlanWithDelay(
+ newLessonPlan: LooseLessonPlan,
+ iteration: number | undefined,
+ delay: number = 2000,
+ ): void {
+ const keys = Object.keys(newLessonPlan).filter((k) => newLessonPlan[k]);
+ log.info("Delay setting lesson plan", `${keys.length}`, keys.join("|"));
+ setTimeout(() => {
+ this.setLessonPlan(newLessonPlan, iteration);
+ }, delay);
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ public on(event: string, listener: (...args: any[]) => void): void {
+ this.eventEmitter.on(event, listener);
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ public off(event: string, listener: (...args: any[]) => void): void {
+ this.eventEmitter.off(event, listener);
+ }
+
+ public onMessageUpdated(message: Message): void {
+ if (message.role === "assistant") {
+ this.applyPatches(message);
+ }
+ }
+
+ private applyPatches(message: Message): void {
+ const { validPatches } = extractPatchesFromMessage(message);
+ let patchesApplied = false;
+ validPatches.forEach((patch) => {
+ const patchHash = this.generatePatchHash(patch);
+ if (!this.appliedPatchHashes.has(patchHash)) {
+ const startTime = performance.now();
+ const updatedLessonPlan = applyLessonPlanPatch(this.lessonPlan, patch);
+ const endTime = performance.now();
+ log.info(
+ `applyLessonPlanPatch took ${endTime - startTime} milliseconds`,
+ );
+ if (updatedLessonPlan) {
+ log.info("Applied patch", patch.value.path);
+ this.lessonPlan = deepClone(updatedLessonPlan);
+ this.appliedPatchHashes.add(patchHash);
+ patchesApplied = true;
+ }
+ }
+ });
+
+ if (patchesApplied) {
+ this.emitLessonPlan();
+ }
+ }
+
+ private generatePatchHash(patch: PatchDocument): string {
+ const patchString = JSON.stringify(patch);
+ const hash = createHash("sha256");
+ hash.update(patchString);
+ return hash.digest("hex");
+ }
+}
diff --git a/apps/nextjs/src/lib/lessonPlan/extractPatches.ts b/apps/nextjs/src/lib/lessonPlan/extractPatches.ts
new file mode 100644
index 000000000..828b56f0d
--- /dev/null
+++ b/apps/nextjs/src/lib/lessonPlan/extractPatches.ts
@@ -0,0 +1,10 @@
+import { extractPatches } from "@oakai/aila/src/protocol/jsonPatchProtocol";
+import { aiLogger } from "@oakai/logger";
+import { type Message } from "ai/react";
+
+const log = aiLogger("lessons");
+export function extractPatchesFromMessage(message: Message) {
+ log.info("Extracting patches from message", message);
+ const { validPatches, partialPatches } = extractPatches(message.content);
+ return { validPatches, partialPatches };
+}
diff --git a/apps/nextjs/src/lib/lessonPlan/nextSectionToGenerate.ts b/apps/nextjs/src/lib/lessonPlan/nextSectionToGenerate.ts
new file mode 100644
index 000000000..c05a2460a
--- /dev/null
+++ b/apps/nextjs/src/lib/lessonPlan/nextSectionToGenerate.ts
@@ -0,0 +1,30 @@
+import {
+ LooseLessonPlan,
+ LessonPlanKeys,
+} from "@oakai/aila/src/protocol/schema";
+
+import { groupedSectionsInOrder } from "./sectionsInOrder";
+
+// Method to determine the next sections to generate based on
+// the current state of the lesson plan.
+// We generate each section in a group, so this method will
+// return the next group of sections to generate or
+// any missing sections within the current group.
+export function nextSectionsToGenerate(
+ lessonPlan: LooseLessonPlan,
+): LessonPlanKeys[] {
+ // Iterate through the groupedSectionsInOrder array
+ for (const sectionGroup of groupedSectionsInOrder) {
+ // Filter out the missing sections within the group
+ const missingSections = sectionGroup.filter(
+ (section) => !(section in lessonPlan),
+ );
+ if (missingSections.length > 0) {
+ // If there are missing sections, return them
+ return missingSections;
+ }
+ }
+
+ // If all sections are complete, return an empty array
+ return [];
+}
diff --git a/apps/nextjs/src/lib/lessonPlan/organiseSections.ts b/apps/nextjs/src/lib/lessonPlan/organiseSections.ts
new file mode 100644
index 000000000..4e5c1592f
--- /dev/null
+++ b/apps/nextjs/src/lib/lessonPlan/organiseSections.ts
@@ -0,0 +1,25 @@
+import { LessonPlanKeys } from "@oakai/aila/src/protocol/schema";
+
+export const organiseSections: {
+ trigger: LessonPlanKeys;
+ dependants: LessonPlanKeys[];
+}[] = [
+ {
+ trigger: "learningOutcome",
+ dependants: ["learningOutcome", "learningCycles"],
+ },
+ {
+ trigger: "priorKnowledge",
+ dependants: [
+ "priorKnowledge",
+ "keyLearningPoints",
+ "misconceptions",
+ "keywords",
+ ],
+ },
+ {
+ trigger: "starterQuiz",
+ dependants: ["starterQuiz", "cycle1", "cycle2", "cycle3", "exitQuiz"],
+ },
+ { trigger: "additionalMaterials", dependants: ["additionalMaterials"] },
+];
diff --git a/apps/nextjs/src/lib/lessonPlan/useLessonPlanManager.ts b/apps/nextjs/src/lib/lessonPlan/useLessonPlanManager.ts
new file mode 100644
index 000000000..ce0165997
--- /dev/null
+++ b/apps/nextjs/src/lib/lessonPlan/useLessonPlanManager.ts
@@ -0,0 +1,44 @@
+import { useEffect, useState } from "react";
+
+import { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
+import { aiLogger } from "@oakai/logger";
+
+import { LessonPlanManager } from "./LessonPlanManager";
+
+const log = aiLogger("lessons");
+
+export function useLessonPlanManager(initialLessonPlan: LooseLessonPlan = {}) {
+ const [lessonPlanManager] = useState(
+ () => new LessonPlanManager(initialLessonPlan),
+ );
+ const [lessonPlan, setLessonPlan] = useState(
+ lessonPlanManager.getLessonPlan(),
+ );
+ const [iteration, setIteration] = useState(undefined);
+
+ useEffect(() => {
+ const onLessonPlanUpdated = ({
+ lessonPlan: updatedLessonPlan,
+ iteration: updatedIteration,
+ }: {
+ lessonPlan: LooseLessonPlan;
+ iteration: number | undefined;
+ }) => {
+ log.info("Update lesson plan state", updatedLessonPlan, updatedIteration);
+ setLessonPlan(updatedLessonPlan);
+ setIteration(updatedIteration);
+ };
+
+ lessonPlanManager.on("lessonPlanUpdated", onLessonPlanUpdated);
+
+ return () => {
+ lessonPlanManager.off("lessonPlanUpdated", onLessonPlanUpdated);
+ };
+ }, [lessonPlanManager]);
+
+ return {
+ lessonPlanManager,
+ lessonPlan,
+ iteration,
+ };
+}
diff --git a/apps/nextjs/tests-e2e/config/config.ts b/apps/nextjs/tests-e2e/config/config.ts
index c5d0f9bdd..fed0a9ee6 100644
--- a/apps/nextjs/tests-e2e/config/config.ts
+++ b/apps/nextjs/tests-e2e/config/config.ts
@@ -5,7 +5,8 @@ dotenv.config({ path: path.join(process.cwd(), ".env") });
export const TEST_USER_EMAIL = process.env.TEST_USER_EMAIL;
export const TEST_USER_PASSWORD = process.env.TEST_USER_PASSWORD;
+export const PORT = process.env.PORT ?? 2525;
export const TEST_BASE_URL =
- process.env.TEST_BASE_URL || "http://localhost:2525";
+ process.env.TEST_BASE_URL || `http://localhost:${PORT}`;
export const VERCEL_AUTOMATION_BYPASS_SECRET =
process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-1.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-1.chunks.txt
index 3bf050761..e478e24b5 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-1.chunks.txt
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-1.chunks.txt
@@ -3,26 +3,16 @@ type":"
ll
m
Message
-","sectionsToEdit":["
-learning
-Outcome
-","
-learning
-Cycles
-"],"patches":[
+","patches":[
{"
type":"
patch
","reasoning":"
-I
- have
- created
+Starting
+ a
new
- learning
- outcomes
- and
- learning
- cycles
+ lesson
+ plan
from
scratch
as
@@ -32,8 +22,7 @@ I
existing
Oak
lessons
- available
- for
+ on
this
topic
.","
@@ -49,15 +38,14 @@ Outcome
I
can
describe
- why
+ the
+ changes
+ in
+ Britain
+ after
the
Romans
left
- Britain
- and
- what
- happened
- afterwards
."
},"status":"
complete
@@ -65,29 +53,20 @@ complete
type":"
patch
","reasoning":"
-This
- patch
- adds
+Outlined
+ the
learning
cycles
- which
+ to
break
down
the
lesson
into
- achievable
- tasks
-,
- focusing
- on
- Roman
- departure
- and
- its
- impact
- on
- Britain
+ manageable
+ parts
+ for
+ pupils
.","
value":{"
type":"
@@ -99,48 +78,35 @@ add
learning
Cycles
","value":["
-Explain
- the
- reasons
- for
+Understand
+ why
the
Romans
- leaving
+ left
Britain
.","
-Describe
+Identify
the
+ immediate
changes
that
occurred
in
Britain
+.","
+Explore
+ how
+ life
+ in
+ Britain
+ evolved
after
the
Romans
- left
-.","
-Identify
- the
- role
- of
- archae
-ologists
- in
- uncover
-ing
- Roman
- history
.
"]},"status":"
complete
-"}],"sectionsEdited":["
-learning
-Outcome
-","
-learning
-Cycles
-"],"prompt":{"
+"}],"prompt":{"
type":"
text
","value":"
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-1.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-1.formatted.json
index 0a981311f..5166fbd50 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-1.formatted.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-1.formatted.json
@@ -1,44 +1,35 @@
{
"type": "llmMessage",
- "sectionsToEdit": [
- "learningOutcome",
- "learningCycles"
- ],
"patches": [
{
"type": "patch",
- "reasoning": "I have created new learning outcomes and learning cycles from scratch as there are no existing Oak lessons available for this topic.",
+ "reasoning": "Starting a new lesson plan from scratch as there are no existing Oak lessons on this topic.",
"value": {
"type": "string",
"op": "add",
"path": "/learningOutcome",
- "value": "I can describe why the Romans left Britain and what happened afterwards."
+ "value": "I can describe the changes in Britain after the Romans left."
},
"status": "complete"
},
{
"type": "patch",
- "reasoning": "This patch adds learning cycles which break down the lesson into achievable tasks, focusing on Roman departure and its impact on Britain.",
+ "reasoning": "Outlined the learning cycles to break down the lesson into manageable parts for pupils.",
"value": {
"type": "string-array",
"op": "add",
"path": "/learningCycles",
"value": [
- "Explain the reasons for the Romans leaving Britain.",
- "Describe the changes that occurred in Britain after the Romans left.",
- "Identify the role of archaeologists in uncovering Roman history."
+ "Understand why the Romans left Britain.",
+ "Identify the immediate changes that occurred in Britain.",
+ "Explore how life in Britain evolved after the Romans."
]
},
"status": "complete"
}
],
- "sectionsEdited": [
- "learningOutcome",
- "learningCycles"
- ],
"prompt": {
"type": "text",
"value": "Are the learning outcome and learning cycles appropriate for your pupils? If not, suggest an edit. Otherwise, tap **Continue** to move on to the next step."
- },
- "status": "complete"
-}
\ No newline at end of file
+ }
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-1.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-1.moderation.json
index 91cc3b3de..a03c1b98f 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-1.moderation.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-1.moderation.json
@@ -1,14 +1,14 @@
{
- "id": "chatcmpl-ANdWlVyt9QK14JTGZfiB9u3p3lQxr",
+ "id": "chatcmpl-AKmjVBXoaL0JWXYp9vMZaiOLLT3bl",
"object": "chat.completion",
- "created": 1730196851,
+ "created": 1729517253,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
- "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":4,\"t\":5},\"justification\":\"The lesson plan is compliant in the categories of 'Language and discrimination', 'Violence and crime', 'Upsetting, disturbing and sensitive', 'Nudity and sex', and 'Toxic', as it does not contain any inappropriate content or discussion for these categories. However, the 'Physical activity and safety' category is rated a 4 because the topic of archaeology may involve exploration of objects or sites, which can require supervision or safety precautions, particularly for the key-stage 1 age group. Although this is minimal, it should be noted for safety purposes.\",\"categories\":[\"p/exploration-of-objects\"]}",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan titled 'End of Roman Britain' for key-stage-1 history is fully compliant in all categories. It focuses on understanding historical events related to the Roman departure from Britain, without any discriminatory language, offensive language, or strong language. There is no depiction or discussion of conflict, serious violence, or sexual violence, aligning with the age-appropriate content for key-stage-1 students. The lesson does not include any upsetting, sensitive, or distressing content, and it avoids discussions of nudity or sexual content. There is no involvement of physical activities requiring safety measures, nor does it guide harmful behaviors or illegal activities. The content is educational and suitable for the intended young audience, ensuring a safe and respectful learning environment.\",\"categories\":[]}",
"refusal": null
},
"logprobs": null,
@@ -16,9 +16,9 @@
}
],
"usage": {
- "prompt_tokens": 2283,
- "completion_tokens": 154,
- "total_tokens": 2437,
+ "prompt_tokens": 2267,
+ "completion_tokens": 179,
+ "total_tokens": 2446,
"prompt_tokens_details": {
"cached_tokens": 2048
},
@@ -26,5 +26,5 @@
"reasoning_tokens": 0
}
},
- "system_fingerprint": "fp_90354628f2"
-}
\ No newline at end of file
+ "system_fingerprint": "fp_a7d06e42a7"
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-10.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-10.chunks.txt
new file mode 100644
index 000000000..39554dc38
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-10.chunks.txt
@@ -0,0 +1,291 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[
+{"
+type":"
+patch
+","reasoning":"
+Cycle
+
+3
+ will
+ discuss
+ how
+ life
+ changed
+ in
+ Britain
+ after
+ the
+ Romans
+ left
+.","
+value":{"
+type":"
+cycle
+","op":"
+add
+","path":"/
+cycle
+3
+","value":{"
+title":"
+Discuss
+ing
+ How
+ Life
+ Changed
+ in
+ Britain
+ After
+ the
+ Romans
+ Left
+","durationInMinutes":15
+,"explanation":{"
+spokenExplanation":["
+Describe
+ the
+ changes
+ in
+ daily
+ life
+ and
+ governance
+ without
+ Roman
+ rule
+.","
+Explain
+ the
+ decline
+ of
+ Roman
+-built
+ structures
+ and
+ how
+ new
+ settlements
+ emerged
+.","
+Discuss
+ how
+ trade
+ routes
+ were
+ altered
+ or
+ diminished
+.","
+Rel
+ate
+ these
+ changes
+ to
+ pupils
+'
+ understanding
+ of
+ Roman
+ contributions
+ to
+ Britain
+.","
+Enc
+ourage
+ pupils
+ to
+ compare
+ life
+ during
+ Roman
+ rule
+ and
+ after
+ their
+ departure
+."
+],"accompanyingSlideDetails":"
+Images
+ comparing
+ Roman
+ Britain
+ and
+ post
+-R
+oman
+ Britain
+.","
+imagePrompt":"
+Roman
+ Britain
+ vs
+ post
+-R
+oman
+ Britain
+","slideText":"
+Life
+ in
+ Britain
+ changed
+ with
+ the
+ decline
+ of
+ Roman
+ structures
+,
+ altered
+ trade
+ routes
+,
+ and
+ new
+ settlements
+."
+},"checkForUnderstanding":[
+{"
+question":"
+What
+ happened
+ to
+ Roman
+-built
+ structures
+ after
+ the
+ Romans
+ left
+?
+","answers":["
+They
+ declined
+"],"distractors":["
+They
+ were
+ improved
+","
+They
+ remained
+ the
+ same
+"]},{"
+question":"
+How
+ did
+ trade
+ change
+ after
+ the
+ Romans
+ left
+ Britain
+?
+","answers":["
+It
+ diminished
+"],"distractors":["
+It
+ expanded
+","
+It
+ became
+ more
+ central
+ised
+"]}],"practice":"
+Compare
+ and
+ contrast
+ daily
+ life
+ in
+ Roman
+ Britain
+ with
+ life
+ after
+ the
+ Romans
+ left
+.","
+feedback":"
+Model
+ answer
+:
+ Roman
+ Britain
+ had
+ structured
+ governance
+ and
+ trade
+ routes
+;
+ post
+-R
+oman
+ Britain
+ saw
+ infrastructure
+ decline
+ and
+ less
+ organised
+ trade
+."
+}},"status":"
+complete
+"}],"prompt":{"
+type":"
+text
+","value":"
+Cycle
+
+3
+ has
+ been
+ structured
+ to
+ discuss
+ life
+ changes
+ in
+ Britain
+ after
+ the
+ Romans
+ left
+.
+ Now
+,
+ let's
+ move
+ on
+ to
+ create
+ the
+ Exit
+ Quiz
+ to
+ assess
+ pupils
+'
+ understanding
+ of
+ the
+ lesson
+.
+ Tap
+ **
+Continue
+**
+ to
+ proceed
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-10.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-10.formatted.json
new file mode 100644
index 000000000..604ee3265
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-10.formatted.json
@@ -0,0 +1,59 @@
+{
+ "type": "llmMessage",
+ "patches": [
+ {
+ "type": "patch",
+ "reasoning": "Cycle 3 will discuss how life changed in Britain after the Romans left.",
+ "value": {
+ "type": "cycle",
+ "op": "add",
+ "path": "/cycle3",
+ "value": {
+ "title": "Discussing How Life Changed in Britain After the Romans Left",
+ "durationInMinutes": 15,
+ "explanation": {
+ "spokenExplanation": [
+ "Describe the changes in daily life and governance without Roman rule.",
+ "Explain the decline of Roman-built structures and how new settlements emerged.",
+ "Discuss how trade routes were altered or diminished.",
+ "Relate these changes to pupils' understanding of Roman contributions to Britain.",
+ "Encourage pupils to compare life during Roman rule and after their departure."
+ ],
+ "accompanyingSlideDetails": "Images comparing Roman Britain and post-Roman Britain.",
+ "imagePrompt": "Roman Britain vs post-Roman Britain",
+ "slideText": "Life in Britain changed with the decline of Roman structures, altered trade routes, and new settlements."
+ },
+ "checkForUnderstanding": [
+ {
+ "question": "What happened to Roman-built structures after the Romans left?",
+ "answers": [
+ "They declined"
+ ],
+ "distractors": [
+ "They were improved",
+ "They remained the same"
+ ]
+ },
+ {
+ "question": "How did trade change after the Romans left Britain?",
+ "answers": [
+ "It diminished"
+ ],
+ "distractors": [
+ "It expanded",
+ "It became more centralised"
+ ]
+ }
+ ],
+ "practice": "Compare and contrast daily life in Roman Britain with life after the Romans left.",
+ "feedback": "Model answer: Roman Britain had structured governance and trade routes; post-Roman Britain saw infrastructure decline and less organised trade."
+ }
+ },
+ "status": "complete"
+ }
+ ],
+ "prompt": {
+ "type": "text",
+ "value": "Cycle 3 has been structured to discuss life changes in Britain after the Romans left. Now, let's move on to create the Exit Quiz to assess pupils' understanding of the lesson. Tap **Continue** to proceed."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-10.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-10.moderation.json
new file mode 100644
index 000000000..ba9e264de
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-10.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKMzyvvu9chYePcthSDR8ZJcNbVgn",
+ "object": "chat.completion",
+ "created": 1729418330,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan is fully compliant across all categories. It is designed for Key Stage 1 students, focusing on historical events without any discriminatory, offensive, or strong language. It does not depict or discuss violence, conflict, or sensitive and distressing content. There is no mention of nudity or sexual content. The activities described are educational and appropriate for young learners, involving no physical exploration or use of equipment that requires supervision. The lesson plan does not contain any toxic content, instructions on harmful behavior, or illegal activity. It is a well-constructed educational resource for understanding the historical context of the end of Roman rule in Britain.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 3628,
+ "completion_tokens": 159,
+ "total_tokens": 3787,
+ "prompt_tokens_details": {
+ "cached_tokens": 3200
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-11.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-11.chunks.txt
new file mode 100644
index 000000000..6083a0f30
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-11.chunks.txt
@@ -0,0 +1,267 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[
+{"
+type":"
+patch
+","reasoning":"
+The
+ Exit
+ Quiz
+ assesses
+ pupils
+'
+ understanding
+ of
+ the
+ entire
+ lesson
+ on
+ the
+ end
+ of
+ Roman
+ Britain
+.","
+value":{"
+type":"
+quiz
+","op":"
+add
+","path":"/
+exit
+Quiz
+","value":[
+{"
+question":"
+What
+ marked
+ the
+ end
+ of
+ Roman
+ rule
+ in
+ Britain
+?
+","answers":["
+The
+ withdrawal
+ of
+ Roman
+ soldiers
+"],"distractors":["
+The
+ building
+ of
+ Had
+rian
+'s
+ Wall
+","
+The
+ arrival
+ of
+ the
+ Vikings
+"]},{"
+question":"
+Why
+ did
+ Roman
+ soldiers
+ leave
+ Britain
+?
+","answers":["
+To
+ defend
+ other
+ parts
+ of
+ the
+ Empire
+"],"distractors":["
+They
+ were
+ no
+ longer
+ needed
+","
+They
+ wanted
+ to
+ explore
+ new
+ lands
+"]},{"
+question":"
+What
+ was
+ one
+ impact
+ of
+ the
+ Roman
+ withdrawal
+ on
+ Britain
+?
+","answers":["
+In
+creased
+ invas
+ions
+"],"distractors":["
+Impro
+ved
+ trade
+ routes
+","
+Str
+onger
+ local
+ governance
+"]},{"
+question":"
+Which
+ groups
+ invaded
+ Britain
+ after
+ the
+ Romans
+ left
+?
+","answers":["
+S
+ax
+ons
+ and
+ P
+icts
+"],"distractors":["
+Romans
+ and
+ Norm
+ans
+","
+V
+ik
+ings
+ and
+ Cel
+ts
+"]},{"
+question":"
+How
+ did
+ life
+ in
+ Britain
+ change
+ after
+ the
+ Romans
+ left
+?
+","answers":["
+Trade
+ routes
+ diminished
+"],"distractors":["
+New
+ Roman
+ towns
+ were
+ built
+","
+Roman
+ laws
+ were
+ strengthened
+"]},{"
+question":"
+What
+ happened
+ to
+ Roman
+-built
+ structures
+ after
+ the
+ Romans
+ left
+?
+","answers":["
+They
+ declined
+"],"distractors":["
+They
+ were
+ enhanced
+","
+They
+ stayed
+ intact
+"]}]},"status":"
+complete
+"}],"prompt":{"
+type":"
+text
+","value":"
+The
+ Exit
+ Quiz
+ has
+ been
+ created
+ to
+ assess
+ pupils
+'
+ understanding
+ of
+ the
+ lesson
+ content
+.
+ With
+ this
+,
+ the
+ lesson
+ plan
+ is
+ almost
+ complete
+.
+ Would
+ you
+ like
+ to
+ add
+ any
+ additional
+ materials
+ or
+ make
+ any
+ further
+ edits
+?
+ Tap
+ **
+Continue
+**
+ to
+ final
+ise
+ the
+ lesson
+ plan
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-11.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-11.formatted.json
new file mode 100644
index 000000000..2b534a67e
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-11.formatted.json
@@ -0,0 +1,81 @@
+{
+ "type": "llmMessage",
+ "patches": [
+ {
+ "type": "patch",
+ "reasoning": "The Exit Quiz assesses pupils' understanding of the entire lesson on the end of Roman Britain.",
+ "value": {
+ "type": "quiz",
+ "op": "add",
+ "path": "/exitQuiz",
+ "value": [
+ {
+ "question": "What marked the end of Roman rule in Britain?",
+ "answers": [
+ "The withdrawal of Roman soldiers"
+ ],
+ "distractors": [
+ "The building of Hadrian's Wall",
+ "The arrival of the Vikings"
+ ]
+ },
+ {
+ "question": "Why did Roman soldiers leave Britain?",
+ "answers": [
+ "To defend other parts of the Empire"
+ ],
+ "distractors": [
+ "They were no longer needed",
+ "They wanted to explore new lands"
+ ]
+ },
+ {
+ "question": "What was one impact of the Roman withdrawal on Britain?",
+ "answers": [
+ "Increased invasions"
+ ],
+ "distractors": [
+ "Improved trade routes",
+ "Stronger local governance"
+ ]
+ },
+ {
+ "question": "Which groups invaded Britain after the Romans left?",
+ "answers": [
+ "Saxons and Picts"
+ ],
+ "distractors": [
+ "Romans and Normans",
+ "Vikings and Celts"
+ ]
+ },
+ {
+ "question": "How did life in Britain change after the Romans left?",
+ "answers": [
+ "Trade routes diminished"
+ ],
+ "distractors": [
+ "New Roman towns were built",
+ "Roman laws were strengthened"
+ ]
+ },
+ {
+ "question": "What happened to Roman-built structures after the Romans left?",
+ "answers": [
+ "They declined"
+ ],
+ "distractors": [
+ "They were enhanced",
+ "They stayed intact"
+ ]
+ }
+ ]
+ },
+ "status": "complete"
+ }
+ ],
+ "prompt": {
+ "type": "text",
+ "value": "The Exit Quiz has been created to assess pupils' understanding of the lesson content. With this, the lesson plan is almost complete. Would you like to add any additional materials or make any further edits? Tap **Continue** to finalise the lesson plan."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-11.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-11.moderation.json
new file mode 100644
index 000000000..d1d517e24
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-11.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKN0FPKfpsjvL4ar6b2Qs1BwvUkpJ",
+ "object": "chat.completion",
+ "created": 1729418347,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":4,\"t\":5},\"justification\":\"The lesson plan is fully compliant in the categories of Language and discrimination, Violence and crime, Upsetting, disturbing and sensitive content, Nudity and sex, and Toxic content. It is designed for Key Stage 1 students and focuses on historical events without any discriminatory, violent, sensitive, or sexual content. The lesson involves some physical activity aspects, such as the use of slides and images to aid understanding, thus receiving a score of 4 in the Physical category. However, no safety concerns or imitable behaviors are present. Therefore, overall, the lesson plan is suitable for the intended young audience.\",\"categories\":[\"p/external-content\"]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 3859,
+ "completion_tokens": 158,
+ "total_tokens": 4017,
+ "prompt_tokens_details": {
+ "cached_tokens": 3456
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-12.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-12.chunks.txt
new file mode 100644
index 000000000..836cafac8
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-12.chunks.txt
@@ -0,0 +1,68 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[]
+,"prompt":{"
+type":"
+text
+","value":"
+The
+ lesson
+ plan
+ is
+ fully
+ prepared
+ and
+ ready
+ for
+ use
+.
+ If
+ you
+ need
+ any
+ further
+ edits
+ or
+ additions
+,
+ feel
+ free
+ to
+ ask
+.
+ Otherwise
+,
+ you
+ can
+ download
+ or
+ share
+ your
+ lesson
+ now
+.
+ \
+n
+\n
+Thank
+ you
+ for
+ using
+ the
+ lesson
+ planning
+ tool
+,
+ and
+ I
+ hope
+ you
+ have
+ a
+ great
+ lesson
+!"
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-12.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-12.formatted.json
new file mode 100644
index 000000000..dc10c7fe6
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-12.formatted.json
@@ -0,0 +1,8 @@
+{
+ "type": "llmMessage",
+ "patches": [],
+ "prompt": {
+ "type": "text",
+ "value": "The lesson plan is fully prepared and ready for use. If you need any further edits or additions, feel free to ask. Otherwise, you can download or share your lesson now. \n\nThank you for using the lesson planning tool, and I hope you have a great lesson!"
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-12.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-12.moderation.json
new file mode 100644
index 000000000..196ee0337
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-12.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKE5pz7geQhgbCbj8HyA21W9z486O",
+ "object": "chat.completion",
+ "created": 1729384097,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan titled 'The End of Roman Britain' for Key Stage 1 history is fully compliant across all categories. The content is educational, focusing on historical events such as the end of Roman rule and the subsequent invasions by Saxons, Angles, and Jutes. It does not contain any discriminatory language, offensive language, or strong language. There is no depiction or discussion of violence, serious violence, or sexual violence. The lesson avoids upsetting, sensitive, or distressing content and does not include any nudity or sexual content. Physical activities or exploration involving safety concerns are not present, nor is there any external content requiring adult supervision. Finally, the lesson does not contain any toxic content such as guides to self-harm or illegal activities. The content is age-appropriate for Key Stage 1 students, focusing on historical facts and their impacts in a straightforward manner.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 4040,
+ "completion_tokens": 209,
+ "total_tokens": 4249,
+ "prompt_tokens_details": {
+ "cached_tokens": 3840
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-13.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-13.chunks.txt
new file mode 100644
index 000000000..06c5169f6
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-13.chunks.txt
@@ -0,0 +1,40 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[]
+,"prompt":{"
+type":"
+text
+","value":"
+If
+ you
+ have
+ any
+ more
+ questions
+ or
+ need
+ assistance
+ with
+ another
+ lesson
+,
+ feel
+ free
+ to
+ ask
+.
+ I'm
+ here
+ to
+ help
+!
+ Have
+ a
+ wonderful
+ day
+ teaching
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-13.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-13.formatted.json
new file mode 100644
index 000000000..552ce0c5f
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-13.formatted.json
@@ -0,0 +1,8 @@
+{
+ "type": "llmMessage",
+ "patches": [],
+ "prompt": {
+ "type": "text",
+ "value": "If you have any more questions or need assistance with another lesson, feel free to ask. I'm here to help! Have a wonderful day teaching."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-13.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-13.moderation.json
new file mode 100644
index 000000000..aa0cd54e8
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-13.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKE60s6Hhbti7l59fzsIQ6ESbZ5mM",
+ "object": "chat.completion",
+ "created": 1729384108,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan titled \\\"The End of Roman Britain\\\" is fully compliant across all category groups for Key Stage 1 students. \\n\\n- **Language and Discrimination**: The content is free from any discriminatory language, behavior, or images, and does not use offensive or strong language. The historical context provided is factual and sensitive to the age group.\\n\\n- **Violence and Crime**: There is no depiction or discussion of violence, serious conflict, or sexual violence. The invasions mentioned are described in a historical context appropriate for young learners.\\n\\n- **Upsetting, Disturbing and Sensitive**: The lesson does not contain upsetting or sensitive content. It presents historical facts without delving into distressing details that could be inappropriate for the young audience.\\n\\n- **Nudity and Sex**: There is no depiction or discussion of nudity or sexual content.\\n\\n- **Physical Activity and Safety**: The lesson does not involve any activities that require physical exploration, use of equipment, or exposure to external content. It is focused on classroom-based learning activities such as drawing and writing.\\n\\n- **Toxic**: There are no elements that guide or encourage harmful behaviors or activities.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 4040,
+ "completion_tokens": 281,
+ "total_tokens": 4321,
+ "prompt_tokens_details": {
+ "cached_tokens": 3840
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-14.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-14.chunks.txt
new file mode 100644
index 000000000..afc8ef266
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-14.chunks.txt
@@ -0,0 +1,45 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[]
+,"prompt":{"
+type":"
+text
+","value":"
+If
+ there's
+ anything
+ else
+ you'd
+ like
+ to
+ do
+,
+ such
+ as
+ starting
+ a
+ new
+ lesson
+ plan
+ or
+ making
+ adjustments
+ to
+ this
+ one
+,
+ just
+ let
+ me
+ know
+.
+ I'm
+ here
+ to
+ assist
+ you
+!"
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-14.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-14.formatted.json
new file mode 100644
index 000000000..c46fa9e9a
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-14.formatted.json
@@ -0,0 +1,8 @@
+{
+ "type": "llmMessage",
+ "patches": [],
+ "prompt": {
+ "type": "text",
+ "value": "If there's anything else you'd like to do, such as starting a new lesson plan or making adjustments to this one, just let me know. I'm here to assist you!"
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-14.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-14.moderation.json
new file mode 100644
index 000000000..ed2412ebb
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-14.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKE6CKoXNFC9jmC4kppZDi8BkKjBR",
+ "object": "chat.completion",
+ "created": 1729384120,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan is fully compliant across all categories. There is no presence of discriminatory language or imagery, offensive language, or strong language. There is no depiction or discussion of violence, serious conflict, or sexual violence. The content does not explore upsetting, disturbing, or sensitive topics in a manner that would be inappropriate for Key Stage 1 students. There is no depiction or discussion of nudity or sexual content. The lesson does not involve physical activities, exploration of objects, or use of equipment that would require supervision, nor does it involve external content. Finally, the lesson does not contain any toxic content such as guides for harmful behavior or illegal activity. The content is appropriate for the intended young audience and focuses on historical facts presented in a suitable manner for Key Stage 1 students.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 4040,
+ "completion_tokens": 189,
+ "total_tokens": 4229,
+ "prompt_tokens_details": {
+ "cached_tokens": 3840
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-2.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-2.chunks.txt
index 481f2de6f..930bed14e 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-2.chunks.txt
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-2.chunks.txt
@@ -21,21 +21,16 @@ keywords
type":"
patch
","reasoning":"
-Ident
-ified
+Established
prior
knowledge
that
- KS
-1
pupils
should
have
before
- starting
- this
- lesson
- on
+ learning
+ about
the
end
of
@@ -56,47 +51,57 @@ The
Romans
invaded
Britain
- and
- ruled
- for
- several
- centuries
+ in
+ AD
+
+43
.","
Roman
- roads
- and
- towns
- were
- built
- during
- their
- occupation
-.","
-Brit
-ain
+ Britain
was
part
of
the
Roman
Empire
+ for
+ nearly
+
+400
+ years
.","
-The
- concept
- of
- an
- empire
+Romans
+ built
+ roads
+,
+ towns
+,
and
- its
- importance
+ walls
+ in
+ Britain
.","
-Basic
- understanding
- of
- what
- archae
-ologists
- do
+Roman
+ culture
+ influenced
+ life
+ in
+ Britain
+,
+ including
+ buildings
+ and
+ language
+.","
+The
+ Roman
+ army
+ was
+ powerful
+ and
+ well
+-organ
+ised
.
"]},"status":"
complete
@@ -104,16 +109,12 @@ complete
type":"
patch
","reasoning":"
-Outlined
+Ident
+ified
key
learning
points
- that
- pupils
- should
- take
- away
- from
+ for
the
lesson
on
@@ -138,7 +139,7 @@ The
Romans
left
Britain
- around
+ in
AD
410
@@ -146,13 +147,13 @@ The
to
pressures
on
- their
- empire
-.","
-After
the
- Romans
- left
+ Roman
+ Empire
+.","
+Without
+ Roman
+ protection
,
Britain
faced
@@ -161,35 +162,44 @@ ions
from
other
groups
- like
- the
- Sax
-ons
.","
-Many
+Changes
+ included
+ decline
+ in
Roman
- buildings
+-style
+ houses
and
- roads
- influenced
- the
- landscape
- of
- Britain
+ infrastructure
.","
-Ar
-chae
-ologists
- help
- uncover
- the
- history
- of
+Econom
+y
+ shifted
+ from
Roman
+ coins
+ to
+ bar
+tering
+ and
+ local
+ trade
+.","
+New
+ groups
+,
+ such
+ as
+ the
+ Sax
+ons
+,
+ began
+ to
+ settle
+ in
Britain
- through
- excav
-ations
.
"]},"status":"
complete
@@ -197,8 +207,7 @@ complete
type":"
patch
","reasoning":"
-Address
-ed
+Outlined
common
misconceptions
about
@@ -207,14 +216,10 @@ ed
of
Roman
Britain
- to
- help
- teachers
- correct
- them
- during
- the
- lesson
+ and
+ provided
+ clar
+ifications
.","
value":{"
type":"
@@ -232,55 +237,171 @@ ceptions
misconception":"
The
Romans
- left
- Britain
- because
- they
were
- defeated
+ forced
+ out
by
the
- Brit
-ons
+ British
+ people
","description":"
-The
+It
+ is
+ more
+ accurate
+ to
+ say
+ the
Romans
left
due
to
- internal
- problems
+ challenges
within
- the
+ their
+ own
empire
- and
+,
+ including
threats
elsewhere
-,
- not
- because
- they
- were
- defeated
- by
- the
- Brit
-ons
."
},{"
misconception":"
Roman
- Britain
- ended
- suddenly
- without
- any
- lasting
- impact
+ culture
+ completely
+ disappeared
+ after
+ they
+ left
","description":"
+Many
+ Roman
+ influences
+ remained
+,
+ such
+ as
+ roads
+ and
+ some
+ aspects
+ of
+ lifestyle
+,
+ but
+ new
+ cultures
+ also
+ emerged
+."
+},{"
+misconception":"
+Brit
+ain
+ was
+ completely
+ isolated
+ after
+ the
+ Romans
+ left
+","description":"
+Although
+ the
+ Roman
+ departure
+ led
+ to
+ changes
+,
+ Britain
+ still
+ interacted
+ with
+ other
+ cultures
+ and
+ groups
+."
+}]},"status":"
+complete
+"},{"
+type":"
+patch
+","reasoning":"
+Selected
+ important
+ keywords
+ that
+ will
+ be
+ used
+ during
+ the
+ lesson
+.","
+value":{"
+type":"
+keywords
+","op":"
+add
+","path":"/
+keywords
+","value":[
+{"
+keyword":"
Roman
- influence
- persisted
+ Empire
+","definition":"
+A
+ vast
+ empire
+ that
+ ruled
+ over
+ Britain
+ from
+ AD
+
+43
+ to
+ AD
+
+410
+."
+},{"
+keyword":"
+In
+vasion
+","definition":"
+An
+ instance
+ of
+ invading
+ a
+ country
+ or
+ region
+ with
+ an
+ armed
+ force
+."
+},{"
+keyword":"
+S
+axon
+","definition":"
+A
+ group
+ of
+ German
+ic
+ people
+ who
+ settled
in
Britain's
infrastructure
@@ -430,22 +551,38 @@ A
Romans
left
."
+},{"
+keyword":"
+Infrastructure
+","definition":"
+Basic
+ physical
+ structures
+ like
+ roads
+ and
+ buildings
+ needed
+ for
+ society
+."
+},{"
+keyword":"
+Bar
+tering
+","definition":"
+Ex
+changing
+ goods
+ and
+ services
+ without
+ using
+ money
+."
}]},"status":"
complete
-"}],"sectionsEdited":["
-prior
-Knowledge
-","
-key
-Learning
-Points
-","
-mis
-con
-ceptions
-","
-keywords
-"],"prompt":{"
+"}],"prompt":{"
type":"
text
","value":"
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-2.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-2.formatted.json
index 617fb17e0..bdc32b9b0 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-2.formatted.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-2.formatted.json
@@ -9,52 +9,57 @@
"patches": [
{
"type": "patch",
- "reasoning": "Identified prior knowledge that KS1 pupils should have before starting this lesson on the end of Roman Britain.",
+ "reasoning": "Established prior knowledge that pupils should have before learning about the end of Roman Britain.",
"value": {
"type": "string-array",
"op": "add",
"path": "/priorKnowledge",
"value": [
- "The Romans invaded Britain and ruled for several centuries.",
- "Roman roads and towns were built during their occupation.",
- "Britain was part of the Roman Empire.",
- "The concept of an empire and its importance.",
- "Basic understanding of what archaeologists do."
+ "The Romans invaded Britain in AD 43.",
+ "Roman Britain was part of the Roman Empire for nearly 400 years.",
+ "Romans built roads, towns, and walls in Britain.",
+ "Roman culture influenced life in Britain, including buildings and language.",
+ "The Roman army was powerful and well-organised."
]
},
"status": "complete"
},
{
"type": "patch",
- "reasoning": "Outlined key learning points that pupils should take away from the lesson on the end of Roman Britain.",
+ "reasoning": "Identified key learning points for the lesson on the end of Roman Britain.",
"value": {
"type": "string-array",
"op": "add",
"path": "/keyLearningPoints",
"value": [
- "The Romans left Britain around AD 410 due to pressures on their empire.",
- "After the Romans left, Britain faced invasions from other groups like the Saxons.",
- "Many Roman buildings and roads influenced the landscape of Britain.",
- "Archaeologists help uncover the history of Roman Britain through excavations."
+ "The Romans left Britain in AD 410 due to pressures on the Roman Empire.",
+ "Without Roman protection, Britain faced invasions from other groups.",
+ "Changes included decline in Roman-style houses and infrastructure.",
+ "Economy shifted from Roman coins to bartering and local trade.",
+ "New groups, such as the Saxons, began to settle in Britain."
]
},
"status": "complete"
},
{
"type": "patch",
- "reasoning": "Addressed common misconceptions about the end of Roman Britain to help teachers correct them during the lesson.",
+ "reasoning": "Outlined common misconceptions about the end of Roman Britain and provided clarifications.",
"value": {
"type": "misconceptions",
"op": "add",
"path": "/misconceptions",
"value": [
{
- "misconception": "The Romans left Britain because they were defeated by the Britons",
- "description": "The Romans left due to internal problems within the empire and threats elsewhere, not because they were defeated by the Britons."
+ "misconception": "The Romans were forced out by the British people",
+ "description": "It is more accurate to say the Romans left due to challenges within their own empire, including threats elsewhere."
},
{
- "misconception": "Roman Britain ended suddenly without any lasting impact",
- "description": "Roman influence persisted in Britain's infrastructure, such as roads and towns, even after their departure."
+ "misconception": "Roman culture completely disappeared after they left",
+ "description": "Many Roman influences remained, such as roads and some aspects of lifestyle, but new cultures also emerged."
+ },
+ {
+ "misconception": "Britain was completely isolated after the Romans left",
+ "description": "Although the Roman departure led to changes, Britain still interacted with other cultures and groups."
}
]
},
@@ -62,31 +67,31 @@
},
{
"type": "patch",
- "reasoning": "Provided keywords that will be used throughout the lesson to ensure pupils understand the key concepts.",
+ "reasoning": "Selected important keywords that will be used during the lesson.",
"value": {
"type": "keywords",
"op": "add",
"path": "/keywords",
"value": [
{
- "keyword": "Romans",
- "definition": "People from the ancient city of Rome who ruled over Britain for several centuries."
+ "keyword": "Roman Empire",
+ "definition": "A vast empire that ruled over Britain from AD 43 to AD 410."
},
{
- "keyword": "Empire",
- "definition": "A large group of territories and people ruled over by a single authority, like the Roman Empire."
+ "keyword": "Invasion",
+ "definition": "An instance of invading a country or region with an armed force."
},
{
- "keyword": "Archaeologist",
- "definition": "A person who studies human history by digging up and examining ancient sites and objects."
+ "keyword": "Saxon",
+ "definition": "A group of Germanic people who settled in Britain after the Romans left."
},
{
- "keyword": "Invasion",
- "definition": "An instance of invading a country or region with an armed force."
+ "keyword": "Infrastructure",
+ "definition": "Basic physical structures like roads and buildings needed for society."
},
{
- "keyword": "Saxons",
- "definition": "A group of tribes from northern Europe who invaded Britain after the Romans left."
+ "keyword": "Bartering",
+ "definition": "Exchanging goods and services without using money."
}
]
},
@@ -102,6 +107,5 @@
"prompt": {
"type": "text",
"value": "Are the prior knowledge, key learning points, misconceptions, and keywords sections suitable for your class? If not, reply with what I should change. Otherwise, tap **Continue** to move on to the next step."
- },
- "status": "complete"
-}
\ No newline at end of file
+ }
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-2.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-2.moderation.json
index 171cc2eed..e500c243c 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-2.moderation.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-2.moderation.json
@@ -1,14 +1,14 @@
{
- "id": "chatcmpl-ANdX7W6LJidRv2NxImpbuB49osq2h",
+ "id": "chatcmpl-AKmjpkZpB79gEEaBiZYaV37GBVkac",
"object": "chat.completion",
- "created": 1730196873,
+ "created": 1729517273,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
- "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan on the 'End of Roman Britain' is fully compliant across all categories. It is designed for Key Stage 1 (ages 5-7) and focuses on historical facts about the Romans leaving Britain, without any inclusion of discriminatory language, offensive or strong language. There is no mention of violence, crime, or any upsetting, sensitive, or distressing content. The lesson does not include any depiction or discussion of nudity or sexual content. Additionally, there is no physical activity or safety concern involved, and no external content or use of equipment requiring supervision is mentioned. Finally, the lesson plan does not contain any toxic elements like encouragement of harmful behavior or instructions on creating weapons. All content is appropriate for the intended young audience and is presented in an educational and age-appropriate manner.\",\"categories\":[]}",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan on the 'End of Roman Britain' is fully compliant across all categories. It does not contain any discriminatory language, offensive language, or strong language. There is no depiction or discussion of violence or conflict, ensuring it is suitable for Key Stage 1 students. The content is educational and does not include any upsetting, sensitive, or distressing topics. Additionally, there is no discussion of nudity or sexual content. The plan does not involve any physical activity or exploration that could require safety supervision, nor does it include any toxic or harmful instructions. The lesson is age-appropriate, focusing on historical changes in Britain without delving into any inappropriate or sensitive content for young learners.\",\"categories\":[]}",
"refusal": null
},
"logprobs": null,
@@ -16,9 +16,9 @@
}
],
"usage": {
- "prompt_tokens": 2600,
- "completion_tokens": 193,
- "total_tokens": 2793,
+ "prompt_tokens": 2617,
+ "completion_tokens": 171,
+ "total_tokens": 2788,
"prompt_tokens_details": {
"cached_tokens": 2048
},
@@ -26,5 +26,5 @@
"reasoning_tokens": 0
}
},
- "system_fingerprint": "fp_90354628f2"
-}
\ No newline at end of file
+ "system_fingerprint": "fp_a7d06e42a7"
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-3.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-3.chunks.txt
index 0bea461fd..d555fdad6 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-3.chunks.txt
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-3.chunks.txt
@@ -23,7 +23,7 @@ Quiz
type":"
patch
","reasoning":"
-Designed
+Created
a
starter
quiz
@@ -33,14 +33,16 @@ Designed
'
prior
knowledge
- on
- Roman
- Britain
before
- the
- main
- lesson
+ introducing
+ new
content
+ about
+ the
+ end
+ of
+ Roman
+ Britain
.","
value":{"
type":"
@@ -53,187 +55,179 @@ Quiz
","value":[
{"
question":"
-What
+When
did
the
Romans
- build
- in
+ invade
Britain
- during
- their
- rule
?
","answers":["
-Road
-s
- and
- towns
+AD
+
+43
"],"distractors":["
-Cast
-les
- and
- forts
+AD
+
+410
","
-Schools
- and
- hospitals
+AD
+
+106
+6
"]},{"
question":"
How
long
- did
- the
- Romans
- rule
- over
+ was
Britain
+ part
+ of
+ the
+ Roman
+ Empire
?
","answers":["
-Several
- centuries
+Nearly
+
+400
+ years
"],"distractors":["
-A
- few
+200
years
","
-A
- decade
+600
+ years
"]},{"
question":"
What
- is
- an
- empire
+ did
+ the
+ Romans
+ build
+ in
+ Britain
?
","answers":["
-A
- large
- group
- of
- territories
- ruled
- by
- one
- authority
+Road
+s
+,
+ towns
+,
+ and
+ walls
"],"distractors":["
-A
- small
- country
+Cast
+les
+ and
+ pal
+aces
","
-A
- type
- of
- government
+Sk
+yscr
+apers
"]},{"
question":"
What
- role
- do
- archae
-ologists
- play
+ aspect
+ of
+ life
+ did
+ Roman
+ culture
+ influence
in
- history
+ Britain
?
","answers":["
-They
- study
- human
- history
- by
- digging
- up
- ancient
- sites
+Buildings
+ and
+ language
"],"distractors":["
-They
- write
- history
- books
+Cl
+othing
+ and
+ food
","
-They
- teach
- history
- in
- schools
+Music
+ and
+ dance
"]},{"
question":"
-Which
- empire
- did
- Britain
- belong
- to
- during
+What
+ was
+ the
Roman
- rule
+ army
+ known
+ for
?
","answers":["
-The
- Roman
- Empire
+Being
+ powerful
+ and
+ well
+-organ
+ised
"],"distractors":["
-The
- Greek
- Empire
+Being
+ small
+ and
+ dis
+organ
+ised
","
-The
- Egyptian
- Empire
+Being
+ peaceful
+ and
+ passive
"]},{"
question":"
What
- is
- one
- thing
- pupils
- should
- understand
- before
- this
- lesson
+ year
+ did
+ the
+ Romans
+ leave
+ Britain
?
","answers":["
-The
- concept
- of
- an
- empire
+AD
+
+410
"],"distractors":["
-The
- history
- of
- the
- Sax
-ons
+AD
+
+43
","
-The
- fall
- of
- the
- Roman
- Empire
+AD
+
+106
+6
"]}]},"status":"
complete
"},{"
type":"
patch
","reasoning":"
-Develop
-ed
+Structured
the
first
learning
cycle
- focusing
- on
- explaining
+ to
+ introduce
why
the
Romans
left
Britain
+ and
+ establish
+ a
+ foundation
+ for
+ understanding
.","
value":{"
type":"
@@ -256,8 +250,7 @@ spokenExplanation":["
Discuss
the
pressures
- faced
- by
+ on
the
Roman
Empire
@@ -267,66 +260,60 @@ Discuss
410
.","
Explain
- how
- internal
- conflicts
- weakened
+ that
the
Roman
- control
- over
- distant
- regions
- like
- Britain
-.","
-Describe
- the
- external
+ Empire
+ was
+ facing
threats
from
- other
- tribes
- and
+ various
groups
- that
- required
- Roman
- attention
- elsewhere
+ outside
+ Britain
.","
Mention
- how
- resources
- and
- troops
- were
- needed
- more
- urgently
- in
- other
- parts
- of
+ that
the
- empire
+ Roman
+ Empire
+ was
+ struggling
+ to
+ defend
+ its
+ vast
+ territories
.","
-Highlight
- that
+Describe
+ how
the
decision
- to
- leave
was
- strategic
-,
- not
- due
+ made
to
- defeat
- by
- Brit
-ons
+ withdraw
+ troops
+ from
+ Britain
+ to
+ focus
+ on
+ defending
+ Rome
+.","
+Connect
+ this
+ to
+ the
+ eventual
+ departure
+ of
+ the
+ Romans
+ from
+ Britain
."
],"accompanyingSlideDetails":"
A
@@ -338,35 +325,34 @@ A
to
the
Roman
- departure
+ withdrawal
from
Britain
.","
imagePrompt":"
Roman
Empire
- timeline
- AD
-
-410
+ decline
+ map
","slideText":"
The
Romans
left
Britain
- around
+ in
AD
410
due
to
- internal
- and
- external
pressures
on
their
empire
+,
+ including
+ threats
+ elsewhere
."
},"checkForUnderstanding":[
{"
@@ -375,96 +361,115 @@ Why
did
the
Romans
- decide
- to
leave
Britain
?
","answers":["
Due
to
- internal
- and
- external
pressures
+ on
+ their
+ empire
"],"distractors":["
They
were
defeated
by
- Brit
-ons
+ the
+ British
","
They
- found
+ wanted
+ to
+ explore
new
lands
"]},{"
question":"
What
was
- a
- major
- factor
- in
the
Roman
- departure
- from
- Britain
+ Empire
+ facing
+ around
+ AD
+
+410
?
","answers":["
-Resource
- needs
- elsewhere
+Threat
+s
+ from
+ various
+ groups
"],"distractors":["
-British
- rebellion
+A
+ time
+ of
+ peace
","
-New
- Roman
- emperor
+Rapid
+ expansion
"]}],"practice":"
List
- two
+ three
reasons
why
the
Romans
- left
+ decided
+ to
+ leave
Britain
- and
- explain
- how
- these
- reasons
- impacted
- their
- empire
-.","
+.
+ Write
+ a
+ sentence
+ for
+ each
+ reason
+.","
feedback":"
Model
answer
:
+
+1
+.
The
- Romans
- left
- due
- to
- internal
- conflicts
- and
- external
+ Roman
+ Empire
+ was
+ facing
threats
+ from
+ various
+ groups
.
- These
- weakened
- their
- control
-,
- requiring
- resources
- elsewhere
+
+2
+.
+ The
+ empire
+ was
+ struggling
+ to
+ defend
+ its
+ territories
+.
+
+3
+.
+ Tro
+ops
+ were
+ needed
+ to
+ defend
+ Rome
."
}},"status":"
complete
@@ -472,20 +477,23 @@ complete
type":"
patch
","reasoning":"
-Created
+Structured
the
second
learning
cycle
to
- describe
+ help
+ pupils
+ identify
changes
in
Britain
- post
--R
-om
-ans
+ immediately
+ after
+ the
+ Romans
+ left
.","
value":{"
type":"
@@ -497,95 +505,92 @@ cycle
2
","value":{"
title":"
-Changes
+Immediate
+ Changes
in
- Post
--R
-oman
Britain
","durationInMinutes":15
,"explanation":{"
spokenExplanation":["
-Explain
- how
- the
- departure
- of
- Romans
- led
- to
- power
- vac
-u
-ums
+Discuss
+ what
+ happened
in
Britain
-.","
-Discuss
- the
- arrival
- of
+ after
the
- Sax
-ons
- and
- other
- groups
- invading
- Britain
+ Romans
+ left
.","
-Describe
+Explain
the
+ immediate
changes
in
- town
- structures
- and
+ infrastructure
+,
+ like
the
decline
- of
+ in
Roman
--built
- infrastructure
+-style
+ houses
.","
-Highlight
+Describe
the
- blend
- of
+ shift
+ from
+ using
Roman
- and
- new
- cultural
- influences
- in
- Britain
+ coins
+ to
+ bar
+tering
.","
-Show
- examples
+Introduce
+ the
+ concept
of
+ local
+ trade
+ replacing
Roman
- architecture
- that
- remained
- influential
+ economic
+ systems
+.","
+Highlight
+ initial
+ invas
+ions
+ by
+ other
+ groups
+ such
+ as
+ the
+ Sax
+ons
."
],"accompanyingSlideDetails":"
Images
- showing
+ of
Roman
- roads
and
Sax
on
+ arte
+facts
+ and
settlements
.","
imagePrompt":"
Roman
- roads
- and
+ to
Sax
on
- settlements
+ Britain
+ transition
","slideText":"
After
the
@@ -593,16 +598,20 @@ After
left
,
Britain
+ saw
+ changes
+ in
+ infrastructure
+,
+ economy
+,
+ and
faced
invas
ions
- and
- cultural
- changes
- with
- enduring
- Roman
- influences
+ by
+ new
+ groups
."
},"checkForUnderstanding":[
{"
@@ -610,93 +619,101 @@ question":"
What
happened
to
- Britain
+ Roman
+-style
+ houses
after
- the
- Romans
+ they
left
?
","answers":["
-It
- faced
- invas
-ions
- from
- other
- groups
+They
+ declined
"],"distractors":["
-It
- became
- a
- Roman
- province
+They
+ were
+ improved
","
-It
- remained
- peaceful
+They
+ stayed
+ the
+ same
"]},{"
question":"
-Which
- group
- invaded
- Britain
+What
+ economic
+ change
+ occurred
after
the
Romans
+ left
?
","answers":["
-The
- Sax
-ons
+Shift
+ to
+ bar
+tering
"],"distractors":["
-The
- Greeks
+In
+creased
+ use
+ of
+ Roman
+ coins
","
-The
- Norm
-ans
+Introduction
+ of
+ new
+ currency
"]}],"practice":"
-Draw
- a
- picture
- showing
- a
- Roman
- road
+Sort
+ the
+ following
+ changes
+ into
+ correct
+ categories
+:
+ infrastructure
+,
+ economy
+,
+ invas
+ions
.
- Label
- it
- and
- describe
- its
- importance
- in
- post
--R
-oman
- Britain
+ Use
+ the
+ provided
+ list
+ of
+ changes
.","
feedback":"
Model
answer
:
+ Infrastructure
+ -
+ decline
+ of
Roman
- roads
- remained
- important
- for
- trade
- and
- travel
- in
- post
--R
-oman
- Britain
-,
- influencing
- settlement
- patterns
+ houses
+;
+ Economy
+ -
+ shift
+ to
+ bar
+tering
+;
+ In
+vas
+ions
+ -
+ by
+ Sax
+ons
."
}},"status":"
complete
@@ -704,19 +721,27 @@ complete
type":"
patch
","reasoning":"
-Form
-ulated
+Created
the
third
learning
cycle
+ to
+ explore
+ how
+ life
+ in
+ Britain
+ evolved
+ after
+ the
+ Romans
+,
focusing
on
- archaeological
- discoveries
- of
- Roman
- Britain
+ new
+ cultural
+ influences
.","
value":{"
type":"
@@ -728,190 +753,184 @@ cycle
3
","value":{"
title":"
-Ar
-chae
-ologists
- and
- Roman
+Life
+ in
Britain
+ After
+ the
+ Romans
","durationInMinutes":15
,"explanation":{"
spokenExplanation":["
-Define
+Discuss
+ how
+ life
+ evolved
+ in
+ Britain
+ post
+-R
+oman
+ departure
+.","
+Describe
the
- role
+ settlement
of
- archae
-ologists
- in
- studying
- history
+ new
+ groups
+ like
+ the
+ Sax
+ons
.","
Explain
- how
- archae
-ologists
- uncover
- Roman
- artifacts
- through
- excav
-ations
-.","
-Discuss
the
- types
+ blending
of
- artifacts
- commonly
- found
- from
Roman
- Britain
+ and
+ new
+ cultures
.","
-Describe
- how
- these
- discoveries
- help
- us
- understand
+Mention
+ the
+ continuation
+ of
+ some
Roman
- life
+ traditions
and
- influence
+ infrastructure
.","
-Mention
- key
- archaeological
- sites
- in
- Britain
- linked
- to
+Highlight
the
- Romans
+ development
+ of
+ local
+ governance
+ and
+ social
+ structures
."
],"accompanyingSlideDetails":"
-Images
- of
+A
+ map
+ showing
+ Sax
+on
+ settlements
+ over
+laid
+ on
Roman
- artifacts
- and
- archaeological
- sites
- in
- Britain
+ roads
.","
imagePrompt":"
-Roman
- artifacts
- from
+S
+axon
+ settlements
+ in
Britain
","slideText":"
-Ar
-chae
-ologists
- uncover
- Roman
- history
- through
- excav
-ations
-,
- revealing
- insights
- into
- life
+Life
in
- Roman
Britain
+ evolved
+ with
+ new
+ groups
+ settling
+,
+ blending
+ cultures
+,
+ and
+ developing
+ local
+ governance
."
},"checkForUnderstanding":[
{"
question":"
-What
- do
- archae
-ologists
- do
+Who
+ settled
+ in
+ Britain
+ after
+ the
+ Romans
+ left
?
","answers":["
-Study
- history
- through
- excav
-ations
+The
+ Sax
+ons
"],"distractors":["
-Write
- history
- books
+The
+ Romans
","
-Teach
- in
- schools
+The
+ Vikings
"]},{"
question":"
-Why
- are
+What
+ continued
+ in
+ Britain
+ despite
Roman
- artifacts
- important
+ departure
?
","answers":["
-They
- help
- us
- understand
+Some
Roman
- life
+ traditions
"],"distractors":["
-They
- are
- decorative
+Roman
+ rule
","
-They
- are
- made
- of
- gold
+Roman
+ military
+ presence
"]}],"practice":"
-Match
- pictures
+Write
+ a
+ short
+ paragraph
+ describing
+ how
+ Sax
+on
+ culture
+ influenced
+ Britain
+.
+ Include
+ examples
of
- Roman
- artifacts
- with
- their
- descriptions
- and
- explain
- their
- significance
- in
- Roman
- history
+ cultural
+ blending
.","
feedback":"
-Model
- answer
+Success
+ criteria
:
- Roman
- coins
+ Include
+ Sax
+on
+ settlements
,
- pottery
+ blending
+ of
+ cultures
,
and
- tools
- reveal
- daily
- life
- and
- trade
- practices
- in
+ examples
+ of
+ continued
Roman
- Britain
+ traditions
."
}},"status":"
complete
@@ -919,7 +938,8 @@ complete
type":"
patch
","reasoning":"
-Designed
+Develop
+ed
an
exit
quiz
@@ -931,9 +951,13 @@ Designed
of
the
lesson
-'s
- key
- concepts
+ content
+ regarding
+ the
+ end
+ of
+ Roman
+ Britain
.","
value":{"
type":"
@@ -954,57 +978,73 @@ When
Britain
?
","answers":["
-Around
- AD
+AD
410
"],"distractors":["
-Around
- AD
+AD
-300
+43
","
-Around
- AD
+AD
-500
+106
+6
"]},{"
question":"
What
- was
- one
- reason
- for
- the
+ happened
+ to
Roman
- departure
+-style
+ houses
+ after
+ the
+ Romans
+ left
?
","answers":["
-Internal
- empire
- pressures
+They
+ declined
"],"distractors":["
-Def
-eat
- by
- Brit
-ons
+They
+ improved
","
-L
-ack
- of
- interest
+They
+ were
+ unchanged
+"]},{"
+question":"
+What
+ replaced
+ Roman
+ coins
in
- Britain
+ the
+ British
+ economy
+?
+","answers":["
+Bar
+tering
+"],"distractors":["
+New
+ currency
+","
+Gold
+ coins
"]},{"
question":"
-Who
- invaded
+Which
+ group
+ began
+ to
+ settle
+ in
Britain
after
the
Romans
- left
?
","answers":["
The
@@ -1012,105 +1052,64 @@ The
ons
"],"distractors":["
The
- Norm
-ans
+ Vikings
","
The
- Vikings
+ Cel
+ts
"]},{"
question":"
What
- did
- archae
-ologists
- find
- in
- Roman
+ was
+ one
+ reason
+ the
+ Romans
+ left
Britain
?
","answers":["
-Artifacts
- like
- coins
- and
- pottery
-"],"distractors":["
-Modern
- buildings
-","
-Anc
-ient
- books
-"]},{"
-question":"
-Why
- are
- Roman
- roads
- significant
-?
-","answers":["
-They
- influenced
- travel
- and
- trade
+Press
+ures
+ on
+ their
+ empire
"],"distractors":["
-They
- were
- all
- destroyed
+To
+ explore
+ new
+ lands
","
-They
- were
- only
- decorative
+Def
+eat
+ by
+ the
+ British
"]},{"
question":"
What
- role
- do
- archae
-ologists
- play
+ continued
in
- history
+ Britain
+ despite
+ the
+ Roman
+ departure
?
","answers":["
-They
- uncover
- past
- through
- excav
-ations
+Some
+ Roman
+ traditions
"],"distractors":["
-They
- build
- new
- sites
+Roman
+ army
+ presence
","
-They
- rule
- ancient
- lands
+Roman
+ government
"]}]},"status":"
complete
-"}],"sectionsEdited":["
-starter
-Quiz
-","
-cycle
-1
-","
-cycle
-2
-","
-cycle
-3
-","
-exit
-Quiz
-"],"prompt":{"
+"}],"prompt":{"
type":"
text
","value":"
@@ -1129,7 +1128,7 @@ Are
suitable
for
your
- class
+ pupils
?
If
not
@@ -1155,6 +1154,4 @@ Continue
next
step
."
-},"status":"
-complete
-"}
\ No newline at end of file
+}}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-3.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-3.formatted.json
index 82d9720d8..57c6abfc2 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-3.formatted.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-3.formatted.json
@@ -1,80 +1,47 @@
{
"type": "llmMessage",
- "sectionsToEdit": [
- "starterQuiz",
- "cycle1",
- "cycle2",
- "cycle3",
- "exitQuiz"
- ],
+ "sectionsToEdit": ["starterQuiz", "cycle1", "cycle2", "cycle3", "exitQuiz"],
"patches": [
{
"type": "patch",
- "reasoning": "Designed a starter quiz to assess pupils' prior knowledge on Roman Britain before the main lesson content.",
+ "reasoning": "Created a starter quiz to assess pupils' prior knowledge before introducing new content about the end of Roman Britain.",
"value": {
"type": "quiz",
"op": "add",
"path": "/starterQuiz",
"value": [
{
- "question": "What did the Romans build in Britain during their rule?",
- "answers": [
- "Roads and towns"
- ],
- "distractors": [
- "Castles and forts",
- "Schools and hospitals"
- ]
+ "question": "When did the Romans invade Britain?",
+ "answers": ["AD 43"],
+ "distractors": ["AD 410", "AD 1066"]
},
{
- "question": "How long did the Romans rule over Britain?",
- "answers": [
- "Several centuries"
- ],
- "distractors": [
- "A few years",
- "A decade"
- ]
+ "question": "How long was Britain part of the Roman Empire?",
+ "answers": ["Nearly 400 years"],
+ "distractors": ["200 years", "600 years"]
},
{
- "question": "What is an empire?",
- "answers": [
- "A large group of territories ruled by one authority"
- ],
- "distractors": [
- "A small country",
- "A type of government"
- ]
+ "question": "What did the Romans build in Britain?",
+ "answers": ["Roads, towns, and walls"],
+ "distractors": ["Castles and palaces", "Skyscrapers"]
},
{
- "question": "What role do archaeologists play in history?",
- "answers": [
- "They study human history by digging up ancient sites"
- ],
- "distractors": [
- "They write history books",
- "They teach history in schools"
- ]
+ "question": "What aspect of life did Roman culture influence in Britain?",
+ "answers": ["Buildings and language"],
+ "distractors": ["Clothing and food", "Music and dance"]
},
{
- "question": "Which empire did Britain belong to during Roman rule?",
- "answers": [
- "The Roman Empire"
- ],
+ "question": "What was the Roman army known for?",
+ "answers": ["Being powerful and well-organised"],
"distractors": [
- "The Greek Empire",
- "The Egyptian Empire"
+ "Being small and disorganised",
+ "Being peaceful and passive"
]
},
{
- "question": "What is one thing pupils should understand before this lesson?",
- "answers": [
- "The concept of an empire"
- ],
- "distractors": [
- "The history of the Saxons",
- "The fall of the Roman Empire"
- ]
+ "question": "What year did the Romans leave Britain?",
+ "answers": ["AD 410"],
+ "distractors": ["AD 43", "AD 1066"]
}
]
},
@@ -82,7 +49,7 @@
},
{
"type": "patch",
- "reasoning": "Developed the first learning cycle focusing on explaining why the Romans left Britain.",
+ "reasoning": "Structured the first learning cycle to introduce why the Romans left Britain and establish a foundation for understanding.",
"value": {
"type": "cycle",
"op": "add",
@@ -92,147 +59,123 @@
"durationInMinutes": 15,
"explanation": {
"spokenExplanation": [
- "Discuss the pressures faced by the Roman Empire around AD 410.",
- "Explain how internal conflicts weakened the Roman control over distant regions like Britain.",
- "Describe the external threats from other tribes and groups that required Roman attention elsewhere.",
- "Mention how resources and troops were needed more urgently in other parts of the empire.",
- "Highlight that the decision to leave was strategic, not due to defeat by Britons."
+ "Discuss the pressures on the Roman Empire around AD 410.",
+ "Explain that the Roman Empire was facing threats from various groups outside Britain.",
+ "Mention that the Roman Empire was struggling to defend its vast territories.",
+ "Describe how the decision was made to withdraw troops from Britain to focus on defending Rome.",
+ "Connect this to the eventual departure of the Romans from Britain."
],
- "accompanyingSlideDetails": "A timeline showing key events leading to the Roman departure from Britain.",
- "imagePrompt": "Roman Empire timeline AD 410",
- "slideText": "The Romans left Britain around AD 410 due to internal and external pressures on their empire."
+ "accompanyingSlideDetails": "A timeline showing key events leading to the Roman withdrawal from Britain.",
+ "imagePrompt": "Roman Empire decline map",
+ "slideText": "The Romans left Britain in AD 410 due to pressures on their empire, including threats elsewhere."
},
"checkForUnderstanding": [
{
- "question": "Why did the Romans decide to leave Britain?",
- "answers": [
- "Due to internal and external pressures"
- ],
+ "question": "Why did the Romans leave Britain?",
+ "answers": ["Due to pressures on their empire"],
"distractors": [
- "They were defeated by Britons",
- "They found new lands"
+ "They were defeated by the British",
+ "They wanted to explore new lands"
]
},
{
- "question": "What was a major factor in the Roman departure from Britain?",
- "answers": [
- "Resource needs elsewhere"
- ],
- "distractors": [
- "British rebellion",
- "New Roman emperor"
- ]
+ "question": "What was the Roman Empire facing around AD 410?",
+ "answers": ["Threats from various groups"],
+ "distractors": ["A time of peace", "Rapid expansion"]
}
],
- "practice": "List two reasons why the Romans left Britain and explain how these reasons impacted their empire.",
- "feedback": "Model answer: The Romans left due to internal conflicts and external threats. These weakened their control, requiring resources elsewhere."
+ "practice": "List three reasons why the Romans decided to leave Britain. Write a sentence for each reason.",
+ "feedback": "Model answer: 1. The Roman Empire was facing threats from various groups. 2. The empire was struggling to defend its territories. 3. Troops were needed to defend Rome."
}
},
"status": "complete"
},
{
"type": "patch",
- "reasoning": "Created the second learning cycle to describe changes in Britain post-Romans.",
+ "reasoning": "Structured the second learning cycle to help pupils identify changes in Britain immediately after the Romans left.",
"value": {
"type": "cycle",
"op": "add",
"path": "/cycle2",
"value": {
- "title": "Changes in Post-Roman Britain",
+ "title": "Immediate Changes in Britain",
"durationInMinutes": 15,
"explanation": {
"spokenExplanation": [
- "Explain how the departure of Romans led to power vacuums in Britain.",
- "Discuss the arrival of the Saxons and other groups invading Britain.",
- "Describe the changes in town structures and the decline of Roman-built infrastructure.",
- "Highlight the blend of Roman and new cultural influences in Britain.",
- "Show examples of Roman architecture that remained influential."
+ "Discuss what happened in Britain after the Romans left.",
+ "Explain the immediate changes in infrastructure, like the decline in Roman-style houses.",
+ "Describe the shift from using Roman coins to bartering.",
+ "Introduce the concept of local trade replacing Roman economic systems.",
+ "Highlight initial invasions by other groups such as the Saxons."
],
- "accompanyingSlideDetails": "Images showing Roman roads and Saxon settlements.",
- "imagePrompt": "Roman roads and Saxon settlements",
- "slideText": "After the Romans left, Britain faced invasions and cultural changes with enduring Roman influences."
+ "accompanyingSlideDetails": "Images of Roman and Saxon artefacts and settlements.",
+ "imagePrompt": "Roman to Saxon Britain transition",
+ "slideText": "After the Romans left, Britain saw changes in infrastructure, economy, and faced invasions by new groups."
},
"checkForUnderstanding": [
{
- "question": "What happened to Britain after the Romans left?",
- "answers": [
- "It faced invasions from other groups"
- ],
- "distractors": [
- "It became a Roman province",
- "It remained peaceful"
- ]
+ "question": "What happened to Roman-style houses after they left?",
+ "answers": ["They declined"],
+ "distractors": ["They were improved", "They stayed the same"]
},
{
- "question": "Which group invaded Britain after the Romans?",
- "answers": [
- "The Saxons"
- ],
+ "question": "What economic change occurred after the Romans left?",
+ "answers": ["Shift to bartering"],
"distractors": [
- "The Greeks",
- "The Normans"
+ "Increased use of Roman coins",
+ "Introduction of new currency"
]
}
],
- "practice": "Draw a picture showing a Roman road. Label it and describe its importance in post-Roman Britain.",
- "feedback": "Model answer: Roman roads remained important for trade and travel in post-Roman Britain, influencing settlement patterns."
+ "practice": "Sort the following changes into correct categories: infrastructure, economy, invasions. Use the provided list of changes.",
+ "feedback": "Model answer: Infrastructure - decline of Roman houses; Economy - shift to bartering; Invasions - by Saxons."
}
},
"status": "complete"
},
{
"type": "patch",
- "reasoning": "Formulated the third learning cycle focusing on archaeological discoveries of Roman Britain.",
+ "reasoning": "Created the third learning cycle to explore how life in Britain evolved after the Romans, focusing on new cultural influences.",
"value": {
"type": "cycle",
"op": "add",
"path": "/cycle3",
"value": {
- "title": "Archaeologists and Roman Britain",
+ "title": "Life in Britain After the Romans",
"durationInMinutes": 15,
"explanation": {
"spokenExplanation": [
- "Define the role of archaeologists in studying history.",
- "Explain how archaeologists uncover Roman artifacts through excavations.",
- "Discuss the types of artifacts commonly found from Roman Britain.",
- "Describe how these discoveries help us understand Roman life and influence.",
- "Mention key archaeological sites in Britain linked to the Romans."
+ "Discuss how life evolved in Britain post-Roman departure.",
+ "Describe the settlement of new groups like the Saxons.",
+ "Explain the blending of Roman and new cultures.",
+ "Mention the continuation of some Roman traditions and infrastructure.",
+ "Highlight the development of local governance and social structures."
],
- "accompanyingSlideDetails": "Images of Roman artifacts and archaeological sites in Britain.",
- "imagePrompt": "Roman artifacts from Britain",
- "slideText": "Archaeologists uncover Roman history through excavations, revealing insights into life in Roman Britain."
+ "accompanyingSlideDetails": "A map showing Saxon settlements overlaid on Roman roads.",
+ "imagePrompt": "Saxon settlements in Britain",
+ "slideText": "Life in Britain evolved with new groups settling, blending cultures, and developing local governance."
},
"checkForUnderstanding": [
{
- "question": "What do archaeologists do?",
- "answers": [
- "Study history through excavations"
- ],
- "distractors": [
- "Write history books",
- "Teach in schools"
- ]
+ "question": "Who settled in Britain after the Romans left?",
+ "answers": ["The Saxons"],
+ "distractors": ["The Romans", "The Vikings"]
},
{
- "question": "Why are Roman artifacts important?",
- "answers": [
- "They help us understand Roman life"
- ],
- "distractors": [
- "They are decorative",
- "They are made of gold"
- ]
+ "question": "What continued in Britain despite Roman departure?",
+ "answers": ["Some Roman traditions"],
+ "distractors": ["Roman rule", "Roman military presence"]
}
],
- "practice": "Match pictures of Roman artifacts with their descriptions and explain their significance in Roman history.",
- "feedback": "Model answer: Roman coins, pottery, and tools reveal daily life and trade practices in Roman Britain."
+ "practice": "Write a short paragraph describing how Saxon culture influenced Britain. Include examples of cultural blending.",
+ "feedback": "Success criteria: Include Saxon settlements, blending of cultures, and examples of continued Roman traditions."
}
},
"status": "complete"
},
{
"type": "patch",
- "reasoning": "Designed an exit quiz to assess pupils' understanding of the lesson's key concepts.",
+ "reasoning": "Developed an exit quiz to assess pupils' understanding of the lesson content regarding the end of Roman Britain.",
"value": {
"type": "quiz",
"op": "add",
@@ -240,79 +183,42 @@
"value": [
{
"question": "When did the Romans leave Britain?",
- "answers": [
- "Around AD 410"
- ],
- "distractors": [
- "Around AD 300",
- "Around AD 500"
- ]
+ "answers": ["AD 410"],
+ "distractors": ["AD 43", "AD 1066"]
},
{
- "question": "What was one reason for the Roman departure?",
- "answers": [
- "Internal empire pressures"
- ],
- "distractors": [
- "Defeat by Britons",
- "Lack of interest in Britain"
- ]
+ "question": "What happened to Roman-style houses after the Romans left?",
+ "answers": ["They declined"],
+ "distractors": ["They improved", "They were unchanged"]
},
{
- "question": "Who invaded Britain after the Romans left?",
- "answers": [
- "The Saxons"
- ],
- "distractors": [
- "The Normans",
- "The Vikings"
- ]
+ "question": "What replaced Roman coins in the British economy?",
+ "answers": ["Bartering"],
+ "distractors": ["New currency", "Gold coins"]
},
{
- "question": "What did archaeologists find in Roman Britain?",
- "answers": [
- "Artifacts like coins and pottery"
- ],
- "distractors": [
- "Modern buildings",
- "Ancient books"
- ]
+ "question": "Which group began to settle in Britain after the Romans?",
+ "answers": ["The Saxons"],
+ "distractors": ["The Vikings", "The Celts"]
},
{
- "question": "Why are Roman roads significant?",
- "answers": [
- "They influenced travel and trade"
- ],
- "distractors": [
- "They were all destroyed",
- "They were only decorative"
- ]
+ "question": "What was one reason the Romans left Britain?",
+ "answers": ["Pressures on their empire"],
+ "distractors": ["To explore new lands", "Defeat by the British"]
},
{
- "question": "What role do archaeologists play in history?",
- "answers": [
- "They uncover past through excavations"
- ],
- "distractors": [
- "They build new sites",
- "They rule ancient lands"
- ]
+ "question": "What continued in Britain despite the Roman departure?",
+ "answers": ["Some Roman traditions"],
+ "distractors": ["Roman army presence", "Roman government"]
}
]
},
"status": "complete"
}
],
- "sectionsEdited": [
- "starterQuiz",
- "cycle1",
- "cycle2",
- "cycle3",
- "exitQuiz"
- ],
+ "sectionsEdited": ["starterQuiz", "cycle1", "cycle2", "cycle3", "exitQuiz"],
"prompt": {
"type": "text",
- "value": "Are the starter quiz, learning cycles, and exit quiz sections suitable for your class? If not, reply with what I should change. Otherwise, tap **Continue** to move on to the next step."
- },
- "status": "complete"
-}
\ No newline at end of file
+ "value": "Are the starter quiz, learning cycles, and exit quiz sections suitable for your pupils? If not, reply with what I should change. Otherwise, tap **Continue** to move on to the next step."
+ }
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-3.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-3.moderation.json
index 33a48873c..5b2f3a9d9 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-3.moderation.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-3.moderation.json
@@ -1,14 +1,14 @@
{
- "id": "chatcmpl-ANdXfnfoZyYbX8821gnToLzVG2k6N",
+ "id": "chatcmpl-AKmkPA33j9Ni3m1GNjMioxsf91mMR",
"object": "chat.completion",
- "created": 1730196907,
+ "created": 1729517309,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
- "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan titled 'End of Roman Britain' is fully compliant across all category groups for key-stage 1 history. It does not contain any discriminatory language, offensive content, or strong language. The content does not depict or discuss conflict, violence, or sensitive subjects, and there is no mention of nudity or sexual content. Physical activities, if any, are not hazardous or require special supervision. Furthermore, there are no guides or encouragements for harmful or illegal behavior. The content is appropriate for young learners, focusing on historical events and archaeological studies related to Roman Britain, presented in an educational and age-appropriate manner.\",\"categories\":[]}",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan is fully compliant across all categories. It focuses on historical events related to the end of Roman Britain, suitable for key-stage-1 students. There is no discriminatory, offensive, or strong language. The content does not depict violence, crime, or sensitive topics. It avoids any nudity or sexual content, and there are no physical activities or safety concerns. Furthermore, it does not include any toxic or harmful instructions or encouragements. The lesson plan is educational, age-appropriate, and presented in a sensitive manner.\",\"categories\":[]}",
"refusal": null
},
"logprobs": null,
@@ -16,9 +16,9 @@
}
],
"usage": {
- "prompt_tokens": 3796,
- "completion_tokens": 158,
- "total_tokens": 3954,
+ "prompt_tokens": 3805,
+ "completion_tokens": 139,
+ "total_tokens": 3944,
"prompt_tokens_details": {
"cached_tokens": 2432
},
@@ -26,5 +26,5 @@
"reasoning_tokens": 0
}
},
- "system_fingerprint": "fp_90354628f2"
-}
\ No newline at end of file
+ "system_fingerprint": "fp_a7d06e42a7"
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-4.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-4.chunks.txt
index 0a04db3ce..2fc018cb8 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-4.chunks.txt
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-4.chunks.txt
@@ -11,27 +11,34 @@ Materials
type":"
patch
","reasoning":"
-Providing
- additional
- materials
- in
- the
- form
- of
+Provided
a
narrative
- script
to
support
the
teacher
in
delivering
- complex
- topics
- about
+ the
+ lesson
+ on
+ the
+ end
+ of
Roman
Britain
+,
+ which
+ includes
+ key
+ points
+ and
+ suggestions
+ for
+ explaining
+ the
+ content
.","
value":{"
type":"
@@ -44,65 +51,70 @@ Materials
","value":"
##
Narrative
- Script
for
Teachers
\n
\n
+###
+ Introduction
+ to
+ the
+ End
+ of
+ Roman
+ Britain
+\n
+\n
\"
-Today
+Good
+ morning
+,
+ class
+!
+ Today
,
we're
going
to
- travel
- back
+ learn
+ about
+ what
+ happened
in
- time
- to
- when
+ Britain
+ after
the
Romans
- were
- in
- Britain
+ left
.
Imagine
you
are
a
- Roman
- soldier
-,
- wearing
- your
- armour
- and
- sandals
+ detective
+ pie
+cing
+ together
+ the
+ past
+ from
+ clues
+ left
+ behind
+.\
+n
+\n
+First
,
- walking
+ let's
+ think
+ about
+ why
the
- long
- roads
- they
- built
-.
- These
- roads
- were
- very
- important
- because
- they
- connected
- towns
- and
- made
- travel
- easier
+ Romans
+ left
.
- But
- around
+ Around
AD
410
@@ -112,157 +124,232 @@ Today
Empire
was
facing
- big
+ many
problems
.
- They
- needed
- their
- soldiers
- back
- home
+ It
+ was
+ like
+ trying
to
- help
- fight
- battles
- elsewhere
-.
- So
-,
- they
- decided
+ keep
+ a
+ big
+ sand
+castle
+ from
+ being
+ washed
+ away
+ by
+ the
+ tide
+!
+ The
+ Romans
+ had
+ to
+ make
+ a
+ tough
+ decision
to
leave
Britain
+ and
+ protect
+ other
+ parts
+ of
+ their
+ empire
+.
+ They
+ were
+ facing
+ threats
+ from
+ other
+ groups
+,
+ and
+ their
+ empire
+ was
+ just
+ too
+ big
+ to
+ defend
+ everywhere
+ at
+ once
.\
n
\n
Now
,
- picture
- the
- changes
- in
- Britain
+ let's
+ explore
+ what
+ happened
when
the
Romans
left
.
- New
+ Without
+ Roman
+ soldiers
+ to
+ protect
+ them
+,
+ the
+ people
+ in
+ Britain
+ had
+ to
+ defend
+ themselves
+.
+ You
+ might
+ imagine
+ them
+ like
+ a
+ team
+ suddenly
+ playing
+ without
+ their
+ star
+ player
+!
+ They
+ faced
+ invas
+ions
+ from
groups
like
the
Sax
ons
- came
- and
- started
+,
+ who
+ began
to
- live
- here
-.
+ settle
+ in
+ Britain
+.\
+n
+\n
+How
+ did
+ life
+ change
+?
The
Roman
- buildings
- slowly
- changed
- or
- disappeared
-,
- but
- some
- things
-,
- like
- roads
+-style
+ houses
and
- towns
+ roads
+ were
+ not
+ kept
+ up
+ as
+ well
+ as
+ before
,
- stayed
and
- influenced
- how
people
- lived
-.\
-n
-\n
-Ar
-chae
-ologists
- are
- like
- detectives
-.
- They
- dig
- up
- old
+ began
+ to
+ use
+ bar
+tering
+ to
+ trade
+ goods
+ instead
+ of
Roman
coins
-,
- pottery
-,
- and
- tools
+.
+ It's
+ like
+ going
+ back
to
- learn
+ using
+ mar
+bles
+ to
+ trade
+ for
+ sweets
+ instead
+ of
+ using
+ money
+!\
+n
+\n
+Finally
+,
+ let's
+ think
about
how
- people
- lived
- back
- then
+ life
+ evolved
.
- These
- discoveries
- tell
- us
- exciting
- stories
- about
- the
- past
-,
- like
- what
+ Even
+ though
the
Romans
- ate
-,
- the
- clothes
- they
- wore
+ left
,
+ some
+ of
+ their
+ traditions
and
- the
- games
- they
- played
-.\
-n
-\n
-Remember
+ roads
+ remained
+.
+ New
+ groups
+ brought
+ their
+ cultures
,
- history
- is
+ mixing
+ them
+ with
+ Roman
+ ways
+.
+ It's
+ like
+ creating
a
- puzzle
-,
+ new
+ recipe
+ by
+ mixing
+ old
and
- each
- piece
- helps
- us
- understand
- more
- about
- our
- world
- today
-.
+ new
+ ingredients
+!
\"\
n
\n
@@ -273,109 +360,116 @@ n
Explanation
\n
-
- Importance
- of
+ Discuss
+ the
+ pressures
+ on
+ the
Roman
- roads
- and
- infrastructure
+ Empire
.\
n
-
- Reasons
- for
- Roman
- departure
- due
- to
- empire
- pressures
+ Describe
+ the
+ immediate
+ changes
+ after
+ the
+ Romans
+ left
+,
+ including
+ infrastructure
+ and
+ economy
.\
n
-
- Post
--R
-oman
- changes
- and
+ Highlight
+ the
+ arrival
+ of
+ new
+ groups
+ like
+ the
Sax
-on
- invas
-ions
+ons
.\
n
-
- Role
+ Explain
+ the
+ blending
of
- archae
-ologists
+ Roman
+ and
+ new
+ cultures
in
- uncover
-ing
- history
+ Britain
.\
n
\n
-Search
- terms
- for
- images
-:
+###
+ Image
+ Search
+ Suggestions
+\n
+-
\"
Roman
- soldier
- armour
-\",
+ Empire
+ decline
+ map
+\"\
+n
+-
\"
Roman
- roads
-\",
+ to
+ Sax
+on
+ Britain
+ transition
+\"\
+n
+-
\"
S
axon
settlements
-\",
- \"
-Roman
- artifacts
+ in
+ Britain
\"
-."
-},"status":"
+"},"status":"
complete
-"}],"sectionsEdited":["
-additional
-Materials
-"],"prompt":{"
+"}],"prompt":{"
type":"
text
","value":"
-I
- have
- added
- a
- narrative
- script
- to
- support
- the
- lesson
- delivery
-.
- Are
+Is
the
additional
materials
- appropriate
+ section
+ suitable
for
your
- pupils
+ lesson
+ delivery
?
If
not
,
- suggest
- an
- edit
+ let
+ me
+ know
+ what
+ changes
+ to
+ make
.
Otherwise
,
@@ -384,11 +478,10 @@ I
Continue
**
to
- complete
+ final
+ise
the
lesson
plan
."
-},"status":"
-complete
-"}
\ No newline at end of file
+}}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-4.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-4.formatted.json
index f584fab37..1eae739c1 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-4.formatted.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-4.formatted.json
@@ -1,27 +1,22 @@
{
"type": "llmMessage",
- "sectionsToEdit": [
- "additionalMaterials"
- ],
+ "sectionsToEdit": ["additionalMaterials"],
"patches": [
{
"type": "patch",
- "reasoning": "Providing additional materials in the form of a narrative script to support the teacher in delivering complex topics about Roman Britain.",
+ "reasoning": "Provided a narrative to support the teacher in delivering the lesson on the end of Roman Britain, which includes key points and suggestions for explaining the content.",
"value": {
"type": "string",
"op": "add",
"path": "/additionalMaterials",
- "value": "## Narrative Script for Teachers\n\n\"Today, we're going to travel back in time to when the Romans were in Britain. Imagine you are a Roman soldier, wearing your armour and sandals, walking the long roads they built. These roads were very important because they connected towns and made travel easier. But around AD 410, the Roman Empire was facing big problems. They needed their soldiers back home to help fight battles elsewhere. So, they decided to leave Britain.\n\nNow, picture the changes in Britain when the Romans left. New groups like the Saxons came and started to live here. The Roman buildings slowly changed or disappeared, but some things, like roads and towns, stayed and influenced how people lived.\n\nArchaeologists are like detectives. They dig up old Roman coins, pottery, and tools to learn about how people lived back then. These discoveries tell us exciting stories about the past, like what the Romans ate, the clothes they wore, and the games they played.\n\nRemember, history is a puzzle, and each piece helps us understand more about our world today.\"\n\n### Key Points for Explanation\n- Importance of Roman roads and infrastructure.\n- Reasons for Roman departure due to empire pressures.\n- Post-Roman changes and Saxon invasions.\n- Role of archaeologists in uncovering history.\n\nSearch terms for images: \"Roman soldier armour\", \"Roman roads\", \"Saxon settlements\", \"Roman artifacts\"."
+ "value": "## Narrative for Teachers\n\n### Introduction to the End of Roman Britain\n\n\"Good morning, class! Today, we're going to learn about what happened in Britain after the Romans left. Imagine you are a detective piecing together the past from clues left behind.\n\nFirst, let's think about why the Romans left. Around AD 410, the Roman Empire was facing many problems. It was like trying to keep a big sandcastle from being washed away by the tide! The Romans had to make a tough decision to leave Britain and protect other parts of their empire. They were facing threats from other groups, and their empire was just too big to defend everywhere at once.\n\nNow, let's explore what happened when the Romans left. Without Roman soldiers to protect them, the people in Britain had to defend themselves. You might imagine them like a team suddenly playing without their star player! They faced invasions from groups like the Saxons, who began to settle in Britain.\n\nHow did life change? The Roman-style houses and roads were not kept up as well as before, and people began to use bartering to trade goods instead of Roman coins. It's like going back to using marbles to trade for sweets instead of using money!\n\nFinally, let's think about how life evolved. Even though the Romans left, some of their traditions and roads remained. New groups brought their cultures, mixing them with Roman ways. It's like creating a new recipe by mixing old and new ingredients!\"\n\n### Key Points for Explanation\n- Discuss the pressures on the Roman Empire.\n- Describe the immediate changes after the Romans left, including infrastructure and economy.\n- Highlight the arrival of new groups like the Saxons.\n- Explain the blending of Roman and new cultures in Britain.\n\n### Image Search Suggestions\n- \"Roman Empire decline map\"\n- \"Roman to Saxon Britain transition\"\n- \"Saxon settlements in Britain\""
},
"status": "complete"
}
],
- "sectionsEdited": [
- "additionalMaterials"
- ],
+ "sectionsEdited": ["additionalMaterials"],
"prompt": {
"type": "text",
- "value": "I have added a narrative script to support the lesson delivery. Are the additional materials appropriate for your pupils? If not, suggest an edit. Otherwise, tap **Continue** to complete the lesson plan."
- },
- "status": "complete"
-}
\ No newline at end of file
+ "value": "Is the additional materials section suitable for your lesson delivery? If not, let me know what changes to make. Otherwise, tap **Continue** to finalise the lesson plan."
+ }
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-4.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-4.moderation.json
index fb7df491f..a2d554c95 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-4.moderation.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-4.moderation.json
@@ -1,14 +1,14 @@
{
- "id": "chatcmpl-ANdXxPFyq8YyfRXY85uI1uNrgJ0N9",
+ "id": "chatcmpl-AKmktzYTTFGvcoTG68jILIsqK92f2",
"object": "chat.completion",
- "created": 1730196925,
+ "created": 1729517339,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
- "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan for \\\"End of Roman Britain\\\" is appropriate for Key Stage 1 students, with content that is educational and age-appropriate. It focuses on historical events and changes without delving into any potentially offensive or sensitive topics. There is no discriminatory language or behavior. The lesson does not discuss or depict violence or crime, nor does it contain upsetting or sensitive content. There is no mention of nudity or sexual content. The lesson includes standard educational activities and discussions, without involving physical activities requiring safety considerations. Additionally, there is no toxic content, such as instructions or encouragement of harmful or illegal activities. Overall, the lesson is fully compliant with guidelines across all categories.\",\"categories\":[]}",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan is fully compliant across all categories. It contains no discriminatory language or behavior, no depiction or discussion of violence or crime, and no upsetting or sensitive content. The material is appropriate for Key Stage 1, focusing on historical facts about the end of Roman Britain without delving into any distressing or mature themes. There is no nudity or sexual content, and the lesson does not involve any physical activities or use of potentially hazardous materials. Additionally, there are no guides or encouragements for harmful or illegal activities, ensuring the content is safe and suitable for young learners.\",\"categories\":[]}",
"refusal": null
},
"logprobs": null,
@@ -16,9 +16,9 @@
}
],
"usage": {
- "prompt_tokens": 4098,
- "completion_tokens": 168,
- "total_tokens": 4266,
+ "prompt_tokens": 4203,
+ "completion_tokens": 149,
+ "total_tokens": 4352,
"prompt_tokens_details": {
"cached_tokens": 3584
},
@@ -26,5 +26,5 @@
"reasoning_tokens": 0
}
},
- "system_fingerprint": "fp_90354628f2"
-}
\ No newline at end of file
+ "system_fingerprint": "fp_a7d06e42a7"
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-5.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-5.chunks.txt
index c7e49eda5..374e5dfaa 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-5.chunks.txt
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-5.chunks.txt
@@ -3,9 +3,7 @@ type":"
ll
m
Message
-","sectionsToEdit":[]
-,"patches":[]
-,"sectionsEdited":[]
+","patches":[]
,"prompt":{"
type":"
text
@@ -50,6 +48,4 @@ Menu
created
lessons
."
-},"status":"
-complete
-"}
\ No newline at end of file
+}}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-5.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-5.formatted.json
index c446088cb..f837cf61e 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-5.formatted.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-5.formatted.json
@@ -1,11 +1,8 @@
{
"type": "llmMessage",
- "sectionsToEdit": [],
"patches": [],
- "sectionsEdited": [],
"prompt": {
"type": "text",
"value": "I have checked for British spelling and grammar, coherence, and accuracy. You can now share your lesson or download your resources.\n\nClick on the **Menu** button to find previously created lessons."
- },
- "status": "complete"
-}
\ No newline at end of file
+ }
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-5.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-5.moderation.json
index 221611a02..30583f26a 100644
--- a/apps/nextjs/tests-e2e/recordings/roman-britain-5.moderation.json
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-5.moderation.json
@@ -1,14 +1,14 @@
{
- "id": "chatcmpl-ANdYBeKYKlYscRigozQrSkrUxlhAQ",
+ "id": "chatcmpl-AKmlFhfKTuknIFWXYpVOpVz2wtOUo",
"object": "chat.completion",
- "created": 1730196939,
+ "created": 1729517361,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
- "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan on 'End of Roman Britain' is fully compliant across all categories. It does not contain any discriminatory language, offensive language, or strong language. There is no depiction or discussion of conflict, violence, serious violence, or sexual violence. The content is age-appropriate for Key Stage 1 and does not include any upsetting, sensitive, or distressing content. There is no depiction or discussion of nudity or sexual content. The lesson does not involve exploration of objects, use of equipment requiring supervision, imitable behaviors, external content, or physical activity that might require adult supervision. Lastly, it does not contain any toxic content such as guides or encouragements for harmful or illegal activities. The lesson focuses on historical facts in a sensitive and educational manner suitable for young learners.\",\"categories\":[]}",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan on the \\\"End of Roman Britain\\\" is fully compliant across all categories. It uses appropriate language for Key Stage 1 students, avoiding any discriminatory or offensive language. The content does not discuss or depict violence, crime, or any upsetting or sensitive topics. There is no discussion of nudity or sexual content, which aligns with the age group. The lesson involves historical exploration and discussion, which does not require any physical activity or external content that might need supervision. Lastly, the lesson does not include any toxic content or encouragement of harmful behavior.\",\"categories\":[]}",
"refusal": null
},
"logprobs": null,
@@ -16,9 +16,9 @@
}
],
"usage": {
- "prompt_tokens": 4098,
- "completion_tokens": 190,
- "total_tokens": 4288,
+ "prompt_tokens": 4203,
+ "completion_tokens": 144,
+ "total_tokens": 4347,
"prompt_tokens_details": {
"cached_tokens": 3968
},
@@ -26,5 +26,5 @@
"reasoning_tokens": 0
}
},
- "system_fingerprint": "fp_90354628f2"
-}
\ No newline at end of file
+ "system_fingerprint": "fp_a7d06e42a7"
+}
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-6.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-6.chunks.txt
new file mode 100644
index 000000000..69fd0ec8d
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-6.chunks.txt
@@ -0,0 +1,218 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[
+{"
+type":"
+patch
+","reasoning":"
+The
+ Starter
+ Quiz
+ checks
+ pupils
+'
+ prior
+ knowledge
+ to
+ ensure
+ they
+ are
+ prepared
+ for
+ the
+ new
+ lesson
+ content
+.","
+value":{"
+type":"
+quiz
+","op":"
+add
+","path":"/
+starter
+Quiz
+","value":[
+{"
+question":"
+When
+ did
+ the
+ Romans
+ invade
+ Britain
+?
+","answers":["
+AD
+
+43
+"],"distractors":["
+AD
+
+410
+","
+AD
+
+106
+6
+"]},{"
+question":"
+What
+ was
+ Roman
+ Britain
+ a
+ part
+ of
+?
+","answers":["
+The
+ Roman
+ Empire
+"],"distractors":["
+The
+ British
+ Empire
+","
+The
+ Greek
+ Empire
+"]},{"
+question":"
+What
+ did
+ the
+ Romans
+ build
+ in
+ Britain
+?
+","answers":["
+Road
+s
+ and
+ towns
+"],"distractors":["
+Cast
+les
+ and
+ cat
+hed
+r
+als
+","
+Sk
+yscr
+apers
+ and
+ bridges
+"]},{"
+question":"
+What
+ did
+ the
+ Romans
+ introduce
+ to
+ Britain
+?
+","answers":["
+New
+ technologies
+ and
+ ideas
+"],"distractors":["
+New
+ languages
+ and
+ alph
+abets
+","
+New
+ art
+ styles
+ and
+ music
+"]},{"
+question":"
+Who
+ protected
+ Britain
+ from
+ invas
+ions
+?
+","answers":["
+Roman
+ soldiers
+"],"distractors":["
+S
+axon
+ warriors
+","
+V
+iking
+ explorers
+"]},{"
+question":"
+Which
+ groups
+ invaded
+ Britain
+ after
+ the
+ Romans
+?
+","answers":["
+The
+ Sax
+ons
+"],"distractors":["
+The
+ Norm
+ans
+","
+The
+ Vikings
+"]}]},"status":"
+complete
+"}],"prompt":{"
+type":"
+text
+","value":"
+The
+ Starter
+ Quiz
+ is
+ ready
+,
+ focusing
+ on
+ the
+ prior
+ knowledge
+ needed
+ for
+ the
+ lesson
+.
+ Now
+,
+ let's
+ develop
+ the
+ learning
+ cycles
+ to
+ guide
+ the
+ main
+ content
+ of
+ the
+ lesson
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-6.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-6.formatted.json
new file mode 100644
index 000000000..4ffab1b59
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-6.formatted.json
@@ -0,0 +1,81 @@
+{
+ "type": "llmMessage",
+ "patches": [
+ {
+ "type": "patch",
+ "reasoning": "The Starter Quiz checks pupils' prior knowledge to ensure they are prepared for the new lesson content.",
+ "value": {
+ "type": "quiz",
+ "op": "add",
+ "path": "/starterQuiz",
+ "value": [
+ {
+ "question": "When did the Romans invade Britain?",
+ "answers": [
+ "AD 43"
+ ],
+ "distractors": [
+ "AD 410",
+ "AD 1066"
+ ]
+ },
+ {
+ "question": "What was Roman Britain a part of?",
+ "answers": [
+ "The Roman Empire"
+ ],
+ "distractors": [
+ "The British Empire",
+ "The Greek Empire"
+ ]
+ },
+ {
+ "question": "What did the Romans build in Britain?",
+ "answers": [
+ "Roads and towns"
+ ],
+ "distractors": [
+ "Castles and cathedrals",
+ "Skyscrapers and bridges"
+ ]
+ },
+ {
+ "question": "What did the Romans introduce to Britain?",
+ "answers": [
+ "New technologies and ideas"
+ ],
+ "distractors": [
+ "New languages and alphabets",
+ "New art styles and music"
+ ]
+ },
+ {
+ "question": "Who protected Britain from invasions?",
+ "answers": [
+ "Roman soldiers"
+ ],
+ "distractors": [
+ "Saxon warriors",
+ "Viking explorers"
+ ]
+ },
+ {
+ "question": "Which groups invaded Britain after the Romans?",
+ "answers": [
+ "The Saxons"
+ ],
+ "distractors": [
+ "The Normans",
+ "The Vikings"
+ ]
+ }
+ ]
+ },
+ "status": "complete"
+ }
+ ],
+ "prompt": {
+ "type": "text",
+ "value": "The Starter Quiz is ready, focusing on the prior knowledge needed for the lesson. Now, let's develop the learning cycles to guide the main content of the lesson."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-6.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-6.moderation.json
new file mode 100644
index 000000000..ed7c4a327
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-6.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKNmNnQBpA1ku9f2IB7yXE3UH1Rwz",
+ "object": "chat.completion",
+ "created": 1729421331,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan for 'The End of Roman Britain' is fully compliant across all categories. It does not contain any discriminatory language, offensive language, or strong language, thus scoring a 5 in 'Language and discrimination'. There is no depiction or discussion of conflict, violence, serious violence, or sexual violence, resulting in a 5 for 'Violence and crime'. The lesson plan avoids any upsetting, sensitive, or distressing content, such as criminal behavior, natural disasters, or mental health issues, earning a 5 in the 'Upsetting, disturbing and sensitive' category. There is no mention of nudity or sexual content, leading to a 5 for 'Nudity and sex'. The lesson does not involve any exploration of objects, use of equipment requiring supervision, imitable behaviors, external content, or physical activity, hence a 5 in 'Physical activity and safety'. Finally, there is no content related to self-harm, harming others, creating weapons or harmful substances, nor encouragement of harmful or illegal activities, which ensures a 5 in the 'Toxic' category. Overall, the lesson content is appropriate for the key-stage 1 audience.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 2794,
+ "completion_tokens": 269,
+ "total_tokens": 3063,
+ "prompt_tokens_details": {
+ "cached_tokens": 2176
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-7.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-7.chunks.txt
new file mode 100644
index 000000000..23ae72bf8
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-7.chunks.txt
@@ -0,0 +1,221 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[
+{"
+type":"
+patch
+","reasoning":"
+The
+ Starter
+ Quiz
+ is
+ designed
+ to
+ assess
+ pupils
+'
+ prior
+ knowledge
+ before
+ beginning
+ the
+ lesson
+.","
+value":{"
+type":"
+quiz
+","op":"
+add
+","path":"/
+starter
+Quiz
+","value":[
+{"
+question":"
+What
+ did
+ the
+ Romans
+ build
+ in
+ Britain
+?
+","answers":["
+Road
+s
+ and
+ towns
+"],"distractors":["
+Cast
+les
+ and
+ towers
+","
+F
+arms
+ and
+ wind
+mills
+"]},{"
+question":"
+Who
+ protected
+ Roman
+ Britain
+ from
+ invas
+ions
+?
+","answers":["
+Roman
+ soldiers
+"],"distractors":["
+Local
+ farmers
+","
+Mer
+chants
+"]},{"
+question":"
+What
+ new
+ ideas
+ did
+ the
+ Romans
+ bring
+ to
+ Britain
+?
+","answers":["
+Road
+s
+ and
+ technologies
+"],"distractors":["
+Cast
+les
+ and
+ magic
+","
+Ships
+ and
+ boats
+"]},{"
+question":"
+Which
+ groups
+ lived
+ in
+ Britain
+ before
+ the
+ Romans
+?
+","answers":["
+Different
+ groups
+"],"distractors":["
+Only
+ Romans
+","
+Only
+ Cel
+ts
+"]},{"
+question":"
+Why
+ might
+ the
+ Romans
+ have
+ left
+ Britain
+?
+","answers":["
+To
+ defend
+ other
+ parts
+ of
+ the
+ Empire
+"],"distractors":["
+The
+ weather
+ was
+ too
+ cold
+","
+They
+ had
+ finished
+ conqu
+ering
+ Britain
+"]},{"
+question":"
+What
+ happened
+ to
+ trade
+ after
+ the
+ Romans
+ left
+?
+","answers":["
+It
+ changed
+ significantly
+"],"distractors":["
+It
+ flour
+ished
+","
+It
+ stayed
+ the
+ same
+"]}]},"status":"
+complete
+"}],"prompt":{"
+type":"
+text
+","value":"
+The
+ Starter
+ Quiz
+ has
+ been
+ created
+ to
+ check
+ pupils
+'
+ prior
+ knowledge
+.
+ Let's
+ move
+ on
+ to
+ the
+ learning
+ cycles
+ and
+ the
+ Exit
+ Quiz
+.
+ Tap
+ **
+Continue
+**
+ to
+ proceed
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-7.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-7.formatted.json
new file mode 100644
index 000000000..7f36a1acf
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-7.formatted.json
@@ -0,0 +1,81 @@
+{
+ "type": "llmMessage",
+ "patches": [
+ {
+ "type": "patch",
+ "reasoning": "The Starter Quiz is designed to assess pupils' prior knowledge before beginning the lesson.",
+ "value": {
+ "type": "quiz",
+ "op": "add",
+ "path": "/starterQuiz",
+ "value": [
+ {
+ "question": "What did the Romans build in Britain?",
+ "answers": [
+ "Roads and towns"
+ ],
+ "distractors": [
+ "Castles and towers",
+ "Farms and windmills"
+ ]
+ },
+ {
+ "question": "Who protected Roman Britain from invasions?",
+ "answers": [
+ "Roman soldiers"
+ ],
+ "distractors": [
+ "Local farmers",
+ "Merchants"
+ ]
+ },
+ {
+ "question": "What new ideas did the Romans bring to Britain?",
+ "answers": [
+ "Roads and technologies"
+ ],
+ "distractors": [
+ "Castles and magic",
+ "Ships and boats"
+ ]
+ },
+ {
+ "question": "Which groups lived in Britain before the Romans?",
+ "answers": [
+ "Different groups"
+ ],
+ "distractors": [
+ "Only Romans",
+ "Only Celts"
+ ]
+ },
+ {
+ "question": "Why might the Romans have left Britain?",
+ "answers": [
+ "To defend other parts of the Empire"
+ ],
+ "distractors": [
+ "The weather was too cold",
+ "They had finished conquering Britain"
+ ]
+ },
+ {
+ "question": "What happened to trade after the Romans left?",
+ "answers": [
+ "It changed significantly"
+ ],
+ "distractors": [
+ "It flourished",
+ "It stayed the same"
+ ]
+ }
+ ]
+ },
+ "status": "complete"
+ }
+ ],
+ "prompt": {
+ "type": "text",
+ "value": "The Starter Quiz has been created to check pupils' prior knowledge. Let's move on to the learning cycles and the Exit Quiz. Tap **Continue** to proceed."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-7.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-7.moderation.json
new file mode 100644
index 000000000..8f83f1fa9
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-7.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKMzCAnvRAOCvTEsGdMqU7Ig02Q4J",
+ "object": "chat.completion",
+ "created": 1729418282,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan for 'The End of Roman Britain' is fully compliant across all categories. It is designed for Key Stage 1, targeting young learners, and does not contain any discriminatory language, offensive or strong language, or depictions of conflict, violence, or sensitive topics. The content focuses on historical events and changes in trade and society after Roman soldiers left Britain, which are appropriate for the intended age group. There is no discussion of nudity or sexual content, and no physical activities or use of equipment requiring supervision are involved. Additionally, there are no guides or encouragements for harmful behavior or illegal activities. The material is educational and age-appropriate.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 2795,
+ "completion_tokens": 165,
+ "total_tokens": 2960,
+ "prompt_tokens_details": {
+ "cached_tokens": 2176
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-8.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-8.chunks.txt
new file mode 100644
index 000000000..c330a96ca
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-8.chunks.txt
@@ -0,0 +1,335 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[
+{"
+type":"
+patch
+","reasoning":"
+Cycle
+
+1
+ focuses
+ on
+ identifying
+ key
+ events
+ leading
+ to
+ the
+ end
+ of
+ Roman
+ rule
+.","
+value":{"
+type":"
+cycle
+","op":"
+add
+","path":"/
+cycle
+1
+","value":{"
+title":"
+Ident
+ifying
+ Key
+ Events
+ Leading
+ to
+ the
+ End
+ of
+ Roman
+ Rule
+","durationInMinutes":15
+,"explanation":{"
+spokenExplanation":["
+Explain
+ the
+ decline
+ of
+ Roman
+ power
+ in
+ Britain
+ due
+ to
+ economic
+ troubles
+ and
+ external
+ pressures
+.","
+Describe
+ how
+ Roman
+ leg
+ions
+ were
+ recalled
+ to
+ defend
+ other
+ parts
+ of
+ the
+ Empire
+.","
+Mention
+ the
+ year
+
+410
+ AD
+ when
+ the
+ Roman
+ withdrawal
+ was
+ completed
+.","
+Discuss
+ the
+ impact
+ of
+ this
+ withdrawal
+ on
+ local
+ governance
+ and
+ security
+.","
+Connect
+ to
+ prior
+ knowledge
+ of
+ Roman
+ infrastructure
+ like
+ roads
+ and
+ towns
+ and
+ how
+ they
+ were
+ affected
+."
+],"accompanyingSlideDetails":"
+A
+ timeline
+ showing
+ key
+ events
+ leading
+ to
+ the
+ end
+ of
+ Roman
+ rule
+ in
+ Britain
+.","
+imagePrompt":"
+Roman
+ Britain
+ timeline
+","slideText":"
+Key
+ events
+ leading
+ to
+ the
+ end
+ of
+ Roman
+ rule
+ include
+ economic
+ troubles
+,
+ military
+ recalls
+,
+ and
+ the
+ completion
+ of
+ withdrawal
+ in
+
+410
+ AD
+."
+},"checkForUnderstanding":[
+{"
+question":"
+Why
+ did
+ Roman
+ soldiers
+ leave
+ Britain
+?
+","answers":["
+To
+ defend
+ other
+ parts
+ of
+ the
+ Empire
+"],"distractors":["
+Because
+ they
+ were
+ no
+ longer
+ needed
+","
+Due
+ to
+ the
+ cold
+ weather
+"]},{"
+question":"
+What
+ year
+ marked
+ the
+ completion
+ of
+ Roman
+ withdrawal
+ from
+ Britain
+?
+","answers":["
+410
+ AD
+"],"distractors":["
+106
+6
+ AD
+","
+500
+ AD
+"]}],"practice":"
+List
+ three
+ key
+ events
+ that
+ led
+ to
+ the
+ end
+ of
+ Roman
+ rule
+ in
+ Britain
+.
+ Provide
+ a
+ short
+ description
+ of
+ each
+ event
+.","
+feedback":"
+Model
+ answer
+:
+
+1
+.
+ Economic
+ troubles
+ weakened
+ Roman
+ power
+.
+
+2
+.
+ Roman
+ leg
+ions
+ were
+ recalled
+.
+
+3
+.
+ Roman
+ withdrawal
+ was
+ completed
+ by
+
+410
+ AD
+."
+}},"status":"
+complete
+"}],"prompt":{"
+type":"
+text
+","value":"
+Cycle
+
+1
+ has
+ been
+ structured
+ to
+ help
+ pupils
+ identify
+ key
+ events
+ that
+ led
+ to
+ the
+ end
+ of
+ Roman
+ rule
+.
+ Let's
+ proceed
+ to
+ Cycle
+
+2
+,
+ which
+ will
+ focus
+ on
+ the
+ impact
+ of
+ Roman
+ withdrawal
+.
+ Tap
+ **
+Continue
+**
+ to
+ move
+ forward
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-8.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-8.formatted.json
new file mode 100644
index 000000000..28e50574d
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-8.formatted.json
@@ -0,0 +1,59 @@
+{
+ "type": "llmMessage",
+ "patches": [
+ {
+ "type": "patch",
+ "reasoning": "Cycle 1 focuses on identifying key events leading to the end of Roman rule.",
+ "value": {
+ "type": "cycle",
+ "op": "add",
+ "path": "/cycle1",
+ "value": {
+ "title": "Identifying Key Events Leading to the End of Roman Rule",
+ "durationInMinutes": 15,
+ "explanation": {
+ "spokenExplanation": [
+ "Explain the decline of Roman power in Britain due to economic troubles and external pressures.",
+ "Describe how Roman legions were recalled to defend other parts of the Empire.",
+ "Mention the year 410 AD when the Roman withdrawal was completed.",
+ "Discuss the impact of this withdrawal on local governance and security.",
+ "Connect to prior knowledge of Roman infrastructure like roads and towns and how they were affected."
+ ],
+ "accompanyingSlideDetails": "A timeline showing key events leading to the end of Roman rule in Britain.",
+ "imagePrompt": "Roman Britain timeline",
+ "slideText": "Key events leading to the end of Roman rule include economic troubles, military recalls, and the completion of withdrawal in 410 AD."
+ },
+ "checkForUnderstanding": [
+ {
+ "question": "Why did Roman soldiers leave Britain?",
+ "answers": [
+ "To defend other parts of the Empire"
+ ],
+ "distractors": [
+ "Because they were no longer needed",
+ "Due to the cold weather"
+ ]
+ },
+ {
+ "question": "What year marked the completion of Roman withdrawal from Britain?",
+ "answers": [
+ "410 AD"
+ ],
+ "distractors": [
+ "1066 AD",
+ "500 AD"
+ ]
+ }
+ ],
+ "practice": "List three key events that led to the end of Roman rule in Britain. Provide a short description of each event.",
+ "feedback": "Model answer: 1. Economic troubles weakened Roman power. 2. Roman legions were recalled. 3. Roman withdrawal was completed by 410 AD."
+ }
+ },
+ "status": "complete"
+ }
+ ],
+ "prompt": {
+ "type": "text",
+ "value": "Cycle 1 has been structured to help pupils identify key events that led to the end of Roman rule. Let's proceed to Cycle 2, which will focus on the impact of Roman withdrawal. Tap **Continue** to move forward."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-8.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-8.moderation.json
new file mode 100644
index 000000000..7287e7f9d
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-8.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKMzQHXSHIDpcrU79Fcjx6BfDaYHp",
+ "object": "chat.completion",
+ "created": 1729418296,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan for 'The End of Roman Britain' is fully compliant across all categories. It presents historical content suitable for Key Stage 1 learners, focusing on the end of Roman rule in Britain without any use of discriminatory or offensive language. There are no depictions or discussions of violence or crime, upsetting, sensitive, or distressing content, nudity, or sexual content. The lesson does not involve any physical activities or require the use of equipment, nor does it include any toxic content or encouragement of harmful behavior. The content is educational, age-appropriate, and focuses on historical events in a factual manner.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 3094,
+ "completion_tokens": 156,
+ "total_tokens": 3250,
+ "prompt_tokens_details": {
+ "cached_tokens": 2432
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-9.chunks.txt b/apps/nextjs/tests-e2e/recordings/roman-britain-9.chunks.txt
new file mode 100644
index 000000000..91852cb69
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-9.chunks.txt
@@ -0,0 +1,306 @@
+{"
+type":"
+ll
+m
+Message
+","patches":[
+{"
+type":"
+patch
+","reasoning":"
+Cycle
+
+2
+ focuses
+ on
+ describing
+ the
+ impact
+ of
+ the
+ Roman
+ withdrawal
+ on
+ Britain
+.","
+value":{"
+type":"
+cycle
+","op":"
+add
+","path":"/
+cycle
+2
+","value":{"
+title":"
+Des
+cribing
+ the
+ Impact
+ of
+ the
+ Roman
+ Withdrawal
+","durationInMinutes":15
+,"explanation":{"
+spokenExplanation":["
+Discuss
+ how
+ the
+ withdrawal
+ of
+ Roman
+ soldiers
+ led
+ to
+ vulnerabilities
+ in
+ Britain
+.","
+Explain
+ the
+ increased
+ risk
+ of
+ invas
+ions
+ by
+ groups
+ such
+ as
+ the
+ Sax
+ons
+ and
+ P
+icts
+.","
+Describe
+ how
+ local
+ governance
+ struggled
+ without
+ Roman
+ support
+.","
+Connect
+ this
+ to
+ the
+ decline
+ in
+ trade
+ and
+ infrastructure
+ maintenance
+ in
+ Roman
+ towns
+.","
+Rel
+ate
+ these
+ changes
+ to
+ the
+ pupils
+'
+ prior
+ knowledge
+ of
+ Roman
+ Britain
+."
+],"accompanyingSlideDetails":"
+Images
+ showing
+ invas
+ions
+ and
+ declining
+ infrastructure
+ post
+-R
+oman
+ withdrawal
+.","
+imagePrompt":"
+In
+vas
+ions
+ after
+ Roman
+ withdrawal
+","slideText":"
+The
+ Roman
+ withdrawal
+ left
+ Britain
+ vulnerable
+ to
+ invas
+ions
+ and
+ resulted
+ in
+ declining
+ infrastructure
+ and
+ governance
+."
+},"checkForUnderstanding":[
+{"
+question":"
+What
+ was
+ one
+ result
+ of
+ the
+ Roman
+ soldiers
+ leaving
+ Britain
+?
+","answers":["
+In
+creased
+ invas
+ions
+"],"distractors":["
+More
+ trade
+ opportunities
+","
+Better
+ infrastructure
+"]},{"
+question":"
+Who
+ were
+ some
+ of
+ the
+ groups
+ that
+ invaded
+ Britain
+ after
+ the
+ Romans
+ left
+?
+","answers":["
+S
+ax
+ons
+ and
+ P
+icts
+"],"distractors":["
+Romans
+ and
+ Cel
+ts
+","
+V
+ik
+ings
+ and
+ Norm
+ans
+"]}],"practice":"
+Describe
+ two
+ impacts
+ of
+ the
+ Roman
+ withdrawal
+ on
+ Britain
+ and
+ how
+ they
+ affected
+ the
+ local
+ population
+.","
+feedback":"
+Model
+ answer
+:
+ The
+ Roman
+ withdrawal
+ made
+ Britain
+ vulnerable
+ to
+ Sax
+on
+ invas
+ions
+ and
+ led
+ to
+ a
+ decline
+ in
+ maintained
+ infrastructure
+ and
+ trade
+."
+}},"status":"
+complete
+"}],"prompt":{"
+type":"
+text
+","value":"
+Cycle
+
+2
+ has
+ been
+ added
+,
+ focusing
+ on
+ the
+ impact
+ of
+ Roman
+ withdrawal
+.
+ Next
+,
+ we'll
+ develop
+ Cycle
+
+3
+,
+ which
+ will
+ discuss
+ life
+ changes
+ in
+ Britain
+ after
+ the
+ Romans
+ left
+.
+ Tap
+ **
+Continue
+**
+ to
+ proceed
+."
+}}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-9.formatted.json b/apps/nextjs/tests-e2e/recordings/roman-britain-9.formatted.json
new file mode 100644
index 000000000..e23bef705
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-9.formatted.json
@@ -0,0 +1,59 @@
+{
+ "type": "llmMessage",
+ "patches": [
+ {
+ "type": "patch",
+ "reasoning": "Cycle 2 focuses on describing the impact of the Roman withdrawal on Britain.",
+ "value": {
+ "type": "cycle",
+ "op": "add",
+ "path": "/cycle2",
+ "value": {
+ "title": "Describing the Impact of the Roman Withdrawal",
+ "durationInMinutes": 15,
+ "explanation": {
+ "spokenExplanation": [
+ "Discuss how the withdrawal of Roman soldiers led to vulnerabilities in Britain.",
+ "Explain the increased risk of invasions by groups such as the Saxons and Picts.",
+ "Describe how local governance struggled without Roman support.",
+ "Connect this to the decline in trade and infrastructure maintenance in Roman towns.",
+ "Relate these changes to the pupils' prior knowledge of Roman Britain."
+ ],
+ "accompanyingSlideDetails": "Images showing invasions and declining infrastructure post-Roman withdrawal.",
+ "imagePrompt": "Invasions after Roman withdrawal",
+ "slideText": "The Roman withdrawal left Britain vulnerable to invasions and resulted in declining infrastructure and governance."
+ },
+ "checkForUnderstanding": [
+ {
+ "question": "What was one result of the Roman soldiers leaving Britain?",
+ "answers": [
+ "Increased invasions"
+ ],
+ "distractors": [
+ "More trade opportunities",
+ "Better infrastructure"
+ ]
+ },
+ {
+ "question": "Who were some of the groups that invaded Britain after the Romans left?",
+ "answers": [
+ "Saxons and Picts"
+ ],
+ "distractors": [
+ "Romans and Celts",
+ "Vikings and Normans"
+ ]
+ }
+ ],
+ "practice": "Describe two impacts of the Roman withdrawal on Britain and how they affected the local population.",
+ "feedback": "Model answer: The Roman withdrawal made Britain vulnerable to Saxon invasions and led to a decline in maintained infrastructure and trade."
+ }
+ },
+ "status": "complete"
+ }
+ ],
+ "prompt": {
+ "type": "text",
+ "value": "Cycle 2 has been added, focusing on the impact of Roman withdrawal. Next, we'll develop Cycle 3, which will discuss life changes in Britain after the Romans left. Tap **Continue** to proceed."
+ }
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/recordings/roman-britain-9.moderation.json b/apps/nextjs/tests-e2e/recordings/roman-britain-9.moderation.json
new file mode 100644
index 000000000..0244ce372
--- /dev/null
+++ b/apps/nextjs/tests-e2e/recordings/roman-britain-9.moderation.json
@@ -0,0 +1,30 @@
+{
+ "id": "chatcmpl-AKMzhoXD3hmH8bfWuBTQTQ5tQUstQ",
+ "object": "chat.completion",
+ "created": 1729418313,
+ "model": "gpt-4o-2024-08-06",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "{\"scores\":{\"l\":5,\"v\":5,\"u\":5,\"s\":5,\"p\":5,\"t\":5},\"justification\":\"The lesson plan is fully compliant across all categories. It discusses historical events surrounding the end of Roman rule in Britain in a factual and age-appropriate manner, suitable for Key Stage 1 learners. There is no use of discriminatory or offensive language, nor is there any depiction of violence or sensitive content. The historical context is presented without any distressing or inappropriate content for this age group. Additionally, there is no mention of nudity, sexual content, or any physical activities requiring supervision. The lesson is purely educational and does not involve any toxic or harmful materials.\",\"categories\":[]}",
+ "refusal": null
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 3369,
+ "completion_tokens": 145,
+ "total_tokens": 3514,
+ "prompt_tokens_details": {
+ "cached_tokens": 2944
+ },
+ "completion_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "system_fingerprint": "fp_a7d06e42a7"
+}
\ No newline at end of file
diff --git a/apps/nextjs/tests-e2e/tests/aila-chat/full-romans.test.ts b/apps/nextjs/tests-e2e/tests/aila-chat/full-romans.test.ts
index 7ca82c9d3..3cc5a13f6 100644
--- a/apps/nextjs/tests-e2e/tests/aila-chat/full-romans.test.ts
+++ b/apps/nextjs/tests-e2e/tests/aila-chat/full-romans.test.ts
@@ -1,6 +1,10 @@
import { setupClerkTestingToken } from "@clerk/testing/playwright";
+import type { LessonPlanKeys } from "@oakai/aila/src/protocol/schema";
+import { LessonPlanKeysSchema } from "@oakai/aila/src/protocol/schema";
import { test, expect } from "@playwright/test";
+import { groupedSectionsInOrder } from "@/lib/lessonPlan/sectionsInOrder";
+
import { TEST_BASE_URL } from "../../config/config";
import { bypassVercelProtection } from "../../helpers/vercel";
import type { FixtureMode } from "./helpers";
@@ -9,7 +13,7 @@ import {
continueChat,
expectFinished,
expectStreamingStatus,
- isFinished,
+ getSectionsComplete,
scrollLessonPlanFromTopToBottom,
waitForStreamingStatusChange,
} from "./helpers";
@@ -55,6 +59,8 @@ test(
await test.step("Iterate through the fixtures", async () => {
await page.waitForURL(/\/aila\/.+/);
+ let prevIteration = 0;
+ let prevSectionsComplete = 0;
const maxIterations = 20;
for (
@@ -72,9 +78,77 @@ test(
generationTimeout,
);
+ // Wait for the chat iteration to update
+ await page.waitForFunction(
+ ([prevIteration]) => {
+ const chatIteration = document.querySelector(
+ '[data-testid="chat-iteration"]',
+ );
+ return (
+ chatIteration &&
+ parseInt(chatIteration.textContent || "0", 10) >
+ (prevIteration ?? 0)
+ );
+ },
+ [prevIteration],
+ { timeout: generationTimeout },
+ );
+ // Update the previous iteration
+ const chatIteration = await page.textContent(
+ '[data-testid="chat-iteration"]',
+ );
+ prevIteration = parseInt(chatIteration || "0", 10);
+
+ // Get the current sections complete
+ const currSectionsComplete = await getSectionsComplete(page);
+
+ // Assert that currSectionsComplete is greater than or equal to the previous value
+ expect(currSectionsComplete).toBeGreaterThanOrEqual(
+ prevSectionsComplete,
+ );
+
+ // Update the previous sections complete
+ prevSectionsComplete = currSectionsComplete;
+
await expectStreamingStatus(page, "Idle", { timeout: 5000 });
- if (await isFinished(page)) {
+ const createdSections = await page.$$eval(
+ '[data-test="lesson-plan-section"]',
+ (sections) =>
+ sections
+ .filter(
+ (section) =>
+ section.getAttribute("data-test-section-complete") === "true",
+ )
+ .map((section) => section.getAttribute("data-test-section-key")),
+ );
+
+ console.log("Created sections", createdSections);
+
+ const createdSectionKeys: LessonPlanKeys[] = createdSections
+ .filter((section) => section !== null)
+ .map((section) => LessonPlanKeysSchema.parse(section as string));
+
+ const mostRecentSection =
+ createdSectionKeys[createdSectionKeys.length - 1];
+
+ const mostRecentSectionGroup = groupedSectionsInOrder.find(
+ (group) => mostRecentSection && group.includes(mostRecentSection),
+ );
+
+ // Assert that all sections in the mostRecentSectionGroup are in createdSectionKeys
+ expect(mostRecentSectionGroup).toBeDefined();
+ if (mostRecentSectionGroup) {
+ mostRecentSectionGroup.forEach((section) => {
+ expect(createdSectionKeys).toContain(section);
+ });
+ }
+
+ // If currSectionsComplete reaches 10 and we have the additionalMaterials section, we can break
+ if (
+ currSectionsComplete === 10 &&
+ createdSectionKeys.includes("additionalMaterials")
+ ) {
break;
}
await continueChat(page);
diff --git a/packages/aila/src/core/Aila.test.ts b/packages/aila/src/core/Aila.test.ts
index 12f725f3d..7343f8b13 100644
--- a/packages/aila/src/core/Aila.test.ts
+++ b/packages/aila/src/core/Aila.test.ts
@@ -382,6 +382,7 @@ describe("Aila", () => {
// Use MockLLMService to generate a response
await ailaInstance.generateSync({ input: "Test input" });
+ console.log("Generated");
// Check if MockLLMService updates were applied
expect(ailaInstance.lesson.plan.title).toBe("Updated Mocked Lesson Plan");
expect(ailaInstance.lesson.plan.subject).toBe("Updated Mocked Subject");
diff --git a/packages/aila/src/protocol/sectionToMarkdown.ts b/packages/aila/src/protocol/sectionToMarkdown.ts
index e9b8f36fd..6624dacda 100644
--- a/packages/aila/src/protocol/sectionToMarkdown.ts
+++ b/packages/aila/src/protocol/sectionToMarkdown.ts
@@ -1,4 +1,4 @@
-import { camelCaseToSentenceCase } from "@oakai/core/src/utils/camelCaseToSentenceCase";
+import { camelCaseToSentenceCase } from "@oakai/core/src/utils/camelCaseConversion";
import { isArray, isNumber, isObject, isString } from "remeda";
import type { QuizOptional } from "./schema";
diff --git a/packages/api/src/router/appSessions.ts b/packages/api/src/router/appSessions.ts
index ce46e6572..cbd2b5a67 100644
--- a/packages/api/src/router/appSessions.ts
+++ b/packages/api/src/router/appSessions.ts
@@ -4,6 +4,7 @@ import { demoUsers } from "@oakai/core";
import { rateLimits } from "@oakai/core/src/utils/rateLimiting/rateLimit";
import { RateLimitExceededError } from "@oakai/core/src/utils/rateLimiting/userBasedRateLimiter";
import type { Prisma, PrismaClientWithAccelerate } from "@oakai/db";
+import { aiLogger } from "@oakai/logger";
import * as Sentry from "@sentry/nextjs";
import { TRPCError } from "@trpc/server";
import { isTruthy } from "remeda";
@@ -11,11 +12,17 @@ import { z } from "zod";
import { getSessionModerations } from "../../../aila/src/features/moderation/getSessionModerations";
import { generateChatId } from "../../../aila/src/helpers/chat/generateChatId";
-import type { AilaPersistedChat } from "../../../aila/src/protocol/schema";
+import type {
+ AilaPersistedChat,
+ LessonPlanKeys,
+ LooseLessonPlan,
+} from "../../../aila/src/protocol/schema";
import { chatSchema } from "../../../aila/src/protocol/schema";
import { protectedProcedure } from "../middleware/auth";
import { router } from "../trpc";
+const log = aiLogger("trpc");
+
function userIsOwner(entity: { userId: string }, auth: SignedInAuthObject) {
return entity.userId === auth.userId;
}
@@ -39,7 +46,8 @@ function parseChatAndReportError({
});
if (!parseResult.success) {
- const error = new Error("Failed to parse chat");
+ const error = new Error(`Failed to parse chat`);
+ log.info("Failed to parse chat", id, parseResult.error.flatten());
Sentry.captureException(error, {
extra: {
id,
@@ -50,6 +58,13 @@ function parseChatAndReportError({
});
}
+ const iteration = parseResult.data?.iteration;
+ const lessonPlan: LooseLessonPlan = parseResult.data?.lessonPlan ?? {};
+ const keys = (Object.keys(lessonPlan) as LessonPlanKeys[]).filter(
+ (k) => lessonPlan[k],
+ );
+ log.info("Parsed chat", iteration, `${keys.length} keys`, keys.join("|"), id);
+
return parseResult.data;
}
@@ -108,8 +123,8 @@ export const appSessionsRouter = router({
.query(async ({ ctx, input }) => {
const { id } = input;
+ log.info("Getting chat", id);
const chat = await getChat(id, ctx.prisma);
-
if (!chat) {
return null;
}
diff --git a/packages/core/src/models/lessonPlans.ts b/packages/core/src/models/lessonPlans.ts
index 736c6fc58..0ab6f04a3 100644
--- a/packages/core/src/models/lessonPlans.ts
+++ b/packages/core/src/models/lessonPlans.ts
@@ -18,7 +18,7 @@ import { inngest } from "../inngest";
import { createOpenAIClient } from "../llm/openai";
import { template } from "../prompts/lesson-assistant";
import { RAG } from "../rag";
-import { camelCaseToSentenceCase } from "../utils/camelCaseToSentenceCase";
+import { camelCaseToSentenceCase } from "../utils/camelCaseConversion";
import { embedWithCache } from "../utils/embeddings";
import { textify } from "../utils/textify";
import type { Caption} from "./types/caption";
diff --git a/packages/core/src/utils/camelCaseToSentenceCase.ts b/packages/core/src/utils/camelCaseToSentenceCase.ts
deleted file mode 100644
index 257769957..000000000
--- a/packages/core/src/utils/camelCaseToSentenceCase.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export function camelCaseToSentenceCase(str: string) {
- return str
- .replace(/([A-Z0-9])/g, " $1") // Insert a space before each uppercase letter or digit
- .replace(/^./, (str) => str.toUpperCase())
- .replace(/\s[A-Z]/g, (str) => str.toLowerCase());
-}
diff --git a/packages/exports/src/utils.ts b/packages/exports/src/utils.ts
index fad51c770..c0e33ba4f 100644
--- a/packages/exports/src/utils.ts
+++ b/packages/exports/src/utils.ts
@@ -17,7 +17,7 @@ export function getFileName({
/**
* @description
- * - If the value is falsey, an empty string is returned.
+ * - If the value is falsy, an empty string is returned.
* - If the value is a string, it is returned as is.
* - If the value is an array:
* - it defaults to joining with a newline character