MichielvanBeers / Flow.Launcher.Plugin.ChatGPT

MIT License
37 stars 5 forks source link

gpt-4 option #50

Closed networkabilityllc closed 5 months ago

networkabilityllc commented 5 months ago

I have been trying to get this to work with gpt-4 and getting:

15:34:43 ERROR (main.py): API returned 404 with message: {'error': {'message': 'The model gpt-4 does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

Just to verify that I have gpt-4 access I ran:

import requests

def list_available_models(api_key):
    url = "https://api.openai.com/v1/models"
    headers = {
        "Authorization": f"Bearer {api_key}"
    }

    response = requests.get(url, headers=headers)

    if response.status_code == 200:
        models = response.json().get('data', [])
        print("Available Models:")
        for model in models:
            print(model['id'])
    else:
        print(f"Error: {response.status_code}")
        print("Details:", response.text)

if __name__ == "__main__":
    your_api_key = "MY_API_KEY"
    list_available_models(your_api_key) 

And it returned:

Available Models:
gpt-3.5-turbo-1106
dall-e-3
whisper-1
dall-e-2
gpt-3.5-turbo-16k
text-embedding-ada-002
tts-1-hd-1106
tts-1-hd
gpt-3.5-turbo-instruct
davinci-002
babbage-002
gpt-4-0613
gpt-3.5-turbo-16k-0613
gpt-4-1106-preview
gpt-4
gpt-4-vision-preview
tts-1-1106
tts-1
gpt-3.5-turbo-instruct-0914
gpt-3.5-turbo
gpt-3.5-turbo-0301
gpt-3.5-turbo-0613

The only way I was able to get your plugin to work with gpt-4 is to change:

- type: dropdown
    attributes:
      name: model
      label: "Model:"
      defaultValue: gpt-3.5-turbo
      options:
        - gpt-3.5-turbo
        - gpt-4

to:

- type: dropdown
    attributes:
      name: model
      label: "Model:"
      defaultValue: gpt-4-0613
      options:
       - gpt-3.5-turbo
       - gpt-4-0613

I don't know if it is something that OpenAI changed in the endpoint, but no matter what I did, I was not able to use just gpt-4 as an option. I had to edit SettingsTemplate.yml

It works now, but I'm stumped.

Thanks for your excellent plugin!

MichielvanBeers commented 5 months ago

Hi @networkabilityllc, thanks for your feedback!

Could you confirm that you have access to the GPT-4 model if you go to the OpenAI API playground here?

Screenshot playground OpenAI

networkabilityllc commented 5 months ago

I do. I also verified using python and my API key (see above).

It works if I choose gpt-4-0613 but I get the 404 error if I choose gpt-4. So I just changed your SettingsTemplate.yml for now, and it works as long as it says:

- type: dropdown
    attributes:
      name: model
      label: "Model:"
      defaultValue: gpt-4-0613
      options:
       - gpt-3.5-turbo
       - gpt-4-0613

image

MichielvanBeers commented 5 months ago

Interesting indeed... I have added the model (plus some additional GPT-4 models such as the new 128k one) for now, so that should cover your issue. Might take an hour or so for the update to arrive in your Flowlauncher. Enjoy!