Skip to content

Commit

Permalink
Migrate gpt-4-turbo-preview to gpt-4-turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
tristandostaler authored Jun 3, 2024
1 parent a1ef8ca commit 167287f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/constants/stateVersion.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const stateVersion: number = 13;
const stateVersion: number = 14;

export default stateVersion;
19 changes: 19 additions & 0 deletions src/store/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
FolderCollection,
LocalStorageInterfaceV0ToV1,
LocalStorageInterfaceV12ToV13,
LocalStorageInterfaceV13ToV14,
LocalStorageInterfaceV1ToV2,
LocalStorageInterfaceV2ToV3,
LocalStorageInterfaceV3ToV4,
Expand Down Expand Up @@ -134,4 +135,22 @@ export const migrateV13 = (persistedState: LocalStorageInterfaceV12ToV13) => {
}
})
});
};

export const migrateV14 = (persistedState: LocalStorageInterfaceV13ToV14) => {
persistedState.chats.forEach((chat) => {
if(chat.config.model.toString() == "gpt-4-turbo-preview") {
chat.config.model = 'gpt-4-turbo';
}
});
if(persistedState.defaultChatConfig.model.toString() == "gpt-4-turbo-preview") {
persistedState.defaultChatConfig.model = 'gpt-4-turbo';
}
persistedState.prompts.forEach((prompt) => {
prompt.prompt = prompt.prompt.replaceAll("~ Model: gpt-4-turbo-preview ~", "~ Model: gpt-4-turbo ~")
});

persistedState.publicPrompts.forEach((prompt) => {
prompt.prompt = prompt.prompt.replaceAll("~ Model: gpt-4-turbo-preview ~", "~ Model: gpt-4-turbo ~")

Check failure on line 154 in src/store/migrate.ts

View workflow job for this annotation

GitHub Actions / build

Property 'prompt' does not exist on type 'PublicPrompt'.

Check failure on line 154 in src/store/migrate.ts

View workflow job for this annotation

GitHub Actions / build

Property 'prompt' does not exist on type 'PublicPrompt'.
});
};
5 changes: 5 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
LocalStorageInterfaceV8ToV9,
LocalStorageInterfaceV8ToV12,
LocalStorageInterfaceV12ToV13,
LocalStorageInterfaceV13ToV14,
} from '@type/chat';
import {
migrateV0,
Expand All @@ -31,6 +32,7 @@ import {
migrateV8,
migrateV12,
migrateV13,
migrateV14,
} from './migrate';
import stateVersion from '@constants/stateVersion';
import { createPublicPromptSlice, PublicPromptSlice } from './public-prompt-sync-slice';
Expand Down Expand Up @@ -120,6 +122,9 @@ const useStore = create<StoreState>()(
case 12:
migrateV13(persistedState as LocalStorageInterfaceV12ToV13);
break;
case 13:
migrateV14(persistedState as LocalStorageInterfaceV13ToV14);
break;
}
return persistedState as StoreState;
},
Expand Down
3 changes: 3 additions & 0 deletions src/types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ export interface LocalStorageInterfaceV12ToV13
extends LocalStorageInterfaceV8ToV12 {
}

export interface LocalStorageInterfaceV13ToV14
extends LocalStorageInterfaceV12ToV13 {
}

0 comments on commit 167287f

Please sign in to comment.