irudnyts / openai

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

connection timeout #42

Open Links996 opened 1 year ago

Links996 commented 1 year ago

What should I do for this? Error in curl::curl_fetch_memory(url, handle = handle) : Timeout was reached: [api.openai.com] Connection timeout after 10007 ms

irudnyts commented 1 year ago

@Links996 It seems to be a problem on the server side. Can you please provide a minimal reproducible example? Thanks!

CorradoLanera commented 5 months ago

@irudnyts , similar issue here. image Is it possible to set the waiting time to a larger value? I am using the following settings:

    model = "gpt-4-turbo-preview",
    temperature = 0,
    max_tokens = NULL,

and a prompt of ~4k tokens / 15k characters. It doesn't happen every time, so maybe set a larger waiting time could be enough; anyway there are other prompts that possibly takes minutes without any issues. No error occurred with gpt-3.5-turbo! Very strange behavior.

Thank you, Corrado.

stevepowell99 commented 4 months ago

exactly the same issue here. intermittent. even with very low / trivial usage; nothing to do with rate limits.

irudnyts commented 4 months ago

@CorradoLanera, you use an outdated version. Please use the following code:

remotes::install_github("irudnyts/openai", ref = "r6")

library(openai)
client <- OpenAI()
completion <- client$chat$completions$create(
    model = "gpt-3.5-turbo",
    messages = list(list("role" = "user", "content" = "What's up?"))
)
irudnyts commented 4 months ago

@stevepowell99 Two questions: 1/ Does official Python package throws the same error? 2/ Can you please prepare a reproducible example? Thanks!

CorradoLanera commented 4 months ago

I used the updated version; tryed both the API. And forked trying to fix the issue. The issue happened in R only, with all the packages, with tirwct call using httr, or whatever other tool. It works, using the python official package through reticulate. I will prepare a reprex (the often eill reprex because the issue happend almost always, but not "always").

CorradoLanera commented 4 months ago

ps: itndoes not happen with 3.5-turbo, but only with 4/-turbo

taiwankyh commented 4 months ago

I got the same issue with create_transcription, error as "curl::curl_fetch_memory(url, handle = handle): Timeout was reached: [api.openai.com] SSL/TLS connection timeout"

Is there any way to adjust the timeout in the package as the python code (However, I can't use python)

CorradoLanera commented 1 month ago

this seems to solve the issue to me. IF it works and can solve the issue, could it be added as an optional argument or hardcode a higher value (as I did 😂 😁 )?