@@ -244,6 +244,7 @@ public ChatResponse call(Prompt prompt) {
244
244
.provider (ZhiPuApiConstants .PROVIDER_NAME )
245
245
.build ();
246
246
247
+ // @formatter:off
247
248
ChatResponse response = ChatModelObservationDocumentation .CHAT_MODEL_OPERATION
248
249
.observation (this .observationConvention , DEFAULT_OBSERVATION_CONVENTION , () -> observationContext ,
249
250
this .observationRegistry )
@@ -262,13 +263,11 @@ public ChatResponse call(Prompt prompt) {
262
263
List <Choice > choices = chatCompletion .choices ();
263
264
264
265
List <Generation > generations = choices .stream ().map (choice -> {
265
- // @formatter:off
266
266
Map <String , Object > metadata = Map .of (
267
267
"id" , chatCompletion .id (),
268
268
"role" , choice .message ().role () != null ? choice .message ().role ().name () : "" ,
269
269
"finishReason" , choice .finishReason () != null ? choice .finishReason ().name () : ""
270
270
);
271
- // @formatter:on
272
271
return buildGeneration (choice , metadata );
273
272
}).toList ();
274
273
@@ -278,6 +277,7 @@ public ChatResponse call(Prompt prompt) {
278
277
279
278
return chatResponse ;
280
279
});
280
+ // @formatter:on
281
281
if (this .toolExecutionEligibilityPredicate .isToolExecutionRequired (requestPrompt .getOptions (), response )) {
282
282
var toolExecutionResult = this .toolCallingManager .executeToolCalls (requestPrompt , response );
283
283
if (toolExecutionResult .returnDirect ()) {
@@ -326,12 +326,13 @@ public Flux<ChatResponse> stream(Prompt prompt) {
326
326
327
327
observation .parentObservation (contextView .getOrDefault (ObservationThreadLocalAccessor .KEY , null )).start ();
328
328
329
+ // @formatter:off
329
330
Flux <ChatResponse > chatResponse = completionChunks .map (this ::chunkToChatCompletion )
330
331
.switchMap (chatCompletion -> Mono .just (chatCompletion ).map (chatCompletion2 -> {
331
332
try {
332
333
String id = chatCompletion2 .id ();
333
334
334
- // @formatter:off
335
+
335
336
List <Generation > generations = chatCompletion2 .choices ().stream ().map (choice -> {
336
337
if (choice .message ().role () != null ) {
337
338
roleMap .putIfAbsent (id , choice .message ().role ().name ());
@@ -353,8 +354,7 @@ public Flux<ChatResponse> stream(Prompt prompt) {
353
354
}
354
355
355
356
}));
356
-
357
- // @formatter:off
357
+
358
358
Flux <ChatResponse > flux = chatResponse .flatMap (response -> {
359
359
if (this .toolExecutionEligibilityPredicate .isToolExecutionRequired (requestPrompt .getOptions (), response )) {
360
360
return Flux .defer (() -> {
0 commit comments