Closed cehio closed 1 year ago
Absolutely.
OpenAiService service = new OpenAiService(token, 55);
I also encountered this problem "java.net.SocketException: Connection reset" with HTTP response code 500
I think we need a api document about client
I also encountered this problem "java.net.SocketException: Connection reset" with HTTP response code 500
you can use OpenAiService service = new OpenAiService("token", Duration.ofSeconds(55));
Also, due to the popularity of ChatGPT, you do get random failures on the system. Make sure your http.getCode handles non-successful http codes.
What version are you using, I tried, but it didn't work
So whenever we receive a:
java.net.SocketTimeoutException: Read timed out
We can assume it's ChatGPT? Because we get these when running multiple threads, and the other threads are doing just fine.
They did recently change the concurrent call limits. Check for 429 status code on those.
https://community.openai.com/t/chatgpt-usage-limits/23920 https://help.openai.com/en/articles/6891829-error-code-429-rate-limit-reached-for-requests
All I am getting is a read timeout error. No error code from the chat completion call since it is throwing an exception. Is there a best practice for running this multi-threaded? I am creating multiple service objects, should I not be? Should I just have one service object?
Interesting, I've only used one service. I think you can run one service per key and it should be fine. I'll try to test multiple services in the same program, but it should be thread safe.
Just another thought. If you are using List or Array structures for loading/feeding messages or grabbing results, make sure that they are not being re-used. One technique is to use a guava concurrent hashmap on user, service, or conversation id. The other trick is to try to use a Java synchronized keyword on a method, lamda, or block of code to try to isolate if there is an issue.
Randomically I receive "java.net.sockettimeoutexception read timed out " Maybe chatgpt´s server is full and delays sending response. After 10 seconds with no answer a Timeout Exceptions appears. Could this time out be increased? This my code
String token = System.getenv("OPENAI_TOKEN"); ChatResponse = ""; OpenAiService service = new OpenAiService(token); Engine davinci = service.getEngine("text-davinci-003"); ArrayList storyArray = new ArrayList();
System.out.println("\nBrewing up a story...");
CompletionRequest completionRequest = CompletionRequest.builder()
.prompt(message)
.temperature(0.6) //0.9
.maxTokens(450)
.topP(1.0) //1.0
.frequencyPenalty(0.4) //0.0
.presencePenalty(0.1) //0.6
.build();
service.createCompletion("text-davinci-003", completionRequest).getChoices().forEach(line -> {
storyArray.add(line);
});
ChatResponse = storyArray.get(0).toString();