From 27690e8dd70f0af4102a9baa1f9c3522421e7d3b Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sun, 28 Sep 2025 14:29:59 +0800 Subject: [PATCH 1/6] feat: support glm-4.6 model --- .../main/java/ai/z/openapi/core/Constants.java | 15 +++++++++++++++ .../service/model/ChatCompletionCreateParams.java | 13 ++++++------- .../ChatCompletionExample.java | 2 +- .../ChatCompletionStreamExample.java | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/ai/z/openapi/core/Constants.java b/core/src/main/java/ai/z/openapi/core/Constants.java index ed8d492..e77f55a 100644 --- a/core/src/main/java/ai/z/openapi/core/Constants.java +++ b/core/src/main/java/ai/z/openapi/core/Constants.java @@ -35,6 +35,21 @@ private Constants() { // Text Generation Models // ============================================================================= + /** + * GLM-4.6 model code + */ + public static final String ModelGLM4_6 = "glm-4.6"; + + /** + * GLM-4.6-air model code + */ + public static final String ModelGLM4_6_AIR = "glm-4.6-air"; + + /** + * GLM-4.6-flash model code + */ + public static final String ModelGLM4_6_FLASH = "glm-4.6-flash"; + /** * GLM-4.5 model code */ diff --git a/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java b/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java index adcd712..44d4234 100644 --- a/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java +++ b/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java @@ -43,7 +43,7 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR /** * Sampling temperature, controls output randomness, must be positive Range: - * (0.0,1.0], cannot equal 0, default value is 0.95 Higher values make output more + * [0.0,1.0] default value is 0.95 Higher values make output more * random and creative; lower values make output more stable or deterministic It's * recommended to adjust either top_p or temperature parameter based on your use case, * but not both simultaneously @@ -51,12 +51,11 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR private Float temperature; /** - * Another method for temperature sampling, called nucleus sampling Range: (0.0, 1.0) - * open interval, cannot equal 0 or 1, default value is 0.7 Model considers results - * with top_p probability mass tokens For example: 0.1 means the model decoder only - * considers tokens from the top 10% probability candidate set It's recommended to - * adjust either top_p or temperature parameter based on your use case, but not both - * simultaneously + * Another method for temperature sampling, called nucleus sampling Range: (0.0, 1.0] + * Model considers results with top_p probability mass tokens For example: 0.1 means + * the model decoder only considers tokens from the top 10% probability candidate set + * It's recommended to adjust either top_p or temperature parameter based on your use + * case, but not both simultaneously */ @JsonProperty("top_p") private Float topP; diff --git a/samples/src/main/ai.z.openapi.samples/ChatCompletionExample.java b/samples/src/main/ai.z.openapi.samples/ChatCompletionExample.java index 127b6f2..423c93f 100644 --- a/samples/src/main/ai.z.openapi.samples/ChatCompletionExample.java +++ b/samples/src/main/ai.z.openapi.samples/ChatCompletionExample.java @@ -25,7 +25,7 @@ public static void main(String[] args) { // Create chat request ChatCompletionCreateParams request = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4_5) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) diff --git a/samples/src/main/ai.z.openapi.samples/ChatCompletionStreamExample.java b/samples/src/main/ai.z.openapi.samples/ChatCompletionStreamExample.java index e573a48..afa5352 100644 --- a/samples/src/main/ai.z.openapi.samples/ChatCompletionStreamExample.java +++ b/samples/src/main/ai.z.openapi.samples/ChatCompletionStreamExample.java @@ -18,7 +18,7 @@ public static void main(String[] args) { // Create chat request ChatCompletionCreateParams streamRequest = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4_5) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) From 17511db6db3bd977a50ea2f4b32dd029b272c923 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sun, 28 Sep 2025 14:32:10 +0800 Subject: [PATCH 2/6] feat: support glm-4.6 model --- README.md | 6 +++--- README_CN.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c7e4a77..0d1d2c3 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ ZaiClient client = ZaiClient.builder() // Create chat request ChatCompletionCreateParams request = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) @@ -152,7 +152,7 @@ if (response.isSuccess()) { ```java // Create streaming request ChatCompletionCreateParams streamRequest = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) @@ -281,7 +281,7 @@ public class AIController { @PostMapping("/chat") public ResponseEntity chat(@RequestBody ChatRequest request) { ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) diff --git a/README_CN.md b/README_CN.md index 481941b..eb6c99f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -123,7 +123,7 @@ ZaiClient client = ZaiClient.builder() // 创建对话请求 ChatCompletionCreateParams request = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) @@ -151,7 +151,7 @@ if (response.isSuccess()) { ```java // 创建流式请求 ChatCompletionCreateParams streamRequest = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) @@ -282,7 +282,7 @@ public class AIController { @PostMapping("/chat") public ResponseEntity chat(@RequestBody ChatRequest request) { ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) From bb0acde0d6e255a5b22411dd8782f49accf44b74 Mon Sep 17 00:00:00 2001 From: haiyang679 <2496085873@qq.com> Date: Mon, 29 Sep 2025 16:06:36 +0800 Subject: [PATCH 3/6] search stream tool calls --- .../z/openapi/service/model/ChatCompletionCreateParams.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java b/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java index 44d4234..dc05100 100644 --- a/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java +++ b/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java @@ -117,6 +117,11 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR */ private ChatThinking thinking; + /** + * Whether to stream tool calls + */ + private Boolean tool_stream; + /** * Forced watermark switch */ From 4ab569b8bd7c68f6d48325ec6bd3820d8371667f Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Mon, 29 Sep 2025 17:07:05 +0800 Subject: [PATCH 4/6] feat: support glm-4.6 model --- .../main/ai.z.openapi.samples/ChatAsyncCompletionExample.java | 2 +- .../ChatCompletionWithCustomHeadersExample.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/src/main/ai.z.openapi.samples/ChatAsyncCompletionExample.java b/samples/src/main/ai.z.openapi.samples/ChatAsyncCompletionExample.java index 6b2ff83..2af9aef 100644 --- a/samples/src/main/ai.z.openapi.samples/ChatAsyncCompletionExample.java +++ b/samples/src/main/ai.z.openapi.samples/ChatAsyncCompletionExample.java @@ -30,7 +30,7 @@ public static void main(String[] args) { // Create chat request ChatCompletionCreateParams request = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4_5) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) diff --git a/samples/src/main/ai.z.openapi.samples/ChatCompletionWithCustomHeadersExample.java b/samples/src/main/ai.z.openapi.samples/ChatCompletionWithCustomHeadersExample.java index dc3f917..ff51652 100644 --- a/samples/src/main/ai.z.openapi.samples/ChatCompletionWithCustomHeadersExample.java +++ b/samples/src/main/ai.z.openapi.samples/ChatCompletionWithCustomHeadersExample.java @@ -22,7 +22,7 @@ public static void main(String[] args) { // Create chat request ChatCompletionCreateParams request = ChatCompletionCreateParams.builder() - .model(Constants.ModelChatGLM4_5) + .model("glm-4.6") .messages(Arrays.asList( ChatMessage.builder() .role(ChatMessageRole.USER.value()) From 7bd078b5de98a949aad1b75af4773e506cc2a0e3 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Tue, 30 Sep 2025 14:36:18 +0800 Subject: [PATCH 5/6] feat: support glm-4.6 model --- README.md | 4 ++-- README_CN.md | 4 ++-- .../java/ai/z/openapi/core/token/HttpRequestInterceptor.java | 2 +- pom.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0d1d2c3..fc13bcf 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Add the following dependency to your `pom.xml`: ai.z.openapi zai-sdk - 0.0.5 + 0.0.6 ``` @@ -39,7 +39,7 @@ Add the following dependency to your `build.gradle` (for Groovy DSL): ```groovy dependencies { - implementation 'ai.z.openapi:zai-sdk:0.0.5' + implementation 'ai.z.openapi:zai-sdk:0.0.6' } ``` diff --git a/README_CN.md b/README_CN.md index eb6c99f..7def537 100644 --- a/README_CN.md +++ b/README_CN.md @@ -30,7 +30,7 @@ Z.ai AI 平台官方 Java SDK,提供统一接口访问强大的AI能力,包 ai.z.openapi zai-sdk - 0.0.5 + 0.0.6 ``` @@ -39,7 +39,7 @@ Z.ai AI 平台官方 Java SDK,提供统一接口访问强大的AI能力,包 ```groovy dependencies { - implementation 'ai.z.openapi:zai-sdk:0.0.5' + implementation 'ai.z.openapi:zai-sdk:0.0.6' } ``` diff --git a/core/src/main/java/ai/z/openapi/core/token/HttpRequestInterceptor.java b/core/src/main/java/ai/z/openapi/core/token/HttpRequestInterceptor.java index e87e0d9..3432a08 100644 --- a/core/src/main/java/ai/z/openapi/core/token/HttpRequestInterceptor.java +++ b/core/src/main/java/ai/z/openapi/core/token/HttpRequestInterceptor.java @@ -40,7 +40,7 @@ public Response intercept(Chain chain) throws IOException { .newBuilder() .header("Authorization", "Bearer " + accessToken) .header("x-source-channel", source_channel) - .header("Zai-SDK-Ver", "0.0.5") + .header("Zai-SDK-Ver", "0.0.6") .header("Accept-Language", "en-US,en"); if (Objects.nonNull(config.getCustomHeaders())) { for (Map.Entry entry : config.getCustomHeaders().entrySet()) { diff --git a/pom.xml b/pom.xml index 3324568..3e46f03 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ - 0.0.5.1 + 0.0.6 8 UTF-8 UTF-8 From 51aff419b9f9d391fdaeb9971438e54366ee3863 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Tue, 30 Sep 2025 14:36:33 +0800 Subject: [PATCH 6/6] feat: support glm-4.6 model --- .../java/ai/z/openapi/core/Constants.java | 28 +++++++++---------- .../model/ChatCompletionCreateParams.java | 23 ++++++++------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/ai/z/openapi/core/Constants.java b/core/src/main/java/ai/z/openapi/core/Constants.java index e77f55a..12557b3 100644 --- a/core/src/main/java/ai/z/openapi/core/Constants.java +++ b/core/src/main/java/ai/z/openapi/core/Constants.java @@ -35,20 +35,20 @@ private Constants() { // Text Generation Models // ============================================================================= - /** - * GLM-4.6 model code - */ - public static final String ModelGLM4_6 = "glm-4.6"; - - /** - * GLM-4.6-air model code - */ - public static final String ModelGLM4_6_AIR = "glm-4.6-air"; - - /** - * GLM-4.6-flash model code - */ - public static final String ModelGLM4_6_FLASH = "glm-4.6-flash"; + /** + * GLM-4.6 model code + */ + public static final String ModelGLM4_6 = "glm-4.6"; + + /** + * GLM-4.6-air model code + */ + public static final String ModelGLM4_6_AIR = "glm-4.6-air"; + + /** + * GLM-4.6-flash model code + */ + public static final String ModelGLM4_6_FLASH = "glm-4.6-flash"; /** * GLM-4.5 model code diff --git a/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java b/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java index dc05100..10d343c 100644 --- a/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java +++ b/core/src/main/java/ai/z/openapi/service/model/ChatCompletionCreateParams.java @@ -42,20 +42,19 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR private Boolean stream; /** - * Sampling temperature, controls output randomness, must be positive Range: - * [0.0,1.0] default value is 0.95 Higher values make output more - * random and creative; lower values make output more stable or deterministic It's - * recommended to adjust either top_p or temperature parameter based on your use case, - * but not both simultaneously + * Sampling temperature, controls output randomness, must be positive Range: [0.0,1.0] + * default value is 0.95 Higher values make output more random and creative; lower + * values make output more stable or deterministic It's recommended to adjust either + * top_p or temperature parameter based on your use case, but not both simultaneously */ private Float temperature; /** * Another method for temperature sampling, called nucleus sampling Range: (0.0, 1.0] * Model considers results with top_p probability mass tokens For example: 0.1 means - * the model decoder only considers tokens from the top 10% probability candidate set - * It's recommended to adjust either top_p or temperature parameter based on your use - * case, but not both simultaneously + * the model decoder only considers tokens from the top 10% probability candidate set + * It's recommended to adjust either top_p or temperature parameter based on your use + * case, but not both simultaneously */ @JsonProperty("top_p") private Float topP; @@ -117,10 +116,10 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR */ private ChatThinking thinking; - /** - * Whether to stream tool calls - */ - private Boolean tool_stream; + /** + * Whether to stream tool calls + */ + private Boolean tool_stream; /** * Forced watermark switch