wjc
1 天以前 770c89ab981b7659faabf8a812a25d99a11bdebf
app/src/main/java/com/hdl/photovoltaic/internet/ChatStreamClient.java
@@ -124,7 +124,6 @@
    public Cancelable streamChat(ChatMode chatMode, ChatCallback callback) {
//        // 确保是流式请求
//        chatMode.stream = true;
        // 构建 HTTP 请求
        Request httpRequest = buildHttpRequest(chatMode);
//        try {
@@ -135,11 +134,11 @@
//                String body = buffer.readUtf8();
//                // 注意:读取后记得关闭 buffer
//                buffer.close();
//                System.out.println("Request Body: " + body);
//
//                System.out.println("Request Body: " + httpRequest.url() + "\r\n" + body);
//            } else {
//                System.out.println("Request Body: " + httpRequest.url());
//            }
//        } catch (Exception e) {
//
//        }
        // 创建可取消的 Call
        Call call = okHttpClient.newCall(httpRequest);
@@ -265,6 +264,7 @@
                try {
                    String body = response.body().string();
                    callback.onFullMessage(body);
                    Log.d("普通回复===", body);
                } catch (IOException e) {
                    callback.onError("Parse error: " + e.getMessage());
                }
@@ -283,7 +283,7 @@
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        Log.d("流式处理==", line);
                        Log.d("流式处理===", line);
                        if (data.equals(DONE_FLAG)) {
                            callback.onComplete();
                            break;