You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A new model for chatGPT has been released, but it uses a different endpoint. Here's some example code to get a result:
library(chatgpt)
library(httr)
library(jsonlite)
Sys.setenv(OPENAI_MODEL="gpt-3.5-turbo")
Sys.setenv(OPENAI_API_KEY= readLines("~/api_keys/openapi.txt"))
openai_api_key= Sys.getenv("OPENAI_API_KEY")
gpt_model= Sys.getenv("OPENAI_MODEL")
messages=list(
list(role="system", content="You are a helpful assistant."),
list(role="user", content="Who won the world series in 2020?"),
list(role="assistant", content="The Los Angeles Dodgers won the World Series in 2020."),
list(role="user", content="Where was it played?")
)
params=list(model=gpt_model,
messages=messages)
response<- content(
POST(
"https://api.openai.com/v1/chat/completions",
add_headers(Authorization= paste("Bearer",
openai_api_key)),
content_type_json(),
body= toJSON(params, auto_unbox=TRUE)
)
)
The text was updated successfully, but these errors were encountered:
A new model for chatGPT has been released, but it uses a different endpoint. Here's some example code to get a result:
The text was updated successfully, but these errors were encountered: