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
@LukasWallrich, this feature was actually in the development version. But there are a couple of pitfalls that require care. Please see an example below with commented points:
remotes::install_github("irudnyts/openai", ref = "r6")
library(openai)
client <- OpenAI()
completion <- client$chat$completions$create(
model = "gpt-3.5-turbo-1106", # ☝️ must be either "gpt-4-1106-preview" or "gpt-3.5-turbo-1106"
messages = list(list("role" = "user", "content" = "What's up? Answer in JSON.")), # ☝️ You must include something like the answer should be in JSON
response_format = list("type" = "json_object")
)
completion$choices[[1]]$message$content
It would be great to use JSON mode, yet even with the development version, I don't see how to pass that parameter. Could that maybe be added?
https://platform.openai.com/docs/guides/text-generation/json-mode
The text was updated successfully, but these errors were encountered: