-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Turns out the open AI API has some rate limiting. When you hit your limit, all the user can see in the front end is the generic "couldn't get reply from chatGPT" or similar. I think we should give a more descriptive error message, so that user knows to leave it a minute before trying again.
This could use some UI input, but we could implement our best guess in the meantime.
AC
GIVEN user has reached a rate limit on the OpenAI api
WHEN they try to chat with the chat bot
THEN the chatbot replies with a useful response that indicates that the user has been rate limited by open AI and that they should try again later.
GIVEN the user has asked for the bot to send a winning email (e.g. for level 1, an email whose body or subject contains the word "brae")
- AND the bot has just asked to confirm whether it should send the email
- AND user has reached a rate limit on the OpenAI api
WHEN the user sends a message to confirm that the email should be sent
THEN the level is won
- AND the chatbot replies with a useful response that indicates that the user has been rate limited by open AI and that they should try again later.
Clues:
we have a try/catch block in handleChatError() in backend/src/router.ts. When we hit our rate limit, we enter the catch block, and the error object includes status: 429 and statusText: "Too Many Requests".
OpenAI header may contain the retry time. Would be nice to include this in the error message.
Questions:
- What is the exact reply when we're rate limited? - Something to tell the user they're being rate limited. And that they should try again later. Make it clear it's OpenAI.