Skip to content

Commit

Permalink
Merge pull request #5444 from skymkmk/pr-fix-model-config-hydration
Browse files Browse the repository at this point in the history
fix: config hydration and default model forced to set gpt-3.5-turbo
  • Loading branch information
Dogtiti authored Sep 18, 2024
2 parents 848f794 + 36a0c7b commit d51bbb4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/store/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ export const useAccessStore = createPersistStore(
.then((res) => {
// Set default model from env request
let defaultModel = res.defaultModel ?? "";
DEFAULT_CONFIG.modelConfig.model =
defaultModel !== "" ? defaultModel : "gpt-3.5-turbo";
if (defaultModel !== "")
DEFAULT_CONFIG.modelConfig.model = defaultModel;
return res;
})
.then((res: DangerConfig) => {
Expand Down
15 changes: 15 additions & 0 deletions app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ export const useAppConfig = createPersistStore(
{
name: StoreKey.Config,
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) {
const state = persistedState as ChatConfig;

Expand Down

0 comments on commit d51bbb4

Please sign in to comment.