fix: handle undefined model in createMessagePair function (#20663)
- Add a null check when looking up model to prevent JavaScript error when trying to add a message pair in a chat with an invalid/corrupt model ID.
This commit is contained in:
@@ -1282,6 +1282,11 @@
|
|||||||
const modelId = selectedModels[0];
|
const modelId = selectedModels[0];
|
||||||
const model = $models.filter((m) => m.id === modelId).at(0);
|
const model = $models.filter((m) => m.id === modelId).at(0);
|
||||||
|
|
||||||
|
if (!model) {
|
||||||
|
toast.error($i18n.t('Model not found'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const messages = createMessagesList(history, history.currentId);
|
const messages = createMessagesList(history, history.currentId);
|
||||||
const parentMessage = messages.length !== 0 ? messages.at(-1) : null;
|
const parentMessage = messages.length !== 0 ? messages.at(-1) : null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user