Skip to content

Commit 3783592

Browse files
committed
new-feat: support stream judge and Support only new ApiClient once
1 parent 27a4301 commit 3783592

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

volcengine-java-sdk-wafruntime/src/main/java/com/volcengine/wafruntime/LLMStreamSession.java

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public LLMStreamSession(String streamBuf, int streamSendLen, String msgID, Check
4444
*
4545
* @return 流缓冲区的值
4646
*/
47-
public String getStreamBuf() {
47+
String getStreamBuf() {
4848
return streamBuf;
4949
}
5050

@@ -53,7 +53,7 @@ public String getStreamBuf() {
5353
*
5454
* @param streamBuf 要设置的流缓冲区的值
5555
*/
56-
public void setStreamBuf(String streamBuf) {
56+
void setStreamBuf(String streamBuf) {
5757
this.streamBuf = streamBuf;
5858
}
5959

@@ -62,7 +62,7 @@ public void setStreamBuf(String streamBuf) {
6262
*
6363
* @return 流发送长度的值
6464
*/
65-
public int getStreamSendLen() {
65+
int getStreamSendLen() {
6666
return streamSendLen;
6767
}
6868

@@ -71,7 +71,7 @@ public int getStreamSendLen() {
7171
*
7272
* @param streamSendLen 要设置的流发送长度的值
7373
*/
74-
public void setStreamSendLen(int streamSendLen) {
74+
void setStreamSendLen(int streamSendLen) {
7575
this.streamSendLen = streamSendLen;
7676
}
7777

@@ -80,7 +80,7 @@ public void setStreamSendLen(int streamSendLen) {
8080
*
8181
* @return 消息 ID 的值
8282
*/
83-
public String getMsgID() {
83+
String getMsgID() {
8484
return msgID;
8585
}
8686

@@ -89,7 +89,7 @@ public String getMsgID() {
8989
*
9090
* @param msgID 要设置的消息 ID 的值
9191
*/
92-
public void setMsgID(String msgID) {
92+
void setMsgID(String msgID) {
9393
this.msgID = msgID;
9494
}
9595

@@ -98,7 +98,7 @@ public void setMsgID(String msgID) {
9898
*
9999
* @return 默认响应体
100100
*/
101-
public CheckLLMResponseStreamResponse getDefaultBody() {
101+
CheckLLMResponseStreamResponse getDefaultBody() {
102102
return defaultBody;
103103
}
104104

@@ -107,7 +107,7 @@ public CheckLLMResponseStreamResponse getDefaultBody() {
107107
*
108108
* @param defaultBody 要设置的默认响应体
109109
*/
110-
public void setDefaultBody(CheckLLMResponseStreamResponse defaultBody) {
110+
void setDefaultBody(CheckLLMResponseStreamResponse defaultBody) {
111111
this.defaultBody = defaultBody;
112112
}
113113

@@ -117,25 +117,11 @@ public void setDefaultBody(CheckLLMResponseStreamResponse defaultBody) {
117117
*
118118
* @param str 要追加的字符串
119119
*/
120-
public void appendStreamBuf(String str) {
120+
void appendStreamBuf(String str) {
121121
if (str != null) {
122122
this.streamBuf += str;
123123
this.streamSendLen += str.length();
124124
}
125125
}
126126

127-
/**
128-
* 重写 toString 方法,返回对象的字符串表示形式。
129-
*
130-
* @return 对象的字符串表示形式
131-
*/
132-
@Override
133-
public String toString() {
134-
return "LLMStreamSession{" +
135-
"streamBuf='" + streamBuf + '\'' +
136-
", streamSendLen=" + streamSendLen +
137-
", msgID='" + msgID + '\'' +
138-
", defaultBody=" + defaultBody +
139-
'}';
140-
}
141127
}

volcengine-java-sdk-wafruntime/src/main/java/com/volcengine/wafruntime/WafApiRuntime.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public CheckLLMResponseStreamResponse checkLLMResponseStream(CheckLLMResponseStr
4646
body.setContent(session.getStreamBuf());
4747

4848
String msgID = session.getMsgID();
49-
if (msgID != null) {
49+
if (msgID != null && !msgID.isEmpty()) {
5050
body.setMsgID(msgID);
5151
}
5252

5353
if (!body.getContent().isEmpty()) {
5454
ApiResponse<CheckLLMResponseStreamResponse> resp = checkLLMResponseStreamWithHttpInfo(body);
55-
if (session.getMsgID() == null && resp.getData() != null) {
55+
if (session.getMsgID().isEmpty() && resp.getData() != null) {
5656
session.setMsgID(resp.getData().getMsgID());
5757
}
5858
session.setDefaultBody(resp.getData() );

0 commit comments

Comments
 (0)