Skip to content

Commit df3fad3

Browse files
author
潘婉宁
committed
chore: add reasoning example
1 parent 25db762 commit df3fad3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ChatCompletionsReasoningExample {
3131
* ArkService service = new ArkService(apiKey);
3232
* Note: If you use an API key, this API key will not be refreshed.
3333
* To prevent the API from expiring and failing after some time, choose an API key with no expiration date.
34-
*
34+
* <p>
3535
* 2.If you authorize your endpoint with Volcengine Identity and Access Management(IAM), set your api key to environment variable "VOLC_ACCESSKEY", "VOLC_SECRETKEY"
3636
* String ak = System.getenv("VOLC_ACCESSKEY");
3737
* String sk = System.getenv("VOLC_SECRETKEY");
@@ -57,13 +57,10 @@ public static void main(String[] args) {
5757
.build();
5858

5959
service.createChatCompletion(chatCompletionRequest).getChoices().forEach(
60-
choice-> {
61-
if(StringUtils.isNotEmpty(choice.getMessage().getReasoningContent())){
62-
System.out.println(choice.getMessage().getReasoningContent());
63-
}else{
64-
System.out.println(choice.getMessage().getContent());
65-
}
66-
}
60+
choice -> {
61+
System.out.println(choice.getMessage().getReasoningContent());
62+
System.out.println(choice.getMessage().getContent());
63+
}
6764
);
6865

6966
System.out.println("\n----- streaming request -----");
@@ -81,9 +78,9 @@ public static void main(String[] args) {
8178
.blockingForEach(
8279
delta -> {
8380
if (!delta.getChoices().isEmpty()) {
84-
if(StringUtils.isNotEmpty(delta.getChoices().get(0).getMessage().getReasoningContent())){
81+
if (StringUtils.isNotEmpty(delta.getChoices().get(0).getMessage().getReasoningContent())) {
8582
System.out.print(delta.getChoices().get(0).getMessage().getReasoningContent());
86-
}else{
83+
} else {
8784
System.out.print(delta.getChoices().get(0).getMessage().getContent());
8885
}
8986
}

0 commit comments

Comments
 (0)