feat: certificates, landing pages, ai tutor, website update, compliance
This commit is contained in:
@@ -1,21 +1,44 @@
|
||||
import { AgentRole, type AgentContext } from '../types';
|
||||
import { buildTeacherSystemPrompt } from './teacher';
|
||||
import { buildStudentSystemPrompt } from './student';
|
||||
import { buildTeacherSystemPrompt, buildTeacherContextMessage } from './teacher';
|
||||
import { buildStudentSystemPrompt, buildStudentContextMessage } from './student';
|
||||
import type { CourseTemplate } from '../templates';
|
||||
import type { AiTutorSettings } from '../tutor-config';
|
||||
|
||||
/**
|
||||
* Builds a role-aware system prompt for the AI assistant.
|
||||
* Teacher prompts include Plan/Agent mode instructions and content writing guidelines.
|
||||
* Student prompts (v2) are read-only focused.
|
||||
* Builds a role-aware system prompt for the AI assistant. The output is stable
|
||||
* across requests (no per-request context) so it can be cached as a long-lived
|
||||
* Anthropic prompt-cache prefix. Per-request volatile context belongs in
|
||||
* `buildContextMessage` and is sent as a user-turn message.
|
||||
*/
|
||||
export function buildSystemPrompt(context: AgentContext): string {
|
||||
export function buildSystemPrompt(context: AgentContext, options?: { tutorSettings?: AiTutorSettings }): string {
|
||||
switch (context.role) {
|
||||
case AgentRole.TEACHER:
|
||||
return buildTeacherSystemPrompt(context);
|
||||
case AgentRole.STUDENT:
|
||||
return buildStudentSystemPrompt(context);
|
||||
return buildStudentSystemPrompt(context, options?.tutorSettings);
|
||||
default:
|
||||
return buildTeacherSystemPrompt(context);
|
||||
}
|
||||
}
|
||||
|
||||
export { buildTeacherSystemPrompt, buildStudentSystemPrompt };
|
||||
/**
|
||||
* Builds the volatile per-request context (current course/lesson/exercise,
|
||||
* uploaded documents, section count, active template flow, latest approved
|
||||
* plan). Send this as a user-turn message at the front of `messages` so the
|
||||
* stable system + tools prefix stays cacheable across navigation and section
|
||||
* mutations.
|
||||
*/
|
||||
export function buildContextMessage(
|
||||
context: AgentContext,
|
||||
options?: { template?: CourseTemplate; approvedPlan?: unknown }
|
||||
): string {
|
||||
switch (context.role) {
|
||||
case AgentRole.STUDENT:
|
||||
return buildStudentContextMessage(context);
|
||||
case AgentRole.TEACHER:
|
||||
default:
|
||||
return buildTeacherContextMessage(context, options);
|
||||
}
|
||||
}
|
||||
|
||||
export { buildTeacherSystemPrompt, buildStudentSystemPrompt, buildTeacherContextMessage, buildStudentContextMessage };
|
||||
|
||||
Reference in New Issue
Block a user