Skip to content

Commit 6d27846

Browse files
animalnotsDmitri Nasonov
andauthored
A: Added warning in case user is trying to import a chat with unknown model (#112)
R: QoL Co-authored-by: Dmitri Nasonov <[email protected]>
1 parent c38b79c commit 6d27846

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "better-chatgpt",
33
"private": true,
4-
"version": "1.25.0",
4+
"version": "1.26.0",
55
"type": "module",
66
"homepage": "./",
77
"main": "electron/index.cjs",
@@ -26,6 +26,10 @@
2626
{
2727
"name": "nm723",
2828
"url": "https://github.com/nm723"
29+
},
30+
{
31+
"name": "ReignOfComputer",
32+
"url": "https://github.com/ReignOfComputer"
2933
}
3034
],
3135
"description": "Play and chat smarter with BetterChatGPT - an amazing open-source web app with a better UI for exploring OpenAI's ChatGPT API!",

public/locales/en/import.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"successfulImport": "Successfully imported!",
99
"nothingImported": "No data has been imported",
1010
"unrecognisedDataFormat": "Unrecognised data format. Supported formats are: BetterGPT export, OpenAI export, OpenAI Playground (JSON)",
11-
"chatsImported": "{{imported}} chats were imported out of {{total}}."
11+
"chatsImported": "{{imported}} chats were imported out of {{total}}.",
12+
"unsupportedModels": "Unsupported model(s): {{models}} are not available. Add them in Settings → Custom Models before importing."
1213
},
1314
"reduceMessagesSuccess": "{{count}} messages were reduced.",
1415
"partialImportMessages": "expected {{total}} messages but found {{count}}"

src/components/ImportExportChat/ImportChat.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,38 @@ import {
1313
validateExportV1,
1414
} from '@utils/import';
1515

16+
import { modelOptions } from '@constants/modelLoader';
17+
18+
// Helper to detect and warn about unknown model IDs referenced in imported chats
19+
const warnUnsupportedModels = (
20+
chats: any[],
21+
t: (key: string, opts?: any) => string
22+
) => {
23+
const unsupportedModels = Array.from(
24+
new Set(
25+
chats
26+
.map((c: any) => c?.config?.model)
27+
.filter(
28+
(id: string | undefined) =>
29+
id && !modelOptions.includes(id)
30+
)
31+
)
32+
);
33+
34+
if (unsupportedModels.length > 0) {
35+
toast.warning(
36+
t('notifications.unsupportedModels', {
37+
ns: 'import',
38+
models: unsupportedModels.join(', '),
39+
}) ||
40+
`Unsupported model(s): ${unsupportedModels.join(', ')}. Please add them in Settings → Custom Models before importing.`,
41+
{ autoClose: 15000 }
42+
);
43+
return true;
44+
}
45+
return false;
46+
};
47+
1648
import { ChatInterface, Folder, FolderCollection } from '@type/chat';
1749
import { ExportBase } from '@type/export';
1850
import { toast } from 'react-toastify';
@@ -175,6 +207,9 @@ const ImportChat = () => {
175207
};
176208
}
177209
} else {
210+
// Validate unsupported model IDs and inform user
211+
warnUnsupportedModels(chatsToImport, t);
212+
178213
return {
179214
success: false,
180215
message: t('notifications.invalidChatsDataFormat', {

0 commit comments

Comments
 (0)