Skip to content

Commit cdf7ce2

Browse files
move modelselector from status to its own file
1 parent cd848ee commit cdf7ce2

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useTranslation } from 'react-i18next'
2+
import { Box, Typography, MenuItem, FormControl, Select, SelectChangeEvent, InputLabel } from '@mui/material'
3+
import { FREE_MODEL } from '../../../config'
4+
5+
const ModelSelector = ({ currentModel, setModel, models }: { currentModel: string; setModel: (model: string) => void; models: string[] }) => {
6+
const { t } = useTranslation()
7+
8+
if (models.length === 1) {
9+
return (
10+
<Box style={{ marginBottom: 5 }}>
11+
<Typography variant="body1">
12+
{t('status:modelInUse')} <code>{models[0]}</code>
13+
</Typography>
14+
</Box>
15+
)
16+
}
17+
18+
return (
19+
<Box mb={2}>
20+
<FormControl sx={{ width: '200px' }}>
21+
<InputLabel>{t('status:modelInUse')}</InputLabel>
22+
<Select label={t('status:modelInUse')} value={currentModel} onChange={(event: SelectChangeEvent) => setModel(event.target.value)}>
23+
{models.map((model) => (
24+
<MenuItem key={model} value={model}>
25+
{model}
26+
</MenuItem>
27+
))}
28+
</Select>
29+
</FormControl>
30+
</Box>
31+
)
32+
}
33+
34+
35+
36+
export default ModelSelector

src/client/components/Chat/Status.tsx

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,7 @@
11
import { useTranslation } from 'react-i18next'
22
import { Box, Typography, MenuItem, FormControl, Select, SelectChangeEvent, InputLabel } from '@mui/material'
33
import { FREE_MODEL } from '../../../config'
4-
5-
const ModelSelector = ({ currentModel, setModel, models }: { currentModel: string; setModel: (model: string) => void; models: string[] }) => {
6-
const { t } = useTranslation()
7-
8-
if (models.length === 1) {
9-
return (
10-
<Box style={{ marginBottom: 5 }}>
11-
<Typography variant="body1">
12-
{t('status:modelInUse')} <code>{models[0]}</code>
13-
</Typography>
14-
</Box>
15-
)
16-
}
17-
18-
return (
19-
<Box mb={2}>
20-
<FormControl sx={{ width: '200px' }}>
21-
<InputLabel>{t('status:modelInUse')}</InputLabel>
22-
<Select label={t('status:modelInUse')} value={currentModel} onChange={(event: SelectChangeEvent) => setModel(event.target.value)}>
23-
{models.map((model) => (
24-
<MenuItem key={model} value={model}>
25-
{model}
26-
</MenuItem>
27-
))}
28-
</Select>
29-
</FormControl>
30-
</Box>
31-
)
32-
}
4+
import ModelSelector from './ModelSelector';
335

346
const Status = ({ model, setModel, models, usage, limit }: { model: string; setModel: (model: string) => void; models: string[]; usage: number; limit: number }) => {
357
const { t } = useTranslation()

0 commit comments

Comments
 (0)