We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用流式客户端时报错: Exception in thread "OkHttp Dispatcher" java.lang.NoSuchFieldError: instance
猜测原因可能是OkHttp的依赖版本问题 请问应该使用哪个版本的OkHttp
maven依赖
<!-- openai-java --> <dependency> <groupId>com.unfbx</groupId> <artifactId>chatgpt-java</artifactId> <version>1.1.5</version> </dependency> <!-- okhttp --> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.5.0</version> </dependency> <dependency> <groupId>com.squareup.okio</groupId> <artifactId>okio</artifactId> <version>3.9.0</version> </dependency>
测试代码
//国内访问需要做代理,国外服务器不需要 Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10809));//代理ip,端口 OkHttpClient okHttpClient = new OkHttpClient .Builder() //自定义代理 .proxy(proxy) .connectTimeout(30, TimeUnit.SECONDS)//自定义超时时间 .writeTimeout(30, TimeUnit.SECONDS)//自定义超时时间 .readTimeout(30, TimeUnit.SECONDS)//自定义超时时间 .build(); OpenAiStreamClient openAiClient = OpenAiStreamClient.builder() .apiKey(Arrays.asList(OPEN_AI_KEY)) .okHttpClient(okHttpClient) .build(); ContentKeywordsPrompt prompt = new ContentKeywordsPrompt(); prompt.setContent("你好"); log.info("本次提示词: \n {}", prompt.build()); //聊天模型:gpt-3.5 Message message = Message.builder().role(Message.Role.USER).content(prompt.build()).build(); ChatCompletion chatCompletion = ChatCompletion.builder().messages(Arrays.asList(message)).build(); ConsoleEventSourceListener eventSourceListener = new ConsoleEventSourceListener(); openAiClient.streamChatCompletion(chatCompletion, eventSourceListener); CountDownLatch countDownLatch = new CountDownLatch(1); try { countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); }
报错详情
Exception in thread "OkHttp Dispatcher" java.lang.NoSuchFieldError: instance at okhttp3.internal.sse.RealEventSource.processResponse(RealEventSource.java:77) at okhttp3.internal.sse.RealEventSource.onResponse(RealEventSource.java:56) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用流式客户端时报错: Exception in thread "OkHttp Dispatcher" java.lang.NoSuchFieldError: instance
猜测原因可能是OkHttp的依赖版本问题 请问应该使用哪个版本的OkHttp
maven依赖
测试代码
报错详情
The text was updated successfully, but these errors were encountered: