fix: publish session.error event for invalid model selection (#8451)
This commit is contained in:
@@ -321,7 +321,18 @@ export namespace SessionPrompt {
|
||||
history: msgs,
|
||||
})
|
||||
|
||||
const model = await Provider.getModel(lastUser.model.providerID, lastUser.model.modelID)
|
||||
const model = await Provider.getModel(lastUser.model.providerID, lastUser.model.modelID).catch((e) => {
|
||||
if (Provider.ModelNotFoundError.isInstance(e)) {
|
||||
const hint = e.data.suggestions?.length ? ` Did you mean: ${e.data.suggestions.join(", ")}?` : ""
|
||||
Bus.publish(Session.Event.Error, {
|
||||
sessionID,
|
||||
error: new NamedError.Unknown({
|
||||
message: `Model not found: ${e.data.providerID}/${e.data.modelID}.${hint}`,
|
||||
}).toObject(),
|
||||
})
|
||||
}
|
||||
throw e
|
||||
})
|
||||
const task = tasks.pop()
|
||||
|
||||
// pending subtask
|
||||
|
||||
Reference in New Issue
Block a user