@@ -181,18 +181,16 @@ void beanStreamOutputConverterRecords() {
181
181
PromptTemplate promptTemplate = new PromptTemplate (template , Map .of ("format" , format ));
182
182
Prompt prompt = new Prompt (promptTemplate .createMessage ());
183
183
184
- // @formatter:off
185
- String generationTextFromStream = this .chatModel .stream (prompt )
186
- .collectList ()
187
- .block ()
188
- .stream ()
189
- .map (ChatResponse ::getResults )
190
- .flatMap (List ::stream )
191
- .map (Generation ::getOutput )
192
- .map (AssistantMessage ::getText )
193
- .filter (Objects ::nonNull )
194
- .collect (Collectors .joining ());
195
- // @formatter:on
184
+ String generationTextFromStream = this .chatModel .stream (prompt )
185
+ .collectList ()
186
+ .block ()
187
+ .stream ()
188
+ .map (ChatResponse ::getResults )
189
+ .flatMap (List ::stream )
190
+ .map (Generation ::getOutput )
191
+ .map (AssistantMessage ::getText )
192
+ .filter (Objects ::nonNull )
193
+ .collect (Collectors .joining ());
196
194
197
195
ActorsFilmsRecord actorsFilms = converter .convert (generationTextFromStream );
198
196
logger .info (actorsFilms .toString ());
@@ -204,13 +202,12 @@ void beanStreamOutputConverterRecords() {
204
202
void multiModalityImageUrl () throws IOException {
205
203
URL url = new URL ("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png" );
206
204
207
- // @formatter:off
208
- String response = ChatClient .create (this .chatModel ).prompt ()
209
- .options (QwenChatOptions .builder ().model (QwenModel .QWEN_VL_MAX .getName ()).build ())
210
- .user (u -> u .text ("Explain what do you see on this picture?" ).media (MimeTypeUtils .IMAGE_PNG , url ))
211
- .call ()
212
- .content ();
213
- // @formatter:on
205
+ String response = ChatClient .create (this .chatModel )
206
+ .prompt ()
207
+ .options (QwenChatOptions .builder ().model (QwenModel .QWEN_VL_MAX .getName ()).build ())
208
+ .user (u -> u .text ("Explain what do you see on this picture?" ).media (MimeTypeUtils .IMAGE_PNG , url ))
209
+ .call ()
210
+ .content ();
214
211
215
212
logger .info (response );
216
213
assertThat (response ).containsAnyOf ("bananas" , "apple" , "bowl" , "basket" , "fruit stand" );
@@ -220,31 +217,28 @@ void multiModalityImageUrl() throws IOException {
220
217
void multiModalityImageResource () {
221
218
Resource resource = new ClassPathResource ("multimodal.test.png" );
222
219
223
- // @formatter:off
224
- String response = ChatClient .create (this .chatModel ).prompt ()
225
- .options (QwenChatOptions .builder ().model (QwenModel .QWEN_VL_MAX .getName ()).build ())
226
- .user (u -> u .text ("Explain what do you see on this picture?" ).media (MimeTypeUtils .IMAGE_PNG , resource ))
227
- .call ()
228
- .content ();
229
- // @formatter:on
220
+ String response = ChatClient .create (this .chatModel )
221
+ .prompt ()
222
+ .options (QwenChatOptions .builder ().model (QwenModel .QWEN_VL_MAX .getName ()).build ())
223
+ .user (u -> u .text ("Explain what do you see on this picture?" ).media (MimeTypeUtils .IMAGE_PNG , resource ))
224
+ .call ()
225
+ .content ();
230
226
231
227
assertThat (response ).containsAnyOf ("bananas" , "apple" , "bowl" , "basket" , "fruit stand" );
232
228
}
233
229
234
230
@ Test
235
231
void answerAfterSearch () {
236
- // @formatter:off
237
- QwenChatOptions options = QwenChatOptions .builder ()
238
- .enableSearch (true )
239
- .searchOptions (QwenChatOptions .SearchOptions .builder ()
240
- .citationFormat ("[<number>]" )
241
- .enableCitation (true )
242
- .enableSource (true )
243
- .forcedSearch (true )
244
- .searchStrategy ("standard" )
245
- .build ())
246
- .build ();
247
- // @formatter:on
232
+ QwenChatOptions options = QwenChatOptions .builder ()
233
+ .enableSearch (true )
234
+ .searchOptions (QwenChatOptions .SearchOptions .builder ()
235
+ .citationFormat ("[<number>]" )
236
+ .enableCitation (true )
237
+ .enableSource (true )
238
+ .forcedSearch (true )
239
+ .searchStrategy ("standard" )
240
+ .build ())
241
+ .build ();
248
242
249
243
Prompt prompt = new Prompt ("What is the weather of Beijing?" , options );
250
244
@@ -258,20 +252,16 @@ void answerAfterSearch() {
258
252
259
253
@ Test
260
254
void translateMessage () {
261
- // @formatter:off
262
- QwenChatOptions options = QwenChatOptions .builder ()
263
- .model (QwenModel .QWEN_MT_PLUS .getName ())
264
- .translationOptions (QwenChatOptions .TranslationOptions .builder ()
265
- .sourceLang ("English" )
266
- .targetLang ("Chinese" )
267
- .terms (singletonList (QwenChatOptions .TranslationOptionTerm .builder ()
268
- .source ("memory" )
269
- .target ("内存" )
270
- .build ()))
271
- .domains ("Translate into this IT domain style." )
272
- .build ())
273
- .build ();
274
- // @formatter:on
255
+ QwenChatOptions options = QwenChatOptions .builder ()
256
+ .model (QwenModel .QWEN_MT_PLUS .getName ())
257
+ .translationOptions (QwenChatOptions .TranslationOptions .builder ()
258
+ .sourceLang ("English" )
259
+ .targetLang ("Chinese" )
260
+ .terms (singletonList (
261
+ QwenChatOptions .TranslationOptionTerm .builder ().source ("memory" ).target ("内存" ).build ()))
262
+ .domains ("Translate into this IT domain style." )
263
+ .build ())
264
+ .build ();
275
265
276
266
Prompt prompt = new Prompt ("my memory" , options );
277
267
0 commit comments