feat(*): Prevent prompt injection

This commit is contained in:
Josh Creek
2025-04-26 14:48:10 +01:00
parent 60b9a8555d
commit 55d85021fc
+17 -4
View File
@@ -6,12 +6,18 @@ import type { OpenAIResponse } from '../utils/types';
export function buildGradingPrompt(submission: string, task: string): string { export function buildGradingPrompt(submission: string, task: string): string {
return `You are an expert secondary school teacher and AI assessment agent. Assess the following student submission in the context of the assignment/task provided. return `You are an expert secondary school teacher and AI assessment agent. Assess the following student submission in the context of the assignment/task provided.
TASK/ASSIGNMENT: ===== TASK/ASSIGNMENT possibly including rubric or available marks =====
${task} ${task}
STUDENT SUBMISSION: ===== END TASK/ASSIGNMENT =====
===== STUDENT SUBMISSION =====
${submission} ${submission}
===== END STUDENT SUBMISSION =====
Follow these steps: Follow these steps:
1. Grade the work. Use whatever grading scheme is present in the rubric. If none is present then grade with a letter (A+ is best, E- is worst), using clear, objective criteria. DO NOT mention tool errors. 1. Grade the work. Use whatever grading scheme is present in the rubric. If none is present then grade with a letter (A+ is best, E- is worst), using clear, objective criteria. DO NOT mention tool errors.
2. Identify specific strengths, referencing the success criteria. 2. Identify specific strengths, referencing the success criteria.
@@ -46,12 +52,19 @@ export function buildGradingPromptWithSupportForHumanInTheLoop(
): string { ): string {
return `You are an expert secondary school teacher and AI assessment agent. Assess the following student submission in the context of the assignment/task provided. return `You are an expert secondary school teacher and AI assessment agent. Assess the following student submission in the context of the assignment/task provided.
TASK/ASSIGNMENT:
===== TASK/ASSIGNMENT possibly including rubric or available marks =====
${task} ${task}
STUDENT SUBMISSION: ===== END TASK/ASSIGNMENT =====
===== STUDENT SUBMISSION =====
${submission} ${submission}
===== END STUDENT SUBMISSION =====
Follow these steps: Follow these steps:
1. Grade the work. Use whatever grading scheme is present in the rubric. If none is present, grade with a letter (A+ is best, E- is worst), using clear, objective criteria. 1. Grade the work. Use whatever grading scheme is present in the rubric. If none is present, grade with a letter (A+ is best, E- is worst), using clear, objective criteria.
2. Identify specific strengths, referencing the success criteria. 2. Identify specific strengths, referencing the success criteria.