paradigmxyz / flux

Graph-based LLM power tool for exploring many completions in parallel.
https://flux.paradigm.xyz
MIT License
781 stars 105 forks source link

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

Open Hey opened 1 year ago

Hey commented 1 year ago

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.

Hey commented 1 year ago

good first issue imo

transmissions11 commented 1 year ago

fosho— def has confused some ppl

AdamSchinzel commented 1 year ago

I can take this.

I was also thinking about the options that are there. I would say that we need to check it every time not only when used firstly pastes API key or later changed it because if initially his API didn't have access to GPT-4 but later on they were granted access, we may not be aware of that.

I think it will be also nice to only disable it in the list of option and provide link where to join the waitlist.

transmissions11 commented 1 year ago

nice, this all sounds right to me, though i lean towards reducing complexity wherever possible — so maybe we dont block off GPT-4 in the dropdown but just check when they select it, and show a toast or something saying "you don't have access to this model, click here to sign up for the waitlist" etc?

AdamSchinzel commented 1 year ago

Sounds great!

I will also add check that if someone without access to GPT-4 but with GPT-4 selected will automatically roll on GPT-3.5-turbo.

AdamSchinzel commented 1 year ago

Just want to let I will have time to work on this on weekend, if someone wants he can pick it up

nmandal commented 1 year ago

@AdamSchinzel happy to take this one over if you haven't started working on it yet!