Skip to content

Commit c57bb6d

Browse files
committed
When setting model and checking localStorage, also update localStorage accordingly
1 parent 4332187 commit c57bb6d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/client/components/Chat/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { enqueueSnackbar } from 'notistack'
55
import { useTranslation } from 'react-i18next'
66
import { useParams } from 'react-router-dom'
77

8-
import { validModels } from '../../../config'
8+
import { validModels, DEFAULT_MODEL } from '../../../config'
99
import { Message, Prompt, SetState } from '../../types'
1010
import { getCompletionStream } from './util'
1111
import Banner from '../Banner'
@@ -56,10 +56,14 @@ function usePersistedState<T>(key: string, defaultValue: T): [T, SetState<T>] {
5656
}
5757

5858
const allowedModels = validModels.map((m) => m.name) // [gpt-4, gpt-4o, gpt-4o-mini] 22.8.2024
59-
console.log('allowedModels:', allowedModels)
59+
6060
const getInitialModel = () => {
6161
const storedModel = localStorage.getItem('model')
62-
return allowedModels.includes(storedModel) ? storedModel : 'gpt-4o'
62+
if (allowedModels.includes(storedModel)) {
63+
return storedModel
64+
}
65+
localStorage.setItem('model', DEFAULT_MODEL)
66+
return DEFAULT_MODEL
6367
}
6468

6569
const Chat = () => {

0 commit comments

Comments
 (0)