Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default prompt for LLM #2656

Draft
wants to merge 45 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b8ef27b
LLM Frontend
clementlemon02 Jul 16, 2023
7bceb47
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Sep 3, 2023
9589c55
Use optional chaining and reformat files
RichDom2185 Jul 18, 2023
b2cb352
Run yarn format
RichDom2185 Jul 18, 2023
a030c99
fix lint issues
clementlemon02 Aug 8, 2023
bbfa704
fix lint issues
clementlemon02 Aug 8, 2023
137eee2
fix lint issues
clementlemon02 Aug 8, 2023
21e606a
fix lint issues
clementlemon02 Aug 8, 2023
9a5fbfa
fix lint issues
clementlemon02 Aug 8, 2023
bd4b401
Remove unnecessary empty line
RichDom2185 Aug 10, 2023
5c75726
resolving comments
clementlemon02 Aug 12, 2023
7a2a8d6
fix format
clementlemon02 Aug 12, 2023
1f21138
Delete unused component
RichDom2185 Sep 3, 2023
77687cd
Delete unused action
RichDom2185 Sep 3, 2023
768afd4
Remove grading CSV items
RichDom2185 Sep 3, 2023
3fefb11
Merge branch 'master' into llm-default-prompt
RichDom2185 Sep 3, 2023
cfedc60
Merge branch 'master' into llm-default-prompt
RichDom2185 Sep 4, 2023
49e56dd
Merge branch 'master' into llm-default-prompt
RichDom2185 Sep 9, 2023
9847732
Merge branch 'master' into llm-default-prompt
RichDom2185 Sep 11, 2023
5a160d1
Merge branch 'master' into llm-default-prompt
RichDom2185 Sep 17, 2023
52ebf71
Merge branch 'master' into llm-default-prompt
RichDom2185 Sep 25, 2023
343a500
Merge branch 'master' into llm-default-prompt
RichDom2185 Oct 19, 2023
8776aad
Merge branch 'master' into llm-default-prompt
RichDom2185 Oct 19, 2023
edb7179
Merge branch 'master' into llm-default-prompt
RichDom2185 Oct 25, 2023
9d43240
Merge branch 'master' into llm-default-prompt
RichDom2185 Nov 2, 2023
ba3faa7
Merge branch 'master' into llm-default-prompt
RichDom2185 Nov 2, 2023
80b73ce
Merge branch 'master' into llm-default-prompt
RichDom2185 Nov 6, 2023
02e91f8
Merge branch 'master' into llm-default-prompt
RichDom2185 Nov 29, 2023
ce686b4
Merge branch 'master' into llm-default-prompt
RichDom2185 Dec 8, 2023
7727ccd
Merge branch 'master' into llm-default-prompt
RichDom2185 Jan 9, 2024
30c448a
Merge branch 'master' into llm-default-prompt
RichDom2185 Jan 16, 2024
31c860f
Merge branch 'master' into llm-default-prompt
RichDom2185 Jan 25, 2024
13c0557
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Feb 5, 2024
e75a790
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 11, 2024
ad44717
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 11, 2024
3a837d9
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 12, 2024
d276616
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 13, 2024
90cf520
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 14, 2024
bf67bbf
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 14, 2024
c01f2b6
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 20, 2024
06002d5
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Feb 23, 2024
8bd90e3
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 23, 2024
5ba53a9
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 23, 2024
b8c413a
Merge branch 'master' into llm-default-prompt
RichDom2185 Feb 24, 2024
e855d4c
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Mar 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/commons/application/actions/__tests__/SessionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ test('setCourseConfiguration generates correct action object', () => {
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help text',
defaultLlmPrompt: 'defaul Llm Prompt',
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others']
};
const action = setCourseConfiguration(courseConfig);
Expand Down Expand Up @@ -656,6 +657,7 @@ test('updateCourseConfig generates correct action object', () => {
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help text',
defaultLlmPrompt: 'default LLM Prompt',
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others']
};
const action = updateCourseConfig(courseConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ test('SET_COURSE_CONFIGURATION works correctly', () => {
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help text',
defaultLlmPrompt: 'default LLM Prompt',
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others']
};
const action = {
Expand Down
2 changes: 2 additions & 0 deletions src/commons/application/types/SessionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type SessionState = {
readonly sourceChapter?: Chapter;
readonly sourceVariant?: Variant;
readonly moduleHelpText?: string;
readonly defaultLlmPrompt?: string;
readonly assetsPrefix?: string;

readonly assessmentConfigurations?: AssessmentConfiguration[];
Expand Down Expand Up @@ -164,6 +165,7 @@ export type CourseConfiguration = {
sourceChapter: Chapter;
sourceVariant: Variant;
moduleHelpText: string;
defaultLlmPrompt: string;
assetsPrefix: string;
};

Expand Down
37 changes: 36 additions & 1 deletion src/commons/dropdown/DropdownCreateCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const DropdownCreateCourse: React.FC<Props> = props => {
enableStories: false,
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: ''
moduleHelpText: '',
defaultLlmPrompt: ''
});

const [courseHelpTextSelectedTab, setCourseHelpTextSelectedTab] =
Expand Down Expand Up @@ -173,6 +174,40 @@ const DropdownCreateCourse: React.FC<Props> = props => {
)}
</FormGroup>

<FormGroup helperText="defaultLlmPrompt" labelFor="defaultLlmPrompt">
<Text tagName="span">Default LLM Prompt&nbsp;</Text>
<Text tagName="span" className="optional-text">
(optional)
</Text>
<Tabs
selectedTabId={courseHelpTextSelectedTab}
onChange={onChangeTabs}
className="module-help-text-tabs"
>
<Tab id={CourseHelpTextEditorTab.WRITE} title="Write" />
<Tab id={CourseHelpTextEditorTab.PREVIEW} title="Preview" />
</Tabs>
{courseHelpTextSelectedTab === CourseHelpTextEditorTab.WRITE && (
<TextArea
id="defaultLlmPrompt"
className="input-textarea"
fill={true}
value={courseConfig.defaultLlmPrompt}
onChange={e =>
setCourseConfig({
...courseConfig,
defaultLlmPrompt: e.target.value
})
}
/>
)}
{courseHelpTextSelectedTab === CourseHelpTextEditorTab.PREVIEW && (
<div className="input-markdown">
<Markdown content={courseConfig.defaultLlmPrompt || ''} openLinksInNewWindow />
</div>
)}
</FormGroup>

<div className="boolean-container">
<div>
<Switch
Expand Down
2 changes: 2 additions & 0 deletions src/commons/mocks/UserMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const mockCourseConfigurations: CourseConfiguration[] = [
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: '',
defaultLlmPrompt: '',
assetsPrefix: ''
},
{
Expand All @@ -147,6 +148,7 @@ export const mockCourseConfigurations: CourseConfiguration[] = [
sourceChapter: Chapter.SOURCE_2,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help Text!',
defaultLlmPrompt: 'Default LLM Prompt',
assetsPrefix: ''
}
];
Expand Down
6 changes: 5 additions & 1 deletion src/commons/sagas/__tests__/BackendSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ const mockCourseConfiguration1: CourseConfiguration = {
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help text',
defaultLlmPrompt: 'default LLM prompt',
assetsPrefix: ''
};

Expand Down Expand Up @@ -208,6 +209,7 @@ const mockCourseConfiguration2: CourseConfiguration = {
sourceChapter: Chapter.SOURCE_4,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help text',
defaultLlmPrompt: 'default LLM prompt',
assetsPrefix: ''
};

Expand Down Expand Up @@ -898,6 +900,7 @@ describe('Test UPDATE_COURSE_CONFIG action', () => {
sourceChapter: Chapter.SOURCE_4,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help',
defaultLlmPrompt: 'default LLM prompt',
assetsPrefix: ''
};

Expand Down Expand Up @@ -995,7 +998,8 @@ describe('Test CREATE_COURSE action', () => {
enableStories: false,
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help Text'
moduleHelpText: 'Help Text',
defaultLlmPrompt: 'default Llm prompt'
};
const user = mockUser;
const courseConfiguration = mockCourseConfiguration1;
Expand Down
3 changes: 2 additions & 1 deletion src/features/academy/__tests__/AcademyActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ test('createCourse generates correct action object', () => {
enableStories: false,
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: 'Help Text'
moduleHelpText: 'Help Text',
defaultLlmPrompt: 'default LLM prompt'
};

const action = createCourse(courseConfig);
Expand Down
1 change: 1 addition & 0 deletions src/pages/__tests__/localStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const mockShortDefaultState: SavedState = {
enableSourcecast: defaultState.session.enableSourcecast,
enableStories: defaultState.session.enableStories,
moduleHelpText: defaultState.session.moduleHelpText,
defaultLlmPrompt: defaultState.session.defaultLlmPrompt,
assetsPrefix: defaultState.session.assetsPrefix,
assessmentConfigurations: defaultState.session.assessmentConfigurations
},
Expand Down
6 changes: 4 additions & 2 deletions src/pages/academy/adminPanel/AdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const AdminPanel: React.FC = () => {
enableAchievements: true,
enableSourcecast: true,
enableStories: false,
moduleHelpText: ''
moduleHelpText: '',
defaultLlmPrompt: ''
});

const dispatch = useDispatch();
Expand Down Expand Up @@ -86,7 +87,8 @@ const AdminPanel: React.FC = () => {
enableAchievements: session.enableAchievements,
enableSourcecast: session.enableSourcecast,
enableStories: session.enableStories,
moduleHelpText: session.moduleHelpText
moduleHelpText: session.moduleHelpText,
defaultLlmPrompt: session.defaultLlmPrompt
});

// IMPT: To prevent mutation of props
Expand Down
Loading
Loading