@@ -46,23 +46,6 @@ public class ChatCompletionsReasoningExample {
4646 static ArkService service = ArkService .builder ().dispatcher (dispatcher ).connectionPool (connectionPool ).apiKey (apiKey ).build ();
4747
4848 public static void main (String [] args ) {
49- System .out .println ("\n ----- standard request -----" );
50- final List <ChatMessage > messages = new ArrayList <>();
51- final ChatMessage userMessage = ChatMessage .builder ().role (ChatMessageRole .USER ).content ("How many Rs are there in the word 'strawberry'?" ).build ();
52- messages .add (userMessage );
53-
54- ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest .builder ()
55- .model ("${YOUR_ENDPOINT_ID}" )
56- .messages (messages )
57- .build ();
58-
59- service .createChatCompletion (chatCompletionRequest ).getChoices ().forEach (
60- choice -> {
61- System .out .println (choice .getMessage ().getReasoningContent ());
62- System .out .println (choice .getMessage ().getContent ());
63- }
64- );
65-
6649 System .out .println ("\n ----- streaming request -----" );
6750 final List <ChatMessage > streamMessages = new ArrayList <>();
6851 final ChatMessage streamUserMessage = ChatMessage .builder ().role (ChatMessageRole .USER ).content ("How many Rs are there in the word 'strawberry'?" ).build ();
@@ -71,6 +54,7 @@ public static void main(String[] args) {
7154 ChatCompletionRequest streamChatCompletionRequest = ChatCompletionRequest .builder ()
7255 .model ("${YOUR_ENDPOINT_ID}" )
7356 .messages (streamMessages )
57+ .thinking (new ChatCompletionRequest .ChatCompletionRequestThinking ("enabled" ))
7458 .build ();
7559
7660 service .streamChatCompletion (streamChatCompletionRequest )
@@ -87,6 +71,25 @@ public static void main(String[] args) {
8771 }
8872 );
8973
74+ System .out .println ("\n ----- standard request -----" );
75+ final List <ChatMessage > messages = new ArrayList <>();
76+ final ChatMessage userMessage = ChatMessage .builder ().role (ChatMessageRole .USER ).content ("How many Rs are there in the word 'strawberry'?" ).build ();
77+ messages .add (userMessage );
78+
79+ ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest .builder ()
80+ .model ("${YOUR_ENDPOINT_ID}" )
81+ .messages (messages )
82+ .thinking (new ChatCompletionRequest .ChatCompletionRequestThinking ("enabled" ))
83+ .build ();
84+
85+ service .createChatCompletion (chatCompletionRequest ).getChoices ().forEach (
86+ choice -> {
87+ System .out .println (choice .getMessage ().getReasoningContent ());
88+ System .out .println (choice .getMessage ().getContent ());
89+ }
90+ );
91+
92+
9093 // shutdown service after all requests is finished
9194 service .shutdownExecutor ();
9295 }
0 commit comments