irudnyts / openai

An R package-wrapper around OpenAI API
https://irudnyts.github.io/openai/
Other
164 stars 28 forks source link

Support for GPT-4? #43

Open gexijin opened 1 year ago

gexijin commented 1 year ago

Currently it does not seem to work for GPT-4 api.

irudnyts commented 1 year ago

Can you please verify that you have access to GPT-4? It seems that the model is in beta and only limited access is provided (see https://platform.openai.com/docs/models/gpt-4).

gexijin commented 1 year ago

Yes, I can confirm. But you do not need to have gpt-4 to try that. You can test on ChatGPT (gpt-3.5-turbo).

It seems that OpenAI has two types of models, completion models (text-davinci-003) and Chat models (gpt-3.5-turbo, gpt-4). The API URL and syntax are different between these two. Your package seems to work well with completion models. But not chat models. https://platform.openai.com/docs/models/model-endpoint-compatibility

RoyalTS commented 1 year ago

create_chat_completion() works perfectly well for me with model='gpt-4'.

irudnyts commented 1 year ago

@gexijin Have you been able to find the solution?

gexijin commented 1 year ago

I haven't tried what @RoyalTS said. But as of now, I used httr to directly talk to OpenAI.

jmouchnino commented 1 year ago

create_chat_completion() works perfectly well for me with model='gpt-4'.

It doesn't work for me and I have a ChatGPT plus subscription.

Error in match.arg(model) : 
  'arg' should be one of “gpt-3.5-turbo”, “gpt-3.5-turbo-0301”
gexijin commented 1 year ago

@jmouchnino Among ChatGPT plus subscribers, very few have gpt-4 API access.

irudnyts commented 9 months ago

@jmouchnino @gexijin well, the thing is I do not event have match.arg(model) line in my code.

Anyways, I am developing a new version, to be in line with OpenAI. You can install it via remotes::install_github("irudnyts/openai", ref = "r6") and play around like that:

library(openai)
client <- OpenAI()
completion <- client$chat$completions$create(
    model = "gpt-4-1106-preview",
    messages = list(list("role" = "user", "content" = "What's up?"))
)

completion$choices[[1]]$message$content

Please let me know if it does not work.