mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-23 06:00:17 +09:00
Merge pull request #5444 from skymkmk/pr-fix-model-config-hydration
fix: config hydration and default model forced to set gpt-3.5-turbo
This commit is contained in:
commit
d51bbb4a81
@ -204,8 +204,8 @@ export const useAccessStore = createPersistStore(
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
// Set default model from env request
|
// Set default model from env request
|
||||||
let defaultModel = res.defaultModel ?? "";
|
let defaultModel = res.defaultModel ?? "";
|
||||||
DEFAULT_CONFIG.modelConfig.model =
|
if (defaultModel !== "")
|
||||||
defaultModel !== "" ? defaultModel : "gpt-3.5-turbo";
|
DEFAULT_CONFIG.modelConfig.model = defaultModel;
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.then((res: DangerConfig) => {
|
.then((res: DangerConfig) => {
|
||||||
|
@ -143,6 +143,21 @@ export const useAppConfig = createPersistStore(
|
|||||||
{
|
{
|
||||||
name: StoreKey.Config,
|
name: StoreKey.Config,
|
||||||
version: 4,
|
version: 4,
|
||||||
|
|
||||||
|
merge(persistedState, currentState) {
|
||||||
|
const state = persistedState as ChatConfig | undefined;
|
||||||
|
if (!state) return { ...currentState };
|
||||||
|
const models = currentState.models.slice();
|
||||||
|
state.models.forEach((pModel) => {
|
||||||
|
const idx = models.findIndex(
|
||||||
|
(v) => v.name === pModel.name && v.provider === pModel.provider,
|
||||||
|
);
|
||||||
|
if (idx !== -1) models[idx] = pModel;
|
||||||
|
else models.push(pModel);
|
||||||
|
});
|
||||||
|
return { ...currentState, ...state, models: models };
|
||||||
|
},
|
||||||
|
|
||||||
migrate(persistedState, version) {
|
migrate(persistedState, version) {
|
||||||
const state = persistedState as ChatConfig;
|
const state = persistedState as ChatConfig;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user