Skip to content

Commit 78e57d4

Browse files
committed
Remove everything related to mandatory prompts
1 parent d3debcc commit 78e57d4

File tree

11 files changed

+27
-51
lines changed

11 files changed

+27
-51
lines changed

src/client/components/ChatV2/PromptSelector.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { DeleteOutline, KeyboardArrowDown, Lock, AutoAwesome } from '@mui/icons-material'
1+
import { DeleteOutline, KeyboardArrowDown, AutoAwesome } from '@mui/icons-material'
22
import { Box, Divider, IconButton, ListSubheader, Menu, MenuItem } from '@mui/material'
33
import { useState } from 'react'
44
import { useTranslation } from 'react-i18next'
55
import type { Prompt } from '../../types'
66
import { OutlineButtonBlack } from './general/Buttons'
77
import { usePromptState } from './PromptState'
88

9-
const PromptSelector = ({ sx = {}, handleDeletePrompt }: { sx?: object; handleDeletePrompt?: (prompt: Prompt) => void }) => {
10-
const { activePrompt, handleChangePrompt, mandatoryPrompt, coursePrompts, myPrompts } = usePromptState()
9+
const PromptSelector = ({ handleDeletePrompt }: { sx?: object; handleDeletePrompt?: (prompt: Prompt) => void }) => {
10+
const { activePrompt, handleChangePrompt, coursePrompts, myPrompts } = usePromptState()
1111

1212
const { t } = useTranslation()
1313

@@ -29,11 +29,10 @@ const PromptSelector = ({ sx = {}, handleDeletePrompt }: { sx?: object; handleDe
2929
sx={{ width: '100%' }}
3030
startIcon={<AutoAwesome />}
3131
data-testid={`prompt-selector-button`}
32-
disabled={!!mandatoryPrompt}
3332
onClick={(event) => {
3433
setAnchorEl(event.currentTarget)
3534
}}
36-
endIcon={mandatoryPrompt ? <Lock /> : <KeyboardArrowDown />}
35+
endIcon={<KeyboardArrowDown />}
3736
>
3837
<Box sx={{
3938
overflow: 'hidden',

src/client/components/ChatV2/PromptState.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ interface PromptSelectorStateType {
2323
handleChangePrompt: (newPrompt: Prompt | undefined) => void
2424
coursePrompts: Prompt[]
2525
myPrompts: Prompt[]
26-
mandatoryPrompt: Prompt | undefined
2726
urlPrompt: Prompt | undefined
2827
isPromptHidden: boolean
2928
isPromptEditable: boolean
@@ -62,7 +61,6 @@ export const PromptStateProvider: React.FC<{
6261
const [customSystemMessage, setCustomSystemMessage] = useLocalStorageState<string>(`${localStoragePrefix}-chat-instructions`, '')
6362
const [activePrompt, setActivePrompt] = useLocalStorageState<Prompt | undefined>(`${localStoragePrefix}-active-prompt`, undefined)
6463

65-
const mandatoryPrompt = course?.prompts.find((p) => p.mandatory)
6664
const urlPrompt = course?.prompts.find((p) => p.id === urlPromptId)
6765
const isPromptHidden = activePrompt?.hidden ?? false
6866
const isPromptEditable = activePrompt === undefined || activePrompt?.type === 'PERSONAL'
@@ -116,15 +114,6 @@ export const PromptStateProvider: React.FC<{
116114
})
117115
}, [activePrompt?.id])
118116

119-
// If there is a mandatory prompt, change to that.
120-
useEffect(() => {
121-
if (mandatoryPrompt) {
122-
handleChangePrompt(mandatoryPrompt)
123-
} else if (urlPrompt) {
124-
handleChangePrompt(urlPrompt)
125-
}
126-
}, [mandatoryPrompt, urlPrompt])
127-
128117
const ownPromptSaveMutation = useMutation({
129118
mutationFn: async ({ name, promptToSave, systemMessage }: { name: string; promptToSave?: Prompt; systemMessage: string }) => {
130119
if (promptToSave && promptToSave.type !== 'PERSONAL') return // Only do this for personal prompts
@@ -173,7 +162,6 @@ export const PromptStateProvider: React.FC<{
173162
handleChangePrompt,
174163
coursePrompts: course?.prompts || [],
175164
myPrompts,
176-
mandatoryPrompt,
177165
urlPrompt,
178166
promptInfo,
179167
isPromptHidden,

src/client/components/Courses/Course/Prompt.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Box, Paper, Typography, Button, Tooltip, IconButton, Link } from '@mui/material'
2-
import { Visibility, VisibilityOff, PriorityHigh, ContentCopyOutlined, Delete, DeleteOutline, Book, BookOutlined, MenuBookOutlined } from '@mui/icons-material'
1+
import { Box, Paper, Typography, Tooltip, IconButton, Link } from '@mui/material'
2+
import { Visibility, VisibilityOff, ContentCopyOutlined, DeleteOutline, MenuBookOutlined } from '@mui/icons-material'
33
import { useTranslation } from 'react-i18next'
44

55
import { enqueueSnackbar } from 'notistack'
@@ -14,7 +14,7 @@ const Prompt = ({ prompt, handleEdit }: { prompt: PromptType; handleEdit: () =>
1414
const { t } = useTranslation()
1515
const { id: courseId } = useParams()
1616

17-
const { id, name, hidden, mandatory, ragIndexId } = prompt
17+
const { id, name, hidden, ragIndexId } = prompt
1818

1919
const chatPath = `/${courseId}?promptId=${id}`
2020
const directLink = `${window.location.origin}${PUBLIC_URL}/${chatPath}`
@@ -48,13 +48,6 @@ const Prompt = ({ prompt, handleEdit }: { prompt: PromptType; handleEdit: () =>
4848
</Tooltip>
4949
)}
5050
</Box>
51-
{mandatory && (
52-
<Box display="inline" mr={2}>
53-
<Tooltip title="Alustus on pakollinen opiskelijoille">
54-
<PriorityHigh />
55-
</Tooltip>
56-
</Box>
57-
)}
5851
{ragIndexId && (
5952
<Box display="inline" mr={2}>
6053
<Tooltip title={t('rag:sourceMaterials')}>

src/client/components/Prompt/PromptEditor.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
4444
prompt ? prompt.messages?.find((m) => m.role === 'system')?.content || '' : t('prompt:defaultRagMessage'),
4545
)
4646
const [hidden, setHidden] = useState<boolean>(prompt?.hidden ?? false)
47-
const [mandatory, setMandatory] = useState<boolean>(prompt?.mandatory ?? false)
4847
const [ragIndexId, setRagIndexId] = useState<number | undefined | null>(prompt?.ragIndexId)
4948

5049
const [selectedModel, setModel] = useState<ValidModelName | 'none'>(prompt?.model ?? 'none')
@@ -78,7 +77,6 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
7877
systemMessage,
7978
messages,
8079
hidden,
81-
mandatory,
8280
ragIndexId,
8381
model,
8482
temperature,
@@ -93,7 +91,6 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
9391
systemMessage,
9492
messages,
9593
hidden,
96-
mandatory,
9794
ragIndexId,
9895
model,
9996
temperature,
@@ -134,10 +131,6 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
134131
margin="normal"
135132
/>
136133
<FormControlLabel control={<Checkbox checked={hidden} onChange={(e) => setHidden(e.target.checked)} />} label={t('prompt:hidePrompt')} />
137-
<FormControlLabel
138-
control={<Checkbox checked={mandatory} onChange={(e) => setMandatory(e.target.checked)} />}
139-
label={t('prompt:editMandatoryPrompt')}
140-
/>
141134
<FormControl fullWidth margin="normal">
142135
<InputLabel>{t('common:model')}</InputLabel>
143136
<Select value={selectedModel || ''} onChange={(e) => setModel(e.target.value as ValidModelName | 'none')}>

src/client/locales/en.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@
291291
"totalUsageToolTip": "Total tokens consumed over the lifetime of the course. This value never resets.",
292292
"usageChartTitle": "Student token usages as percentages",
293293
"noData": "No data",
294-
"oneMandatoryPrompt": "Course can have only one mandatory prompt",
295294
"noCourses": "No courses",
296295
"showActiveCourses": "Show active courses",
297296
"isSavedOptOut": "The course discussions will be saved anonymously, if you grant permission to save. Saved discussions can be used for research purposes.",
@@ -317,7 +316,6 @@
317316
"modelFreeToChoose": "Model free to choose",
318317
"systemMessage": "Instructions for the language model",
319318
"hidePrompt": "Hide prompt text from students",
320-
"editMandatoryPrompt": "Make prompt mandatory",
321319
"noSourceMaterials": "No source materials",
322320
"ragSystemMessage": "Source material instructions",
323321
"basicInformation": "Basic information",

src/client/locales/fi.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@
292292
"totalUsageToolTip": "Tokenien kokonaismäärä koko kurssin ajalta. Tämä arvo ei koskaan nollaudu.",
293293
"usageChartTitle": "Opiskelijoiden käytetyt tokenit prosenttiosuutena käyttörajasta",
294294
"noData": "Ei dataa",
295-
"editMandatoryPrompt": "Tee alustuksesta pakollinen opiskelijoille",
296-
"oneMandatoryPrompt": "Kurssilla voi olla vain yksi pakollinen alustus",
297295
"noCourses": "Ei näytettäviä kursseja",
298296
"showActiveCourses": "Näytä aktiiviset kurssit",
299297
"isSavedOptOut": "Kurssilla käymäsi keskustelut tallennetaan anonyymisti, jos annat tallennusluvan.\nTallennettuja keskusteluja voidaan käyttää tutkimuksessa.",
@@ -319,7 +317,6 @@
319317
"modelFreeToChoose": "Malli vapaasti valittavissa",
320318
"systemMessage": "Kielimallin ohjeistus",
321319
"hidePrompt": "Piilota alustuksen sisältö opiskelijoilta",
322-
"editMandatoryPrompt": "Tee alustuksesta pakollinen",
323320
"noSourceMaterials": "Ei lähdemateriaaleja",
324321
"ragSystemMessage": "Lähdemateriaaliohjeistus",
325322
"basicInformation": "Perustiedot",

src/client/locales/sv.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@
257257
"totalUsageToolTip": "Totalt antal tokens som använts under hela kursen. Detta värde nollställs aldrig.",
258258
"usageChartTitle": "Studenttokenanvändning i procent",
259259
"noData": "Inga data",
260-
"editMandatoryPrompt": "Gör en uppmaning obligatorisk",
261-
"oneMandatoryPrompt": "Kursen kan endast ha en obligatorisk uppmaning",
262260
"noCourses": "Inga kurser att visa",
263261
"percentageUsed": "Andel använda polletter",
264262
"howToActive": "Välj de kurser jag undervisar om du vill aktivera kurschatten",
@@ -296,7 +294,6 @@
296294
"modelFreeToChoose": "Modell fri att välja",
297295
"systemMessage": "Instruktioner för språkmodellen",
298296
"hidePrompt": "Dölj prompttext för studenter",
299-
"editMandatoryPrompt": "Gör prompt obligatorisk",
300297
"noSourceMaterials": "Inga källmaterial",
301298
"ragSystemMessage": "Instruktioner för källmaterial",
302299
"basicInformation": "Grundläggande information",

src/client/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export type Prompt = {
4747
systemMessage: string
4848
messages: ChatMessage[]
4949
hidden: boolean
50-
mandatory: boolean
5150
type: 'CHAT_INSTANCE' | 'PERSONAL'
5251
createdAt: string
5352
ragIndexId?: number
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { DataTypes } from 'sequelize'
2+
3+
import { Migration } from '../connection'
4+
5+
export const up: Migration = async ({ context: queryInterface }) => {
6+
await queryInterface.removeColumn('prompts', 'mandatory')
7+
await queryInterface.addColumn('prompts', 'mandatory', {
8+
type: DataTypes.BOOLEAN,
9+
allowNull: false,
10+
defaultValue: false,
11+
})
12+
}
13+
14+
export const down: Migration = async ({ context: queryInterface }) => {
15+
await queryInterface.addColumn('prompts', 'mandatory', {
16+
type: DataTypes.BOOLEAN,
17+
allowNull: false,
18+
defaultValue: false,
19+
})
20+
}

src/server/db/models/prompt.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class Prompt extends Model<InferAttributes<Prompt>, InferCreationAttributes<Prom
2727

2828
declare hidden: CreationOptional<boolean>
2929

30-
declare mandatory: CreationOptional<boolean>
31-
3230
declare model?: CreationOptional<ValidModelName>
3331

3432
declare temperature?: CreationOptional<number>
@@ -82,11 +80,6 @@ Prompt.init(
8280
allowNull: false,
8381
defaultValue: false,
8482
},
85-
mandatory: {
86-
type: DataTypes.BOOLEAN,
87-
allowNull: false,
88-
defaultValue: false,
89-
},
9083
model: {
9184
type: DataTypes.STRING,
9285
allowNull: true,

0 commit comments

Comments
 (0)