baidubce / bce-qianfan-sdk

Provide best practices for LMOps, as well as elegant and convenient access to the features of the Qianfan MaaS Platform. (提供大模型工具链最佳实践,以及优雅且便捷地访问千帆大模型平台)
https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html
Apache License 2.0
331 stars 50 forks source link

流式对话异常 NoSuchElementException #471

Closed jackdeng1202 closed 5 months ago

jackdeng1202 commented 7 months ago

System Info

  1. qianfan version -0.0.2
  2. System Version -java8 -android 9.0
  3. language - kotlin

Reproduction

  1. implementation "com.baidubce:qianfan:0.0.2"

  2. call api:

           val iterator = qianfan.chatCompletion()
                    .model("ERNIE-Bot-4") 
                    .temperature(0.7)
                    .addMessage("user", "hello")
                    .executeStream()
            while (iterator.hasNext()) {
                var chunk = iterator.next()
                Log.i(TAG, "result: " + chunk)
            }
  3. See error:

    java.util.NoSuchElementException at com.baidubce.qianfan.util.http.SSEWrapper$1.next(SSEWrapper.java:59) at com.baidubce.qianfan.util.http.SSEWrapper$1.next(SSEWrapper.java:30) at com.baidubce.qianfan.QianfanClient$StreamIterator.next(QianfanClient.java:118)

Azure99 commented 7 months ago

请先更新到0.0.4版本,然后使用非流式发起请求,检查下报错