From 33d5ebdc08fe3ec0db03a2ebf36020edd238fb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=82=85=E5=93=A5?= <184172133@qq.com> Date: Mon, 3 Jun 2024 07:14:37 +0800 Subject: [PATCH] =?UTF-8?q?docs=EF=BC=9AmaxTokens=20=3D=201024;=20?= =?UTF-8?q?=E5=AE=98=E7=BD=91=E6=9C=80=E5=A4=A7=E5=80=BC=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/curl/curl-glm-4v.sh | 2 +- .../chatglm/model/ChatCompletionRequest.java | 2 +- .../java/cn/bugstack/chatglm/test/ApiTest.java | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/curl/curl-glm-4v.sh b/docs/curl/curl-glm-4v.sh index 25e5357..d85a416 100644 --- a/docs/curl/curl-glm-4v.sh +++ b/docs/curl/curl-glm-4v.sh @@ -1,6 +1,6 @@ # url 支持base64和图片地址;https://bugstack.cn/images/article/project/chatgpt/chatgpt-extra-231011-01.png curl -X POST \ - -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsInNpZ25fdHlwZSI6IlNJR04ifQ.eyJhcGlfa2V5IjoiNjJkZGVjMzhiMWQwYjlhN2IwZmRkYWYyNzFlNmVkOTAiLCJleHAiOjE3MDU4MDgxNDEwNDUsInRpbWVzdGFtcCI6MTcwNTgwNjM0MTA0NX0.o7kogP0ZIFWVEEhplGaW1zBz16B1UbG2NIEqb7ZVflU" \ + -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsInNpZ25fdHlwZSI6IlNJR04ifQ.eyJhcGlfa2V5IjoiMzk1ODBlMzRlMTc1MDE5YzIzMGZkZDUxOTgxN2IzODEiLCJleHAiOjE3MTczNzE2MzE4MDgsInRpbWVzdGFtcCI6MTcxNzM2OTgzMTgwOH0.2lk57oALzFxx2eAo-dKojKnVpn_MvJ8VJ4NQWTMYPHQ" \ -H "Content-Type: application/json" \ -H "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)" \ -d '{ diff --git a/src/main/java/cn/bugstack/chatglm/model/ChatCompletionRequest.java b/src/main/java/cn/bugstack/chatglm/model/ChatCompletionRequest.java index 1dc83d5..9d154d9 100644 --- a/src/main/java/cn/bugstack/chatglm/model/ChatCompletionRequest.java +++ b/src/main/java/cn/bugstack/chatglm/model/ChatCompletionRequest.java @@ -70,7 +70,7 @@ public class ChatCompletionRequest { * 24年1月发布的 GLM_3_5_TURBO、GLM_4 模型时新增 */ @JsonProperty("max_tokens") - private Integer maxTokens = 2048; + private Integer maxTokens = 1024; /** * 模型在遇到stop所制定的字符时将停止生成,目前仅支持单个停止词,格式为["stop_word1"] * 24年1月发布的 GLM_3_5_TURBO、GLM_4 模型时新增 diff --git a/src/test/java/cn/bugstack/chatglm/test/ApiTest.java b/src/test/java/cn/bugstack/chatglm/test/ApiTest.java index cef643f..7415afd 100644 --- a/src/test/java/cn/bugstack/chatglm/test/ApiTest.java +++ b/src/test/java/cn/bugstack/chatglm/test/ApiTest.java @@ -40,7 +40,7 @@ public class ApiTest { // 1. 配置文件 Configuration configuration = new Configuration(); configuration.setApiHost("https://open.bigmodel.cn/"); - configuration.setApiSecretKey("74e0b7fff9a578e2137300bcd58ae062.q0ABClJJS50rHQnn"); + configuration.setApiSecretKey("39580e34e175019c230fdd519817b381.*****"); configuration.setLevel(HttpLoggingInterceptor.Level.BODY); // 2. 会话工厂 OpenAiSessionFactory factory = new DefaultOpenAiSessionFactory(configuration); @@ -125,7 +125,7 @@ public class ApiTest { // 入参;模型、请求信息 ChatCompletionRequest request = new ChatCompletionRequest(); - request.setModel(Model.GLM_4); // GLM_3_5_TURBO、GLM_4 + request.setModel(Model.GLM_4V); // GLM_3_5_TURBO、GLM_4 request.setIsCompatible(false); // 24年1月发布的 glm-3-turbo、glm-4 支持函数、知识库、联网功能 request.setTools(new ArrayList() { @@ -196,10 +196,10 @@ public class ApiTest { { // content 字符串格式 - add(ChatCompletionRequest.Prompt.builder() - .role(Role.user.getCode()) - .content("这个图片写了什么") - .build()); +// add(ChatCompletionRequest.Prompt.builder() +// .role(Role.user.getCode()) +// .content("这个图片写了什么") +// .build()); // content 对象格式 add(ChatCompletionRequest.Prompt.builder() @@ -348,7 +348,7 @@ public class ApiTest { // 1. 配置文件 Configuration configuration = new Configuration(); configuration.setApiHost("https://open.bigmodel.cn/"); - configuration.setApiSecretKey("62ddec38b1d0b9a7b0fddaf271e6ed90.HpD0SUBUlvqd05ey"); + configuration.setApiSecretKey("39580e34e175019c230fdd519817b381.*****"); // 2. 获取Token String token = BearerTokenUtils.getToken(configuration.getApiKey(), configuration.getApiSecret()); -- GitLab