Skip to content

Commit 94a63bb

Browse files
committed
Merge all prompts into :prompts
1 parent 2425d4b commit 94a63bb

File tree

9 files changed

+39
-79
lines changed

9 files changed

+39
-79
lines changed

src/commons/application/actions/__tests__/SessionActions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ test('updateGrading generates correct action object', async () => {
605605
const grading: GradingQuery = {
606606
answers: [
607607
{
608+
id: 0,
609+
prompts: [],
608610
question: await vi.importMock('../../../../features/grading/GradingTypes'),
609611
student: {
610612
name: 'test student',
@@ -627,7 +629,6 @@ test('updateGrading generates correct action object', async () => {
627629
],
628630
enable_llm_grading: false,
629631
assessment: {
630-
llm_assessment_prompt: null,
631632
coverPicture: 'https://i.imgur.com/dR7zBPI.jpeg',
632633
id: 1,
633634
number: '5',

src/commons/application/reducers/__tests__/SessionReducer.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ const gradingTest1: GradingQuery = {
405405
enable_llm_grading: false,
406406
answers: [
407407
{
408+
id: 0,
409+
prompts: [],
408410
autogradingResults: [],
409411
autoGradingStatus: 'N/A',
410412
question: await vi.importMock('../../../../features/grading/GradingTypes'),
@@ -421,7 +423,6 @@ const gradingTest1: GradingQuery = {
421423
}
422424
],
423425
assessment: {
424-
llm_assessment_prompt: null,
425426
coverPicture: 'test string',
426427
id: 1,
427428
number: 'M1A',
@@ -437,6 +438,8 @@ const gradingTest2: GradingQuery = {
437438
enable_llm_grading: false,
438439
answers: [
439440
{
441+
id: 0,
442+
prompts: [],
440443
autogradingResults: [],
441444
autoGradingStatus: 'N/A',
442445
question: await vi.importMock('../../../../features/grading/GradingTypes'),
@@ -453,7 +456,6 @@ const gradingTest2: GradingQuery = {
453456
}
454457
],
455458
assessment: {
456-
llm_assessment_prompt: null,
457459
coverPicture: 'another test string',
458460
id: 2,
459461
number: 'P2',

src/commons/assessment/AssessmentTypes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export interface IProgrammingQuestion extends BaseQuestion {
121121
prepend: string;
122122
postpend: string;
123123
solutionTemplate: string;
124-
llm_prompt?: string | null;
125124
testcases: Testcase[];
126125
testcasesPrivate?: Testcase[]; // For mission control
127126
type: 'programming';
@@ -144,6 +143,11 @@ export interface IContestVotingQuestion extends BaseQuestion {
144143
type: 'voting';
145144
}
146145

146+
export type LLMPrompt = {
147+
role: string;
148+
content: string;
149+
};
150+
147151
export type BaseQuestion = {
148152
answer: string | number | ContestEntry[] | null;
149153
comments?: string;
@@ -281,7 +285,6 @@ export const programmingTemplate = (): IProgrammingQuestion => {
281285
prepend: '',
282286
solutionTemplate: '//This is a mock solution template',
283287
postpend: '',
284-
llm_prompt: null,
285288
testcases: [],
286289
testcasesPrivate: [],
287290
type: 'programming',

src/commons/mocks/GradingMocks.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ export const mockTestcases: Testcase[] = [
128128

129129
export const mockGradingAnswer: GradingAnswer = [
130130
{
131+
id: 0,
132+
prompts: [],
131133
autogradingResults: [],
132134
autoGradingStatus: 'N/A',
133135
question: {
@@ -246,6 +248,8 @@ _italics_
246248
}
247249
},
248250
{
251+
id: 1,
252+
prompts: [],
249253
autogradingResults: [],
250254
autoGradingStatus: 'N/A',
251255
question: {
@@ -340,6 +344,8 @@ New message from **Avenger**!
340344
}
341345
},
342346
{
347+
id: 2,
348+
prompts: [],
343349
autogradingResults: [],
344350
autoGradingStatus: 'N/A',
345351
question: {
@@ -421,7 +427,6 @@ New message from **Avenger**!
421427

422428
export const mockGradingAssessment: GradingAssessment = {
423429
coverPicture: 'https://i.imgur.com/dR7zBPI.jpeg',
424-
llm_assessment_prompt: null,
425430
id: 1,
426431
number: '10',
427432
reading:

src/commons/sagas/RequestsSaga.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,6 @@ export const getGrading = async (
10451045
solutionTemplate: question.solutionTemplate,
10461046
prepend: question.prepend || '',
10471047
postpend: question.postpend || '',
1048-
llm_prompt: question.llm_prompt || null,
10491048
testcases: question.testcases || [],
10501049
type: question.type as QuestionType,
10511050
maxXp: question.maxXp
@@ -1057,7 +1056,8 @@ export const getGrading = async (
10571056
xpAdjustment: grade.xpAdjustment,
10581057
comments: grade.comments
10591058
},
1060-
ai_comments: gradingQuestion.ai_comments?.response?.split('|||') || []
1059+
ai_comments: gradingQuestion.ai_comments?.response?.split('|||') || [],
1060+
prompts: gradingQuestion.prompts
10611061
} as GradingQuestion;
10621062

10631063
if (gradingQuestion.grade.grader !== null) {

src/features/grading/GradingTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
AssessmentStatus,
55
AssessmentType,
66
AutogradingResult,
7+
LLMPrompt,
78
MCQChoice,
89
ProgressStatus,
910
Question,
@@ -94,7 +95,6 @@ export type GradingAssessment = {
9495
summaryLong: string;
9596
summaryShort: string;
9697
title: string;
97-
llm_assessment_prompt: string | null;
9898
};
9999

100100
export type GradingQuery = {
@@ -195,6 +195,7 @@ export type GradingQuestion = {
195195
autogradingResults: AutogradingResult[];
196196
autoGradingStatus: string;
197197
ai_comments?: string[];
198+
prompts: LLMPrompt[];
198199
};
199200

200201
/**

src/pages/academy/grading/subcomponents/GradingEditor.tsx

Lines changed: 16 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
Dialog,
44
Divider,
55
H3,
6-
H5,
76
Icon,
87
IconName,
98
Intent,
@@ -15,7 +14,7 @@ import { IconNames } from '@blueprintjs/icons';
1514
import React, { useEffect, useMemo, useState } from 'react';
1615
import ReactMde, { ReactMdeProps } from 'react-mde';
1716
import { useDispatch } from 'react-redux';
18-
import { AutogradingResult } from 'src/commons/assessment/AssessmentTypes';
17+
import { AutogradingResult, LLMPrompt } from 'src/commons/assessment/AssessmentTypes';
1918
import { useTokens } from 'src/commons/utils/Hooks';
2019

2120
import SessionActions from '../../../../commons/application/actions/SessionActions';
@@ -41,6 +40,7 @@ type GradingSaveFunction = (
4140
) => void;
4241

4342
type Props = {
43+
prompts: LLMPrompt[];
4444
answer_id: number;
4545
solution: number | string | null;
4646
questionId: number;
@@ -52,12 +52,8 @@ type Props = {
5252
studentUsernames: string[];
5353
is_llm: boolean;
5454
comments: string;
55-
llm_course_level_prompt: string | null;
56-
llm_assessment_prompt: string | null;
57-
llm_question_prompt: string | null;
5855
autoGradingStatus: string;
5956
autoGradingResults: AutogradingResult[];
60-
questionContent: string;
6157
studentAnswer: string | null;
6258
graderName?: string;
6359
gradedAt?: string;
@@ -261,24 +257,11 @@ const GradingEditor: React.FC<Props> = props => {
261257

262258
const copyComposedPromptToClipboard = () => {
263259
navigator.clipboard.writeText(
264-
`${props.llm_course_level_prompt || ''}\n
265-
${props.llm_assessment_prompt || ''}\n
266-
${props.llm_question_prompt || ''}\n
267-
**Question:** \n
268-
\`\`\`\n
269-
${props.questionContent}\n
270-
\`\`\`\n\n
271-
**Model Solution:** \n
272-
\`\`\`\n
273-
${props.solution || 'N/A'}\n
274-
\`\`\`\n\n
275-
**Autograding Status:** ${props.autoGradingStatus}\n
276-
**Autograding Results:** ${props.autoGradingResults ? JSON.stringify(props.autoGradingResults) : 'N/A'}\n
277-
The student answer will be given below as part of the User Prompt.\n
278-
**Student Answer:** \n
279-
\`\`\`\n
280-
${props.studentAnswer}\n
281-
\`\`\``
260+
props.prompts
261+
.map(prompt => {
262+
return `**${prompt.role} Prompt**\n\n${prompt.content}`;
263+
})
264+
.join('\n\n')
282265
);
283266
showSuccessMessage('Composed prompt copied to clipboard!', 2000);
284267
};
@@ -393,43 +376,15 @@ ${props.studentAnswer}\n
393376
<Icon icon={IconNames.Clipboard} />
394377
</Button>
395378
</div>
396-
<H3>System Prompt</H3>
397-
<Divider />
398-
<H5>Course Level Prompt</H5>
399-
{props.llm_course_level_prompt || ''}
400-
<br />
401-
<H5>Assessment Level Prompt</H5>
402-
{props.llm_assessment_prompt || ''}
403-
<br />
404-
<H5>Question Level Prompt</H5>
405-
{props.llm_question_prompt || ''}
406-
<H5>Generic Info From Question</H5>
407-
**Question:** <br />
408-
```
409-
<br />
410-
{props.questionContent}
411-
<br />
412-
```
413-
<br />
414-
<br />
415-
**Model Solution:** <br />
416-
``` <br />
417-
{props.solution || 'N/A'}
418-
<br />
419-
```
420-
<br />
421-
<br />
422-
**Autograding Status:** {props.autoGradingStatus} <br />
423-
**Autograding Results:**{' '}
424-
{props.autoGradingResults ? JSON.stringify(props.autoGradingResults) : 'N/A'} <br />
425-
The student answer will be given below as part of the User Prompt.
426-
<H3>User Prompt</H3>
427-
<Divider />
428-
**Student Answer:** <br />
429-
``` <br />
430-
{props.studentAnswer}
431-
<br />
432-
``` <br />
379+
{props.prompts.map(prompt => {
380+
return (
381+
<>
382+
<H3>{prompt.role} Level Prompt</H3>
383+
<Divider />
384+
{prompt.content}
385+
</>
386+
);
387+
})}
433388
</div>
434389
</Dialog>
435390
<div style={{ marginBottom: '10px' }}>

src/pages/academy/grading/subcomponents/GradingWorkspace.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const GradingWorkspace: React.FC<Props> = props => {
7777
const grading = useTypedSelector(state => state.session.gradings[props.submissionId]);
7878
const courseId = useTypedSelector(state => state.session.courseId);
7979
const llm_grading = useTypedSelector(state => state.session.enableLlmGrading);
80-
const llm_course_level_prompt = useTypedSelector(state => state.session.llmCourseLevelPrompt);
8180
const {
8281
autogradingResults,
8382
isFolderModeEnabled,
@@ -308,7 +307,7 @@ const GradingWorkspace: React.FC<Props> = props => {
308307
ai_comments={grading!.answers[questionId].ai_comments || []}
309308
solution={grading!.answers[questionId].question.solution}
310309
questionId={grading!.answers[questionId].question.id}
311-
questionContent={grading!.answers[questionId].question.content}
310+
prompts={grading!.answers[questionId].prompts}
312311
submissionId={props.submissionId}
313312
initialXp={grading!.answers[questionId].grade.xp}
314313
xpAdjustment={grading!.answers[questionId].grade.xpAdjustment}
@@ -328,13 +327,6 @@ const GradingWorkspace: React.FC<Props> = props => {
328327
: grading!.answers[questionId].team!.map(member => member.username)
329328
}
330329
is_llm={!!llm_grading && grading!.answers[questionId].question.type == 'programming'}
331-
llm_course_level_prompt={llm_course_level_prompt || ''}
332-
llm_assessment_prompt={grading!.assessment.llm_assessment_prompt}
333-
llm_question_prompt={
334-
(grading!.answers[questionId].question.type === 'programming' &&
335-
grading!.answers[questionId].question.llm_prompt) ||
336-
''
337-
}
338330
comments={grading!.answers[questionId].grade.comments ?? ''}
339331
graderName={
340332
grading!.answers[questionId].grade.grader

src/styles/_academy.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
padding: 1rem;
264264
h3 {
265265
margin-top: 1rem;
266+
text-transform: capitalize;
266267
}
267268
h5 {
268269
margin-top: 0.5rem;

0 commit comments

Comments
 (0)