paradigmxyz/flux

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

開放

#26 建立於 2023年3月31日

 (7 則留言) (1 個反應) (0 位負責人)TypeScript (130 個分叉)github user discovery
good first issue

倉庫指標

星標
 (892 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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.

貢獻者指南