Skip to content

Commit deac555

Browse files
committed
Merge 'integration_2024-12-05_629870411266' into 'master'
merge branch integration_2024-12-05_629870411266 into master See merge request: !313
2 parents 93fbb24 + 6fd8d6e commit deac555

File tree

129 files changed

+9428
-546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+9428
-546
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<dependency>
5555
<groupId>com.volcengine</groupId>
5656
<artifactId>volcengine-java-sdk-bom</artifactId>
57-
<version>0.1.138</version>
57+
<version>0.1.139</version>
5858
<type>pom</type>
5959
<scope>import</scope>
6060
</dependency>
@@ -70,12 +70,12 @@
7070
<dependency>
7171
<groupId>com.volcengine</groupId>
7272
<artifactId>volcengine-java-sdk-vpc</artifactId>
73-
<version>0.1.138</version>
73+
<version>0.1.139</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>com.volcengine</groupId>
7777
<artifactId>volcengine-java-sdk-ecs</artifactId>
78-
<version>0.1.138</version>
78+
<version>0.1.139</version>
7979
</dependency>
8080
</dependencies>
8181
```

meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"lasted": "0.1.138",
3-
"meta_commit": "d6f154626edbc873356df218e33494c6fa5cbc32"
2+
"lasted": "0.1.139",
3+
"meta_commit": "9c1ca76c57d6b77bb842db8b1d54a35005b38060"
44
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.volcengine</groupId>
55
<artifactId>volcengine-java-sdk</artifactId>
66
<packaging>pom</packaging>
7-
<version>0.1.138</version>
7+
<version>0.1.139</version>
88
<name>volcengine-java-sdk</name>
99
<url>https://open.volcengineapi.com</url>
1010
<description>The Java SDK For Volcengine</description>

volcengine-java-sdk-advdefence/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>volcengine-java-sdk</artifactId>
55
<groupId>com.volcengine</groupId>
6-
<version>0.1.138</version>
6+
<version>0.1.139</version>
77
<relativePath>../pom.xml</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

volcengine-java-sdk-advdefence20230308/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>volcengine-java-sdk</artifactId>
55
<groupId>com.volcengine</groupId>
6-
<version>0.1.138</version>
6+
<version>0.1.139</version>
77
<relativePath>../pom.xml</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

volcengine-java-sdk-alb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>volcengine-java-sdk</artifactId>
55
<groupId>com.volcengine</groupId>
6-
<version>0.1.138</version>
6+
<version>0.1.139</version>
77
<relativePath>../pom.xml</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

volcengine-java-sdk-ark-runtime/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>volcengine-java-sdk</artifactId>
55
<groupId>com.volcengine</groupId>
6-
<version>0.1.138</version>
6+
<version>0.1.139</version>
77
<relativePath>../pom.xml</relativePath>
88
</parent>
99
<build>

volcengine-java-sdk-ark-runtime/src/main/java/com/volcengine/ark/runtime/interceptor/RequestIdInterceptor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.volcengine.ark.runtime.interceptor;
22

33
import com.volcengine.ark.runtime.Const;
4+
import com.volcengine.version.Version;
45
import okhttp3.Interceptor;
56
import okhttp3.Request;
67
import okhttp3.Response;
@@ -22,6 +23,7 @@ public Response intercept(Chain chain) throws IOException {
2223
if (chain.request().header(Const.CLIENT_REQUEST_HEADER) == null || chain.request().header(Const.CLIENT_REQUEST_HEADER).length() == 0) {
2324
requestBuilder = requestBuilder.header(Const.CLIENT_REQUEST_HEADER, genRequestId());
2425
}
26+
requestBuilder.header("User-Agent", getUserAgent());
2527

2628
Request request = requestBuilder.build();
2729
return chain.proceed(request);
@@ -32,4 +34,14 @@ private String genRequestId() {
3234
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMddhhmmss");
3335
return dateFormat.format(date) + RandomStringUtils.randomAlphanumeric(20);
3436
}
37+
38+
private static String getUserAgent() {
39+
String format = "%s/%s/(%s;%s;%s)";
40+
41+
String osInfo = System.getProperty("os.name") + "-" + System.getProperty("os.version");
42+
String jdkInfo = "java-" + System.getProperty("java.version");
43+
String arch = System.getProperty("os.arch");
44+
45+
return String.format(format, Version.SDK_NAME, Version.SDK_VERSION, jdkInfo, osInfo, arch);
46+
}
3547
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package com.volcengine.ark.runtime.service;
22

33

4+
import okhttp3.ConnectionPool;
5+
import okhttp3.Dispatcher;
6+
47
import java.time.Duration;
8+
import java.util.concurrent.TimeUnit;
59

610

711
/**
812
* The interface ark service.
913
*/
1014
public abstract class ArkBaseService {
1115

12-
static final String BASE_URL = "https://ark.cn-beijing.volces.com";
13-
static final String BASE_REGION = "cn-beijing";
14-
static final Duration DEFAULT_TIMEOUT = Duration.ofMinutes(10);
15-
static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofMinutes(1);
16-
String apiKey = "";
17-
String ak = "";
18-
String sk = "";
19-
16+
public static final String BASE_URL = "https://ark.cn-beijing.volces.com";
17+
public static final String BASE_REGION = "cn-beijing";
18+
public static final Duration DEFAULT_TIMEOUT = Duration.ofMinutes(10);
19+
public static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofMinutes(1);
2020
}

volcengine-java-sdk-ark-runtime/test/java/com/volcengine/ark/runtime/BotChatCompletionsExample.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
import com.volcengine.ark.runtime.model.bot.completion.chat.BotChatCompletionRequest;
55
import com.volcengine.ark.runtime.model.bot.completion.chat.BotChatCompletionResult;
6-
import com.volcengine.ark.runtime.model.completion.chat.ChatCompletionRequest;
76
import com.volcengine.ark.runtime.model.completion.chat.ChatMessage;
87
import com.volcengine.ark.runtime.model.completion.chat.ChatMessageRole;
98
import com.volcengine.ark.runtime.service.ArkService;
9+
import okhttp3.ConnectionPool;
10+
import okhttp3.Dispatcher;
1011

1112
import java.util.ArrayList;
1213
import java.util.List;
14+
import java.util.concurrent.TimeUnit;
1315

1416
/*
1517
# pom.xml
@@ -37,11 +39,13 @@ public class BotChatCompletionsExample {
3739
* To get your ak&sk, please refer to this document(https://www.volcengine.com/docs/6291/65568)
3840
* For more information,please check this document(https://www.volcengine.com/docs/82379/1263279)
3941
*/
40-
public static void main(String[] args) {
4142

42-
String apiKey = System.getenv("ARK_API_KEY");
43-
ArkService service = new ArkService(apiKey);
43+
static String apiKey = System.getenv("ARK_API_KEY");
44+
static ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
45+
static Dispatcher dispatcher = new Dispatcher();
46+
static ArkService service = ArkService.builder().dispatcher(dispatcher).connectionPool(connectionPool).apiKey(apiKey).build();
4447

48+
public static void main(String[] args) {
4549
System.out.println("\n----- standard request -----");
4650
final List<ChatMessage> messages = new ArrayList<>();
4751
final ChatMessage systemMessage = ChatMessage.builder().role(ChatMessageRole.SYSTEM).content("你是豆包,是由字节跳动开发的 AI 人工智能助手").build();
@@ -57,7 +61,9 @@ public static void main(String[] args) {
5761
BotChatCompletionResult chatCompletionResult = service.createBotChatCompletion(chatCompletionRequest);
5862
chatCompletionResult.getChoices().forEach(choice -> System.out.println(choice.getMessage().getContent()));
5963
// the references example
60-
chatCompletionResult.getReferences().forEach(ref -> System.out.println(ref.getUrl()));
64+
if (chatCompletionResult.getReferences() != null) {
65+
chatCompletionResult.getReferences().forEach(ref -> System.out.println(ref.getUrl()));
66+
}
6167

6268
System.out.println("\n----- streaming request -----");
6369
final List<ChatMessage> streamMessages = new ArrayList<>();
@@ -84,7 +90,7 @@ public static void main(String[] args) {
8490
}
8591
);
8692

87-
// shutdown service
93+
// shutdown service after all requests is finished
8894
service.shutdownExecutor();
8995
}
9096

0 commit comments

Comments
 (0)