Closed 1603411588 closed 1 year ago
Message message = Message.builder().role(Message.Role.USER).content(content).build(); ChatCompletion chatCompletion = ChatCompletion.builder().messages(Arrays.asList(message)).build(); ChatCompletionResponse chatCompletionResponse = openAiClient.chatCompletion(chatCompletion); chatCompletionResponse.getChoices().forEach(e -> { System.out.println(e.getMessage()); });
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: unexpected end of stream on https://api.openai.com/... at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:93) at io.reactivex.Single.blockingGet(Single.java:2870) at com.unfbx.chatgpt.OpenAiClient.chatCompletion(OpenAiClient.java:658) at com.yilop.bys.digital.service.OpenAiApi.chat(OpenAiApi.java:52) at com.yilop.bys.digital.service.OpenAiApi.main(OpenAiApi.java:60) Caused by: java.io.IOException: unexpected end of stream on https://api.openai.com/... at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:210) at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:110) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at com.unfbx.chatgpt.interceptor.DefaultOpenAiAuthInterceptor.intercept(DefaultOpenAiAuthInterceptor.java:45) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at com.unfbx.chatgpt.interceptor.OpenAiResponseInterceptor.intercept(OpenAiResponseInterceptor.java:27) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at retrofit2.OkHttpCall.execute(OkHttpCall.java:204) at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:46) at io.reactivex.Observable.subscribe(Observable.java:12284) at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:35) at io.reactivex.Observable.subscribe(Observable.java:12284) at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35) at io.reactivex.Single.subscribe(Single.java:3666) at io.reactivex.Single.blockingGet(Single.java:2869) ... 3 more Caused by: java.io.EOFException: \n not found: limit=0 content=… at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:332) at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29) at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:180) ... 30 more