Closed Ugleh closed 2 years ago
There's no way to modify anything within OpenAiService
, so if you want to increase any timeouts, you'll have to make your own OkHttpClient
and Retrofit
instances. Just copy the OpenAiService
constructor code and modify the OkHttpClient
as shown here https://www.baeldung.com/okhttp-timeouts#read
I have the same problem. Is it possible to simply have a setTimeout() method somewhere in the api ?
@TheoKanning Thank you for this toolkit. This is really useful.
If you can make the OpenAiApi public that would fix it or else just create a getter and setter for OpenAiApi api in OpenAiService?
I'm using the api-0.6.0.jar and cleint-0.6.0.jar so would prefer not to have to have another code copy if i could avoid it.
Just more info. After switching to text-davinci-002, it takes more time than the default timeout about 60% of the time.
I ended up just importing the project as a gradle project into eclipse and set the dependency. I still think it'd be useful to have a parameter or to be able to access the api object directly to set it, but my problem is solved.
Thank you again!
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new AuthenticationInterceptor(token))
.connectionPool(new ConnectionPool(8, 42, TimeUnit.SECONDS))
.connectTimeout(42, TimeUnit.SECONDS)
.readTimeout(42, TimeUnit.SECONDS)
.writeTimeout(42, TimeUnit.SECONDS)
.build();
@gbolcer you beat me to it haha. I just added a timeout option to fix this.
I also added much easier way to provide your own OpenAiApi in case you want to customize something else without copying the entire OpenAiService.
Version 0.7.0 with the changes will be available very soon
Thank you all for pointing this out to me! Version 0.7.0 is live with the new timeout parameter, marking as closed :+1:
Again, kudos for the api. This is extremely useful.
Randomly, unbeknownst to me, I get a SocketTimeoutExeption during some executions for createCompletion. I don't know how to increase the connection timeout for OpenAiService and was wondering if I could get some advice, thanks.