Grt1228 / chatgpt-java

ChatGPT Java SDK支持流式输出、Gpt插件、联网。支持OpenAI官方所有接口。ChatGPT的Java客户端。OpenAI GPT-3.5-Turb GPT-4 Api Client for Java
https://chatgpt-java.unfbx.com
Apache License 2.0
3.34k stars 816 forks source link

ChatCompletion 使用 stream 时,报错。不用 stream 就正常。 #138

Closed iszhouhuabo closed 1 year ago

iszhouhuabo commented 1 year ago
image

错误信息:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'data': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 5]] with root cause com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'data': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 5]

Grt1228 commented 1 year ago

使用stream时候使用OpenAiStreamClient

如果两个都用的话建议实例化两个Client,使用同一个OkHttpClient