Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Add the following dependency to your `pom.xml`:
<dependency>
<groupId>ai.z.openapi</groupId>
<artifactId>zai-sdk</artifactId>
<version>0.3.3</version>
<version>0.3.5</version>
</dependency>
```

Expand All @@ -39,7 +39,7 @@ Add the following dependency to your `build.gradle` (for Groovy DSL):

```groovy
dependencies {
implementation 'ai.z.openapi:zai-sdk:0.3.3'
implementation 'ai.z.openapi:zai-sdk:0.3.5'
}
```

Expand Down Expand Up @@ -126,7 +126,7 @@ ZaiClient client = ZaiClient.builder()

// Create chat request
ChatCompletionCreateParams request = ChatCompletionCreateParams.builder()
.model("glm-5.1")
.model("glm-5.2")
.messages(Arrays.asList(
ChatMessage.builder()
.role(ChatMessageRole.USER.value())
Expand Down Expand Up @@ -154,7 +154,7 @@ if (response.isSuccess()) {
```java
// Create streaming request
ChatCompletionCreateParams streamRequest = ChatCompletionCreateParams.builder()
.model("glm-5.1")
.model("glm-5.2")
.messages(Arrays.asList(
ChatMessage.builder()
.role(ChatMessageRole.USER.value())
Expand Down Expand Up @@ -284,7 +284,7 @@ public class AIController {
@PostMapping("/chat")
public ResponseEntity<String> chat(@RequestBody ChatRequest request) {
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.model("glm-5.1")
.model("glm-5.2")
.messages(Arrays.asList(
ChatMessage.builder()
.role(ChatMessageRole.USER.value())
Expand Down
10 changes: 5 additions & 5 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Z.ai AI 平台官方 Java SDK,提供统一接口访问强大的AI能力,包
<dependency>
<groupId>ai.z.openapi</groupId>
<artifactId>zai-sdk</artifactId>
<version>0.3.3</version>
<version>0.3.5</version>
</dependency>
```

Expand All @@ -39,7 +39,7 @@ Z.ai AI 平台官方 Java SDK,提供统一接口访问强大的AI能力,包

```groovy
dependencies {
implementation 'ai.z.openapi:zai-sdk:0.3.3'
implementation 'ai.z.openapi:zai-sdk:0.3.5'
}
```

Expand Down Expand Up @@ -125,7 +125,7 @@ ZaiClient client = ZaiClient.builder()

// 创建对话请求
ChatCompletionCreateParams request = ChatCompletionCreateParams.builder()
.model("glm-5.1")
.model("glm-5.2")
.messages(Arrays.asList(
ChatMessage.builder()
.role(ChatMessageRole.USER.value())
Expand Down Expand Up @@ -153,7 +153,7 @@ if (response.isSuccess()) {
```java
// 创建流式请求
ChatCompletionCreateParams streamRequest = ChatCompletionCreateParams.builder()
.model("glm-5.1")
.model("glm-5.2")
.messages(Arrays.asList(
ChatMessage.builder()
.role(ChatMessageRole.USER.value())
Expand Down Expand Up @@ -285,7 +285,7 @@ public class AIController {
@PostMapping("/chat")
public ResponseEntity<String> chat(@RequestBody ChatRequest request) {
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.model("glm-5.1")
.model("glm-5.2")
.messages(Arrays.asList(
ChatMessage.builder()
.role(ChatMessageRole.USER.value())
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/ai/z/openapi/core/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ private Constants() {
// Text Generation Models
// =============================================================================

/**
* GLM-5.2 model code
*/
public static final String ModelGLM5_2 = "glm-5.2";

/**
* GLM-5.1 model code
*/
Expand Down
22 changes: 19 additions & 3 deletions core/src/main/java/ai/z/openapi/core/config/ZaiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Map;
Expand All @@ -17,7 +16,6 @@
*/
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ZaiConfig {

Expand Down Expand Up @@ -128,12 +126,30 @@ public class ZaiConfig {
@Builder.Default
private String source_channel = "java-sdk";

/**
* No-arg constructor that mirrors all {@link Builder.Default} field values. Lombok's
* {@code @NoArgsConstructor} does not apply {@code @Builder.Default} values, so we
* write this constructor explicitly to ensure every field starts with the same
* defaults as the builder.
*/
public ZaiConfig() {
this.expireMillis = 30 * 60 * 1000;
this.alg = "HS256";
this.disableTokenCache = true;
this.connectionPoolMaxIdleConnections = 5;
this.connectionPoolKeepAliveDuration = 10;
this.connectionPoolTimeUnit = TimeUnit.SECONDS;
this.timeOutTimeUnit = TimeUnit.SECONDS;
this.source_channel = "java-sdk";
}

/**
* Constructor with combined API secret key.
* @param apiKey combined secret key in format {apiKey}.{apiSecret}
* @throws RuntimeException if apiSecretKey format is invalid
*/
public ZaiConfig(String apiKey) {
this();
this.apiKey = apiKey;
String[] arrStr = apiKey.split("\\.");
if (arrStr.length != 2) {
Expand Down Expand Up @@ -251,7 +267,7 @@ public int getConnectionPoolMaxIdleConnections() {
* variable fallback.
*/
public long getConnectionPoolKeepAliveDuration() {
if (connectionPoolKeepAliveDuration != 1) { // If not default value
if (connectionPoolKeepAliveDuration != 10) { // If not default value
return connectionPoolKeepAliveDuration;
}
String propValue = System.getProperty(ENV_CONNECTION_POOL_KEEP_ALIVE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.3");
.header("Zai-SDK-Ver", "0.3.5");
if (Objects.nonNull(config.getCustomHeaders())) {
for (Map.Entry<String, String> entry : config.getCustomHeaders().entrySet()) {
request.addHeader(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.module.SimpleModule;
import ai.z.openapi.service.assistant.AssistantChoice;
import ai.z.openapi.service.deserialize.assistant.AssistantChoiceDeserializer;
Expand All @@ -14,7 +14,7 @@ public static ObjectMapper defaultObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
SimpleModule module = new SimpleModule();

module.addDeserializer(AssistantChoice.class, new AssistantChoiceDeserializer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,11 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR
@JsonProperty("watermark_enabled")
private Boolean watermarkEnabled;

/**
* Reasoning effort level, supported values: none, minimal, low, medium, high, xhigh,
* max. Defaults to max when not specified. Effective for glm-5.2 and above models.
*/
@JsonProperty("reasoning_effort")
private String reasoningEffort;

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</scm>

<properties>
<revision>0.3.4</revision>
<revision>0.3.5</revision>
<java.version>8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down
13 changes: 13 additions & 0 deletions samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,17 @@
<version>${revision}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<classpathScope>compile</classpathScope>
</configuration>
</plugin>
</plugins>
</build>
</project>
75 changes: 0 additions & 75 deletions samples/src/main/ai.z.openapi.samples/AgentExample.java

This file was deleted.

72 changes: 0 additions & 72 deletions samples/src/main/ai.z.openapi.samples/AgentVideoExample.java

This file was deleted.

Loading
Loading