Skip to content

Commit a749d91

Browse files
committed
0.2.1 update: add debug log; add stream model finish callback
1 parent 4303518 commit a749d91

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.liurb.ai.sdk</groupId>
88
<artifactId>java-ai-sdk</artifactId>
9-
<version>0.2.0</version>
9+
<version>0.2.1</version>
1010

1111
<name>java-ai-sdk</name>
1212
<description>
@@ -52,6 +52,7 @@
5252
<lombok.version>1.18.32</lombok.version>
5353
<fastjson2.version>2.0.52</fastjson2.version>
5454
<okhttp.version>4.12.0</okhttp.version>
55+
<slf4j-api.version>2.0.16</slf4j-api.version>
5556
</properties>
5657

5758
<dependencies>
@@ -81,6 +82,13 @@
8182
<scope>provided</scope>
8283
</dependency>
8384

85+
<dependency>
86+
<groupId>org.slf4j</groupId>
87+
<artifactId>slf4j-api</artifactId>
88+
<version>${slf4j-api.version}</version>
89+
</dependency>
90+
91+
8492
<dependency>
8593
<groupId>junit</groupId>
8694
<artifactId>junit</artifactId>

src/main/java/org/liurb/ai/sdk/common/AiBaseClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.alibaba.fastjson2.JSON;
44
import com.alibaba.fastjson2.JSONObject;
5+
import lombok.extern.slf4j.Slf4j;
56
import okhttp3.*;
67
import okhttp3.logging.HttpLoggingInterceptor;
78
import org.liurb.ai.sdk.common.bean.*;
@@ -15,6 +16,7 @@
1516
import java.util.List;
1617
import java.util.concurrent.TimeUnit;
1718

19+
@Slf4j
1820
public abstract class AiBaseClient {
1921

2022
private ModelAccount account;
@@ -100,7 +102,7 @@ public void onResponse(Call call, Response response) throws IOException {
100102
String line;
101103
while ((line = reader.readLine()) != null) {
102104
line = line.trim();
103-
System.out.println(line);
105+
log.debug(line);
104106

105107
AiStreamMessage streamMessage = buildStreamMessage(line);
106108
if (streamMessage != null) {
@@ -117,6 +119,9 @@ public void onResponse(Call call, Response response) throws IOException {
117119
//handle history
118120
buildStreamChatHistory(message, mediaData, textSb.toString(), history);
119121

122+
} finally {
123+
//finish callback
124+
responseListener.accept(AiStreamMessage.builder().stop(true).build());
120125
}
121126
}
122127
}

0 commit comments

Comments
 (0)