Skip to content

Commit c0b0c1f

Browse files
committed
no need for these extra constants
1 parent e620207 commit c0b0c1f

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

src/client/components/Prompt/PromptEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
Typography,
1717
CircularProgress,
1818
} from '@mui/material'
19-
import { DEFAULT_RAG_SYSTEM_MESSAGE, validModels } from '@config'
19+
import { validModels } from '@config'
2020
import { useTranslation } from 'react-i18next'
2121
import type { RagIndexAttributes } from '@shared/types'
2222
import { useCreatePromptMutation, useEditPromptMutation } from '../../hooks/usePromptMutation'
@@ -41,7 +41,7 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
4141
const [name, setName] = useState<string>(prompt?.name ?? '')
4242
const [systemMessage, setSystemMessage] = useState<string>(prompt?.systemMessage ?? '')
4343
const [ragSystemMessage, setRagSystemMessage] = useState<string>(() =>
44-
prompt ? prompt.messages?.find((m) => m.role === 'system')?.content || '' : t(DEFAULT_RAG_SYSTEM_MESSAGE),
44+
prompt ? prompt.messages?.find((m) => m.role === 'system')?.content || '' : t('prompt:defaultRagMessage'),
4545
)
4646
const [hidden, setHidden] = useState<boolean>(prompt?.hidden ?? false)
4747
const [mandatory, setMandatory] = useState<boolean>(prompt?.mandatory ?? false)
@@ -196,7 +196,7 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
196196
<OpenableTextfield
197197
value={ragSystemMessage}
198198
onChange={(e) => setRagSystemMessage(e.target.value)}
199-
onAppend={(text) => setRagSystemMessage(prev => prev + (prev.trim().length ? ' ' : '') + text)}
199+
onAppend={(text) => setRagSystemMessage((prev) => prev + (prev.trim().length ? ' ' : '') + text)}
200200
slotProps={{
201201
htmlInput: { 'data-testid': 'rag-system-message-input' },
202202
}}
@@ -228,7 +228,7 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId, setEdit
228228
</Box>
229229

230230
<DialogActions>
231-
{loading && <CircularProgress color='secondary' />}
231+
{loading && <CircularProgress color="secondary" />}
232232
<BlueButton disabled={loading} type="submit" variant="contained" sx={{ mt: 2 }}>
233233
{t('common:save')}
234234
</BlueButton>
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
1-
import { Accordion, AccordionDetails, AccordionSummary, Box, TextField, TextFieldProps } from '@mui/material'
2-
import { DEFAULT_RAG_SYSTEM_MESSAGE, ENFORCE_RAG_SYSTEM_MESSAGE, UNKNOWN_RAG_SYSTEM_MESSAGE } from '@config'
1+
import { Box, TextField, type TextFieldProps } from '@mui/material'
32
import { GrayButton } from '../ChatV2/general/Buttons'
4-
import AddIcon from '@mui/icons-material/Add';
5-
import { t } from 'i18next';
3+
import AddIcon from '@mui/icons-material/Add'
4+
import { t } from 'i18next'
65

76
type OpenableTextfieldProps = TextFieldProps & {
87
onAppend: (text: string) => void
98
}
109

1110
const OpenableTextfield = ({ onAppend, ...props }: OpenableTextfieldProps) => {
12-
1311
return (
1412
<Box sx={{ mb: 2 }}>
1513
<TextField sx={{ mb: 0 }} {...props} fullWidth />
1614
<Box sx={{ display: 'flex', gap: 1, mt: 1, width: '100%' }}>
17-
<GrayButton size="small" endIcon={<AddIcon />} onClick={() => onAppend(t(DEFAULT_RAG_SYSTEM_MESSAGE))}>
18-
{t("prompt:defaultRagLabel")}
15+
<GrayButton size="small" endIcon={<AddIcon />} onClick={() => onAppend(t('prompt:defaultRagMessage'))}>
16+
{t('prompt:defaultRagLabel')}
1917
</GrayButton>
20-
<GrayButton size="small" endIcon={<AddIcon />} onClick={() => onAppend(t(ENFORCE_RAG_SYSTEM_MESSAGE))}>
21-
{t("prompt:enforceRagLabel")}
18+
<GrayButton size="small" endIcon={<AddIcon />} onClick={() => onAppend(t('prompt:enforceRagMessage'))}>
19+
{t('prompt:enforceRagLabel')}
2220
</GrayButton>
23-
<GrayButton size="small" endIcon={<AddIcon />} onClick={() => onAppend(t(UNKNOWN_RAG_SYSTEM_MESSAGE))}>
24-
{t("prompt:unknownRagLabel")}
21+
<GrayButton size="small" endIcon={<AddIcon />} onClick={() => onAppend(t('prompt:unknownRagMessage'))}>
22+
{t('prompt:unknownRagLabel')}
2523
</GrayButton>
2624
</Box>
2725
</Box>
2826
)
2927
}
3028

31-
32-
export default OpenableTextfield
29+
export default OpenableTextfield

src/config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ Put math in $$ ... $$ for LaTeX rendering.
2828
Wrap code in triple backticks with the correct language tag (js, ts, py, etc.) so syntax highlighting and rendering work.
2929
`
3030

31-
// EXAMPLE: with localize translation -> t(DEFAULT_RAG_SYSTEM_MESSAGE)
32-
export const DEFAULT_RAG_SYSTEM_MESSAGE = 'prompt:defaultRagMessage'
33-
export const ENFORCE_RAG_SYSTEM_MESSAGE = 'prompt:enforceRagMessage'
34-
export const UNKNOWN_RAG_SYSTEM_MESSAGE = 'prompt:unknownRagMessage'
35-
3631
/**
3732
* name: the acual model name, which is shown to users, configures the model to be used and is also the azure deployment name.
3833
*/

0 commit comments

Comments
 (0)