Skip to content

Commit

Permalink
Improve openai error message
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Jun 4, 2024
1 parent 44d5d8a commit bce5126
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bioimageio_chatbot/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,14 @@ <h3 class="text-center">Welcome to BioImage.IO Chatbot</h3>
}
catch (e) {
// generate an error message to simulate how Melman from Madagascar would respond to an error
let details = "Oh no! I'm sorry, an unexpected error occurred. Please try again. \n\n<details class='details-box'> <summary>🔍More Details</summary>\n\n"
// let's split the error message and check if the starts with `openai`
// if yes, let's say that it's likely to be an error caused by the malfunction of the OpenAI server

let details = "Oh no! I'm sorry, an unexpected error occurred."
if (`${e}`.includes('openai.')) {
details += " It seems that the OpenAI server is malfunctioning. Please try again later."
}
details += " \n\n<details class='details-box'> <summary>🔍More Details</summary>\n\n"
details += `The server reported the following error:\n\n`;
details += `\`\`\`\n${e}\n\`\`\`\n\n`;
if(`${e}`.includes('model_not_found')){
Expand Down

0 comments on commit bce5126

Please sign in to comment.