paradigmxyz/flux

fix: error handling if user has no access to gpt4 yet

Open

#26 opened on Mar 31, 2023

 (7 comments) (1 reaction) (0 assignees)TypeScript (130 forks)github user discovery
good first issue

Repository metrics

Stars
 (892 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

The problem

At the moment, GPT4 rollout isn't available for everyone yet, if an API key is used that does not have access yet we should at least show something.

Error when calling model

{
    "error": {
        "message": "The model: `gpt-4` does not exist",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

Multiple ways to fix:

  1. We check if the error is error.code = model_not_found and display a message telling the user to switch because they don't have access yet. But this requires us to implement some general error
  2. When supplying an API key we call https://api.openai.com/v1/models which returns the available models and we lock GPT4 if it isn't in this list and lock it if is.
  3. When switching models we call https://api.openai.com/v1/models to see if this key has access to GPT4 and lock the model switch in settings.

2 and 3 can maybe be done in combination because if a user gets access while they already had supplied the key on Flux they would have to switch api keys for it to refetch this information.

Contributor guide