From 70aa9f5f79962cc047edbf116b71365167e702fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=82=85=E5=93=A5?= <184172133@qq.com> Date: Tue, 23 Jan 2024 08:24:11 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Av1.1=20test=5Fcompletions=5Fsync=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../model/ChatCompletionSyncResponse.java | 24 +++++++++++++++++++ .../cn/bugstack/chatglm/test/ApiTest.java | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1976f50..debd457 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.bugstack chatglm-sdk-java - 2.0 + 2.1 chatglm-sdk-java OpenAI Java SDK, ZhiPuAi ChatGLM Java SDK . Copyright © 2023 bugstack虫洞栈 All rights reserved. 版权所有(C)小傅哥 https://github.com/fuzhengwei/chatglm-sdk-java diff --git a/src/main/java/cn/bugstack/chatglm/model/ChatCompletionSyncResponse.java b/src/main/java/cn/bugstack/chatglm/model/ChatCompletionSyncResponse.java index 485f972..dc0e675 100644 --- a/src/main/java/cn/bugstack/chatglm/model/ChatCompletionSyncResponse.java +++ b/src/main/java/cn/bugstack/chatglm/model/ChatCompletionSyncResponse.java @@ -6,6 +6,7 @@ import java.util.List; /** * 同步调用响应 + * * @author max * @date 2023/12/14 15:41 */ @@ -17,6 +18,17 @@ public class ChatCompletionSyncResponse { private Boolean success; private ChatGLMData data; + // 24年1月发布模型新增字段 GLM3、GLM4 + private String task_status; + private List choices; + + public void setChoices(List choices) { + this.choices = choices; + this.data = new ChatGLMData(); + this.data.setChoices(choices); + } + + @Data public static class ChatGLMData { private List choices; @@ -35,6 +47,18 @@ public class ChatCompletionSyncResponse { @Data public static class Choice { + + private String role; + private String content; + + // 24年1月发布模型新增字段 GLM3、GLM4 + private String finish_reason; + private int index; + private Message message; + } + + @Data + public static class Message { private String role; private String content; } diff --git a/src/test/java/cn/bugstack/chatglm/test/ApiTest.java b/src/test/java/cn/bugstack/chatglm/test/ApiTest.java index f0d7224..0be80a9 100644 --- a/src/test/java/cn/bugstack/chatglm/test/ApiTest.java +++ b/src/test/java/cn/bugstack/chatglm/test/ApiTest.java @@ -283,7 +283,7 @@ public class ApiTest { public void test_completions_sync() throws Exception { // 入参;模型、请求信息 ChatCompletionRequest request = new ChatCompletionRequest(); - request.setModel(Model.GLM_4V); // chatGLM_6b_SSE、chatglm_lite、chatglm_lite_32k、chatglm_std、chatglm_pro + request.setModel(Model.GLM_3_5_TURBO); // chatGLM_6b_SSE、chatglm_lite、chatglm_lite_32k、chatglm_std、chatglm_pro request.setPrompt(new ArrayList() { private static final long serialVersionUID = -7988151926241837899L; -- GitLab